GearDrop.cs 1.9 KB

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