Equipment.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Equipment.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 System.Collections.Generic;
  12. using Microsoft.Xna.Framework.Content;
  13. #endregion
  14. namespace RolePlayingGameData
  15. {
  16. /// <summary>
  17. /// Gear that may be equipped onto a FightingCharacter.
  18. /// </summary>
  19. public class Equipment : Gear
  20. {
  21. #region Owner Buff
  22. /// <summary>
  23. /// The statistics buff applied by this equipment to its owner.
  24. /// </summary>
  25. /// <remarks>Buff values are positive, and will be added.</remarks>
  26. private StatisticsValue ownerBuffStatistics = new StatisticsValue();
  27. /// <summary>
  28. /// The statistics buff applied by this equipment to its owner.
  29. /// </summary>
  30. /// <remarks>Buff values are positive, and will be added.</remarks>
  31. [ContentSerializer(Optional=true)]
  32. public StatisticsValue OwnerBuffStatistics
  33. {
  34. get { return ownerBuffStatistics; }
  35. set { ownerBuffStatistics = value; }
  36. }
  37. #endregion
  38. #region Content Type Reader
  39. /// <summary>
  40. /// Read the Equipment type from the content pipeline.
  41. /// </summary>
  42. public class EquipmentReader : ContentTypeReader<Equipment>
  43. {
  44. /// <summary>
  45. /// Read the Equipment type from the content pipeline.
  46. /// </summary>
  47. protected override Equipment Read(ContentReader input,
  48. Equipment existingInstance)
  49. {
  50. Equipment equipment = existingInstance;
  51. if (equipment == null)
  52. {
  53. throw new ArgumentException(
  54. "Unable to create new Equipment objects.");
  55. }
  56. // read the gear settings
  57. input.ReadRawObject<Gear>(equipment as Gear);
  58. // read the equipment settings
  59. equipment.OwnerBuffStatistics = input.ReadObject<StatisticsValue>();
  60. return equipment;
  61. }
  62. }
  63. #endregion
  64. }
  65. }