Equipment.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //-----------------------------------------------------------------------------
  2. // Equipment.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using System.Collections.Generic;
  9. using Microsoft.Xna.Framework.Content;
  10. namespace RolePlaying.Data
  11. {
  12. /// <summary>
  13. /// Gear that may be equipped onto a FightingCharacter.
  14. /// </summary>
  15. public class Equipment : Gear
  16. {
  17. /// <summary>
  18. /// The statistics buff applied by this equipment to its owner.
  19. /// </summary>
  20. /// <remarks>Buff values are positive, and will be added.</remarks>
  21. private StatisticsValue ownerBuffStatistics = new StatisticsValue();
  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. [ContentSerializer(Optional = true)]
  27. public StatisticsValue OwnerBuffStatistics
  28. {
  29. get { return ownerBuffStatistics; }
  30. set { ownerBuffStatistics = value; }
  31. }
  32. public static Equipment Load(string equipmentAssetName)
  33. {
  34. throw new NotImplementedException();
  35. }
  36. /// <summary>
  37. /// Read the Equipment type from the content pipeline.
  38. /// </summary>
  39. public class EquipmentReader : ContentTypeReader<Equipment>
  40. {
  41. /// <summary>
  42. /// Read the Equipment type from the content pipeline.
  43. /// </summary>
  44. protected override Equipment Read(ContentReader input,
  45. Equipment existingInstance)
  46. {
  47. Equipment equipment = existingInstance;
  48. if (equipment == null)
  49. {
  50. throw new ArgumentException(
  51. "Unable to create new Equipment objects.");
  52. }
  53. // read the gear settings
  54. input.ReadRawObject<Gear>(equipment as Gear);
  55. // read the equipment settings
  56. equipment.OwnerBuffStatistics = input.ReadObject<StatisticsValue>();
  57. return equipment;
  58. }
  59. }
  60. }
  61. }