FixedCombat.cs 2.2 KB

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