Portal.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //-----------------------------------------------------------------------------
  2. // Portal.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using Microsoft.Xna.Framework;
  9. using Microsoft.Xna.Framework.Content;
  10. namespace RolePlaying.Data
  11. {
  12. /// <summary>
  13. /// A transition point from one map to another.
  14. /// </summary>
  15. public class Portal : ContentObject
  16. {
  17. /// <summary>
  18. /// The name of the object.
  19. /// </summary>
  20. private string name;
  21. /// <summary>
  22. /// The name of the object.
  23. /// </summary>
  24. public string Name
  25. {
  26. get { return name; }
  27. set { name = value; }
  28. }
  29. /// <summary>
  30. /// The map coordinate that the party will automatically walk to
  31. /// after spawning on this portal.
  32. /// </summary>
  33. private Point landingMapPosition;
  34. /// <summary>
  35. /// The map coordinate that the party will automatically walk to
  36. /// after spawning on this portal.
  37. /// </summary>
  38. public Point LandingMapPosition
  39. {
  40. get { return landingMapPosition; }
  41. set { landingMapPosition = value; }
  42. }
  43. /// <summary>
  44. /// The content name of the map that the portal links to.
  45. /// </summary>
  46. private string destinationMapContentName;
  47. /// <summary>
  48. /// The content name of the map that the portal links to.
  49. /// </summary>
  50. public string DestinationMapContentName
  51. {
  52. get { return destinationMapContentName; }
  53. set { destinationMapContentName = value; }
  54. }
  55. /// <summary>
  56. /// The name of the portal that the party spawns at on the destination map.
  57. /// </summary>
  58. private string destinationMapPortalName;
  59. /// <summary>
  60. /// The name of the portal that the party spawns at on the destination map.
  61. /// </summary>
  62. public string DestinationMapPortalName
  63. {
  64. get { return destinationMapPortalName; }
  65. set { destinationMapPortalName = value; }
  66. }
  67. /// <summary>
  68. /// Reads a Portal object from the content pipeline.
  69. /// </summary>
  70. public class PortalReader : ContentTypeReader<Portal>
  71. {
  72. protected override Portal Read(ContentReader input,
  73. Portal existingInstance)
  74. {
  75. Portal portal = existingInstance;
  76. if (portal == null)
  77. {
  78. portal = new Portal();
  79. }
  80. portal.AssetName = input.AssetName;
  81. portal.Name = input.ReadString();
  82. portal.LandingMapPosition = input.ReadObject<Point>();
  83. portal.DestinationMapContentName = input.ReadString();
  84. portal.DestinationMapPortalName = input.ReadString();
  85. return portal;
  86. }
  87. }
  88. }
  89. }