FixedCombat.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // FixedCombat.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 System.IO;
  13. using Microsoft.Xna.Framework.Content;
  14. #endregion
  15. namespace RolePlayingGameData
  16. {
  17. /// <summary>
  18. /// The description of a fixed combat encounter in the world.
  19. /// </summary>
  20. public class FixedCombat : WorldObject
  21. {
  22. /// <summary>
  23. /// The content name and quantities of the monsters in this encounter.
  24. /// </summary>
  25. private List<ContentEntry<Monster>> entries = new List<ContentEntry<Monster>>();
  26. /// <summary>
  27. /// The content name and quantities of the monsters in this encounter.
  28. /// </summary>
  29. public List<ContentEntry<Monster>> Entries
  30. {
  31. get { return entries; }
  32. set { entries = value; }
  33. }
  34. #region Content Type Reader
  35. /// <summary>
  36. /// Reads a FixedCombat object from the content pipeline.
  37. /// </summary>
  38. public class FixedCombatReader : ContentTypeReader<FixedCombat>
  39. {
  40. /// <summary>
  41. /// Reads a FixedCombat object from the content pipeline.
  42. /// </summary>
  43. protected override FixedCombat Read(ContentReader input,
  44. FixedCombat existingInstance)
  45. {
  46. FixedCombat fixedCombat = existingInstance;
  47. if (fixedCombat == null)
  48. {
  49. fixedCombat = new FixedCombat();
  50. }
  51. input.ReadRawObject<WorldObject>(fixedCombat as WorldObject);
  52. fixedCombat.Entries.AddRange(
  53. input.ReadObject<List<ContentEntry<Monster>>>());
  54. foreach (ContentEntry<Monster> fixedCombatEntry in fixedCombat.Entries)
  55. {
  56. fixedCombatEntry.Content = input.ContentManager.Load<Monster>(
  57. Path.Combine(@"Characters\Monsters",
  58. fixedCombatEntry.ContentName));
  59. }
  60. return fixedCombat;
  61. }
  62. }
  63. #endregion
  64. }
  65. }