Store.cs 4.1 KB

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