Store.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Store.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 System.Collections.Generic;
  12. using Microsoft.Xna.Framework.Content;
  13. using Microsoft.Xna.Framework.Graphics;
  14. #endregion
  15. namespace RolePlayingGameData
  16. {
  17. /// <summary>
  18. /// A gear store, where the party can buy and sell gear, organized into categories.
  19. /// </summary>
  20. public class Store : WorldObject
  21. {
  22. #region Shopping Data
  23. /// <summary>
  24. /// A purchasing multiplier applied to the price of all gear.
  25. /// </summary>
  26. private float buyMultiplier;
  27. /// <summary>
  28. /// A purchasing multiplier applied to the price of all gear.
  29. /// </summary>
  30. public float BuyMultiplier
  31. {
  32. get { return buyMultiplier; }
  33. set { buyMultiplier = value; }
  34. }
  35. /// <summary>
  36. /// A sell-back multiplier applied to the price of all gear.
  37. /// </summary>
  38. private float sellMultiplier;
  39. /// <summary>
  40. /// A sell-back multiplier applied to the price of all gear.
  41. /// </summary>
  42. public float SellMultiplier
  43. {
  44. get { return sellMultiplier; }
  45. set { sellMultiplier = value; }
  46. }
  47. /// <summary>
  48. /// The categories of gear in this store.
  49. /// </summary>
  50. private List<StoreCategory> storeCategories = new List<StoreCategory>();
  51. /// <summary>
  52. /// The categories of gear in this store.
  53. /// </summary>
  54. public List<StoreCategory> StoreCategories
  55. {
  56. get { return storeCategories; }
  57. set { storeCategories = value; }
  58. }
  59. #endregion
  60. #region Menu Messages
  61. /// <summary>
  62. /// The message shown when the party enters the store.
  63. /// </summary>
  64. private string welcomeMessage;
  65. /// <summary>
  66. /// The message shown when the party enters the store.
  67. /// </summary>
  68. public string WelcomeMessage
  69. {
  70. get { return welcomeMessage; }
  71. set { welcomeMessage = value; }
  72. }
  73. #endregion
  74. #region Graphics Data
  75. /// <summary>
  76. /// The content path and name of the texture for the shopkeeper.
  77. /// </summary>
  78. private string shopkeeperTextureName;
  79. /// <summary>
  80. /// The content path and name of the texture for the shopkeeper.
  81. /// </summary>
  82. public string ShopkeeperTextureName
  83. {
  84. get { return shopkeeperTextureName; }
  85. set { shopkeeperTextureName = value; }
  86. }
  87. /// <summary>
  88. /// The texture for the shopkeeper.
  89. /// </summary>
  90. private Texture2D shopkeeperTexture;
  91. /// <summary>
  92. /// The texture for the shopkeeper.
  93. /// </summary>
  94. [ContentSerializerIgnore]
  95. public Texture2D ShopkeeperTexture
  96. {
  97. get { return shopkeeperTexture; }
  98. }
  99. #endregion
  100. #region Content Type Reader
  101. /// <summary>
  102. /// Reads an Store object from the content pipeline.
  103. /// </summary>
  104. public class StoreReader : ContentTypeReader<Store>
  105. {
  106. protected override Store Read(ContentReader input, Store existingInstance)
  107. {
  108. Store store = existingInstance;
  109. if (store == null)
  110. {
  111. store = new Store();
  112. }
  113. input.ReadRawObject<WorldObject>(store as WorldObject);
  114. store.BuyMultiplier = input.ReadSingle();
  115. store.SellMultiplier = input.ReadSingle();
  116. store.StoreCategories.AddRange(input.ReadObject<List<StoreCategory>>());
  117. store.WelcomeMessage = input.ReadString();
  118. store.ShopkeeperTextureName = input.ReadString();
  119. store.shopkeeperTexture = input.ContentManager.Load<Texture2D>(
  120. System.IO.Path.Combine(@"Textures\Characters\Portraits",
  121. store.ShopkeeperTextureName));
  122. return store;
  123. }
  124. }
  125. #endregion
  126. }
  127. }