GearDrop.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GearDrop.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using Microsoft.Xna.Framework.Content;
  12. #endregion
  13. namespace RolePlayingGameData
  14. {
  15. /// <summary>
  16. /// Description of how often a particular gear drops, typically from a Monster.
  17. /// </summary>
  18. public class GearDrop
  19. {
  20. /// <summary>
  21. /// The content name of the gear.
  22. /// </summary>
  23. private string gearName;
  24. /// <summary>
  25. /// The content name of the gear.
  26. /// </summary>
  27. public string GearName
  28. {
  29. get { return gearName; }
  30. set { gearName = value; }
  31. }
  32. /// <summary>
  33. /// The percentage chance that the gear will drop, from 0 to 100.
  34. /// </summary>
  35. private int dropPercentage;
  36. /// <summary>
  37. /// The percentage chance that the gear will drop, from 0 to 100.
  38. /// </summary>
  39. public int DropPercentage
  40. {
  41. get { return dropPercentage; }
  42. set { dropPercentage = (value > 100 ? 100 : (value < 0 ? 0 : value)); }
  43. }
  44. #region Content Type Reader
  45. /// <summary>
  46. /// Read a GearDrop object from the content pipeline.
  47. /// </summary>
  48. public class GearDropReader : ContentTypeReader<GearDrop>
  49. {
  50. protected override GearDrop Read(ContentReader input,
  51. GearDrop existingInstance)
  52. {
  53. GearDrop gearDrop = existingInstance;
  54. if (gearDrop == null)
  55. {
  56. gearDrop = new GearDrop();
  57. }
  58. gearDrop.GearName = input.ReadString();
  59. gearDrop.DropPercentage = input.ReadInt32();
  60. return gearDrop;
  61. }
  62. }
  63. #endregion
  64. }
  65. }