Portal.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Portal.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 Microsoft.Xna.Framework;
  12. using Microsoft.Xna.Framework.Content;
  13. #endregion
  14. namespace RolePlayingGameData
  15. {
  16. /// <summary>
  17. /// A transition point from one map to another.
  18. /// </summary>
  19. public class Portal : ContentObject
  20. {
  21. #region Description
  22. /// <summary>
  23. /// The name of the object.
  24. /// </summary>
  25. private string name;
  26. /// <summary>
  27. /// The name of the object.
  28. /// </summary>
  29. public string Name
  30. {
  31. get { return name; }
  32. set { name = value; }
  33. }
  34. #endregion
  35. #region Landing Data
  36. /// <summary>
  37. /// The map coordinate that the party will automatically walk to
  38. /// after spawning on this portal.
  39. /// </summary>
  40. private Point landingMapPosition;
  41. /// <summary>
  42. /// The map coordinate that the party will automatically walk to
  43. /// after spawning on this portal.
  44. /// </summary>
  45. public Point LandingMapPosition
  46. {
  47. get { return landingMapPosition; }
  48. set { landingMapPosition = value; }
  49. }
  50. #endregion
  51. #region Destination Map Data
  52. /// <summary>
  53. /// The content name of the map that the portal links to.
  54. /// </summary>
  55. private string destinationMapContentName;
  56. /// <summary>
  57. /// The content name of the map that the portal links to.
  58. /// </summary>
  59. public string DestinationMapContentName
  60. {
  61. get { return destinationMapContentName; }
  62. set { destinationMapContentName = value; }
  63. }
  64. /// <summary>
  65. /// The name of the portal that the party spawns at on the destination map.
  66. /// </summary>
  67. private string destinationMapPortalName;
  68. /// <summary>
  69. /// The name of the portal that the party spawns at on the destination map.
  70. /// </summary>
  71. public string DestinationMapPortalName
  72. {
  73. get { return destinationMapPortalName; }
  74. set { destinationMapPortalName = value; }
  75. }
  76. #endregion
  77. #region Content Type Reader
  78. /// <summary>
  79. /// Reads a Portal object from the content pipeline.
  80. /// </summary>
  81. public class PortalReader : ContentTypeReader<Portal>
  82. {
  83. protected override Portal Read(ContentReader input,
  84. Portal existingInstance)
  85. {
  86. Portal portal = existingInstance;
  87. if (portal == null)
  88. {
  89. portal = new Portal();
  90. }
  91. portal.AssetName = input.AssetName;
  92. portal.Name = input.ReadString();
  93. portal.LandingMapPosition = input.ReadObject<Point>();
  94. portal.DestinationMapContentName = input.ReadString();
  95. portal.DestinationMapPortalName = input.ReadString();
  96. return portal;
  97. }
  98. }
  99. #endregion
  100. }
  101. }