GameStartDescription.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GameStartDescription.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. /// The data needed to start a new game.
  18. /// </summary>
  19. public class GameStartDescription
  20. {
  21. #region Map
  22. /// <summary>
  23. /// The content name of the map for a new game.
  24. /// </summary>
  25. private string mapContentName;
  26. /// <summary>
  27. /// The content name of the map for a new game.
  28. /// </summary>
  29. public string MapContentName
  30. {
  31. get { return mapContentName; }
  32. set { mapContentName = value; }
  33. }
  34. #endregion
  35. #region Party
  36. /// <summary>
  37. /// The content names of the players in the party from the beginning.
  38. /// </summary>
  39. private List<string> playerContentNames = new List<string>();
  40. /// <summary>
  41. /// The content names of the players in the party from the beginning.
  42. /// </summary>
  43. public List<string> PlayerContentNames
  44. {
  45. get { return playerContentNames; }
  46. set { playerContentNames = value; }
  47. }
  48. #endregion
  49. #region Quest Line
  50. /// <summary>
  51. /// The quest line in action when the game starts.
  52. /// </summary>
  53. /// <remarks>The first quest will be started before the world is shown.</remarks>
  54. private string questLineContentName;
  55. /// <summary>
  56. /// The quest line in action when the game starts.
  57. /// </summary>
  58. /// <remarks>The first quest will be started before the world is shown.</remarks>
  59. [ContentSerializer(Optional = true)]
  60. public string QuestLineContentName
  61. {
  62. get { return questLineContentName; }
  63. set { questLineContentName = value; }
  64. }
  65. #endregion
  66. #region Content Type Reader
  67. /// <summary>
  68. /// Read a GameStartDescription object from the content pipeline.
  69. /// </summary>
  70. public class GameStartDescriptionReader : ContentTypeReader<GameStartDescription>
  71. {
  72. protected override GameStartDescription Read(ContentReader input,
  73. GameStartDescription existingInstance)
  74. {
  75. GameStartDescription desc = existingInstance;
  76. if (desc == null)
  77. {
  78. desc = new GameStartDescription();
  79. }
  80. desc.MapContentName = input.ReadString();
  81. desc.PlayerContentNames.AddRange(input.ReadObject<List<string>>());
  82. desc.QuestLineContentName = input.ReadString();
  83. return desc;
  84. }
  85. }
  86. #endregion
  87. }
  88. }