Inn.cs 4.0 KB

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