GameStartDescription.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //-----------------------------------------------------------------------------
  2. // GameStartDescription.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using Microsoft.Xna.Framework;
  8. using Microsoft.Xna.Framework.Content;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Xml.Linq;
  13. namespace RolePlaying.Data
  14. {
  15. /// <summary>
  16. /// The data needed to start a new game.
  17. /// </summary>
  18. public class GameStartDescription
  19. {
  20. /// <summary>
  21. /// The content name of the map for a new game.
  22. /// </summary>
  23. private string mapContentName;
  24. /// <summary>
  25. /// The content name of the map for a new game.
  26. /// </summary>
  27. public string MapContentName
  28. {
  29. get { return mapContentName; }
  30. set { mapContentName = value; }
  31. }
  32. /// <summary>
  33. /// The content names of the players in the party from the beginning.
  34. /// </summary>
  35. private List<string> playerContentNames = new List<string>();
  36. /// <summary>
  37. /// The content names of the players in the party from the beginning.
  38. /// </summary>
  39. public List<string> PlayerContentNames
  40. {
  41. get { return playerContentNames; }
  42. set { playerContentNames = value; }
  43. }
  44. /// <summary>
  45. /// The quest line in action when the game starts.
  46. /// </summary>
  47. /// <remarks>The first quest will be started before the world is shown.</remarks>
  48. private string questLineContentName;
  49. /// <summary>
  50. /// The quest line in action when the game starts.
  51. /// </summary>
  52. /// <remarks>The first quest will be started before the world is shown.</remarks>
  53. [ContentSerializer(Optional = true)]
  54. public string QuestLineContentName
  55. {
  56. get { return questLineContentName; }
  57. set { questLineContentName = value; }
  58. }
  59. public static GameStartDescription Load(string description)
  60. {
  61. XElement asset = XmlHelper.GetAssetElementFromXML(description);
  62. var gameStartDescription = new GameStartDescription
  63. {
  64. MapContentName = (string)asset.Element("MapContentName"),
  65. PlayerContentNames = asset.Element("PlayerContentNames")
  66. .Elements("Item")
  67. .Select(x => (string)x)
  68. .ToList(),
  69. QuestLineContentName = (string)asset.Element("QuestLineContentName"),
  70. };
  71. return gameStartDescription;
  72. }
  73. }
  74. }