Inn.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Inn.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.Content;
  12. using Microsoft.Xna.Framework.Graphics;
  13. #endregion
  14. namespace RolePlayingGameData
  15. {
  16. /// <summary>
  17. /// An inn in the game world, where the party can rest and restore themselves.
  18. /// </summary>
  19. public class Inn : WorldObject
  20. {
  21. #region Operation
  22. /// <summary>
  23. /// The amount that the party has to pay for each member to stay.
  24. /// </summary>
  25. private int chargePerPlayer;
  26. /// <summary>
  27. /// The amount that the party has to pay for each member to stay.
  28. /// </summary>
  29. public int ChargePerPlayer
  30. {
  31. get { return chargePerPlayer; }
  32. set { chargePerPlayer = value; }
  33. }
  34. #endregion
  35. #region Menu Message Data
  36. /// <summary>
  37. /// The message shown when the player enters the inn.
  38. /// </summary>
  39. private string welcomeMessage;
  40. /// <summary>
  41. /// The message shown when the player enters the inn.
  42. /// </summary>
  43. public string WelcomeMessage
  44. {
  45. get { return welcomeMessage; }
  46. set { welcomeMessage = value; }
  47. }
  48. /// <summary>
  49. /// The message shown when the party successfully pays to stay the night.
  50. /// </summary>
  51. private string paidMessage;
  52. /// <summary>
  53. /// The message shown when the party successfully pays to stay the night.
  54. /// </summary>
  55. public string PaidMessage
  56. {
  57. get { return paidMessage; }
  58. set { paidMessage = value; }
  59. }
  60. /// <summary>
  61. /// The message shown when the party tries to stay but lacks the funds.
  62. /// </summary>
  63. private string notEnoughGoldMessage;
  64. /// <summary>
  65. /// The message shown when the party tries to stay but lacks the funds.
  66. /// </summary>
  67. public string NotEnoughGoldMessage
  68. {
  69. get { return notEnoughGoldMessage; }
  70. set { notEnoughGoldMessage = value; }
  71. }
  72. #endregion
  73. #region Graphics Data
  74. /// <summary>
  75. /// The content name of the texture for the shopkeeper.
  76. /// </summary>
  77. private string shopkeeperTextureName;
  78. /// <summary>
  79. /// The content name of the texture for the shopkeeper.
  80. /// </summary>
  81. public string ShopkeeperTextureName
  82. {
  83. get { return shopkeeperTextureName; }
  84. set { shopkeeperTextureName = value; }
  85. }
  86. /// <summary>
  87. /// The texture for the shopkeeper.
  88. /// </summary>
  89. private Texture2D shopkeeperTexture;
  90. /// <summary>
  91. /// The texture for the shopkeeper.
  92. /// </summary>
  93. [ContentSerializerIgnore]
  94. public Texture2D ShopkeeperTexture
  95. {
  96. get { return shopkeeperTexture; }
  97. }
  98. #endregion
  99. #region Content Type Reader
  100. /// <summary>
  101. /// Reads an Inn object from the content pipeline.
  102. /// </summary>
  103. public class InnReader : ContentTypeReader<Inn>
  104. {
  105. protected override Inn Read(ContentReader input, Inn existingInstance)
  106. {
  107. Inn inn = existingInstance;
  108. if (inn == null)
  109. {
  110. inn = new Inn();
  111. }
  112. input.ReadRawObject<WorldObject>(inn as WorldObject);
  113. inn.ChargePerPlayer = input.ReadInt32();
  114. inn.WelcomeMessage = input.ReadString();
  115. inn.PaidMessage = input.ReadString();
  116. inn.NotEnoughGoldMessage = input.ReadString();
  117. inn.ShopkeeperTextureName = input.ReadString();
  118. inn.shopkeeperTexture = input.ContentManager.Load<Texture2D>(
  119. System.IO.Path.Combine(@"Textures\Characters\Portraits",
  120. inn.ShopkeeperTextureName));
  121. return inn;
  122. }
  123. }
  124. #endregion
  125. }
  126. }