SceneData.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // SceneData.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 System.Text;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. #endregion
  16. namespace SceneDataLibrary
  17. {
  18. /// <summary>
  19. /// This class manages scene data (pattern and sequence).
  20. /// In Layout, stage data corresponds to this scene data.
  21. ///
  22. /// シーンデータ(パターン、シーケンス)を保持します。
  23. /// Layoutではステージデータに相当します。
  24. /// </summary>
  25. public class SceneData
  26. {
  27. #region Fields
  28. //List of pattern groups
  29. //
  30. //パターングループのリスト
  31. private Dictionary<String, PatternGroupData> patternGroupDictionary =
  32. new Dictionary<string,PatternGroupData>();
  33. //List of sequence banks
  34. //
  35. //シーケンスバンクのリスト
  36. private Dictionary<String, SequenceBankData> sequenceBankDictionary =
  37. new Dictionary<string,SequenceBankData>();
  38. //List of sequence play data
  39. //
  40. //シーケンス再生データのリスト
  41. private List<SequencePlayData> sequencePlayList = new List<SequencePlayData>();
  42. #endregion
  43. #region Propaties
  44. /// <summary>
  45. /// Obtains the dictionary list for pattern groups.
  46. ///
  47. /// パターングループデータの辞書リストを設定取得します。
  48. /// </summary>
  49. public Dictionary<String, PatternGroupData> PatternGroupDictionary
  50. {
  51. get { return patternGroupDictionary; }
  52. }
  53. /// <summary>
  54. /// Obtains the dictionary list for sequence bank data.
  55. ///
  56. /// シーケンスバンクデータの辞書リストを設定取得します。
  57. /// </summary>
  58. public Dictionary<String, SequenceBankData> SequenceBankDictionary
  59. {
  60. get { return sequenceBankDictionary; }
  61. }
  62. #endregion
  63. /// <summary>
  64. /// Creates data to play the sequence.
  65. /// When specifying the target sequence, uses the sequence bank name.
  66. ///
  67. /// シーケンスを再生するためのデータを作成します。
  68. /// 対象は、シーケンスバンク名で名前で指定します。
  69. /// </summary>
  70. /// <param name="name">
  71. /// Sequence name
  72. ///
  73. /// シーケンスの名前
  74. /// </param>
  75. /// <returns></returns>
  76. public SequencePlayData CreatePlaySeqData(String name)
  77. {
  78. return new SequencePlayData(sequenceBankDictionary[name]);
  79. }
  80. /// <summary>
  81. /// Adds sequences to be played.
  82. /// When adding them to the list, the display priority specified in
  83. /// the layout tool must be considered.
  84. ///
  85. /// 再生するシーケンスを追加します。
  86. /// レイアウトツールで指定された表示優先順位を考慮して
  87. /// リストに追加します。
  88. /// </summary>
  89. /// <param name="data">
  90. /// Sequence data to be played
  91. ///
  92. /// 再生するシーケンスのデータ
  93. /// </param>
  94. public void AddPlaySeqData(SequencePlayData data)
  95. {
  96. int nInsertIndex = 0;
  97. for(int i = sequencePlayList.Count - 1; i >= 0; i--)
  98. {
  99. int nZPos = sequencePlayList[i].SequenceData.ZPos;
  100. if (nZPos <= data.SequenceData.ZPos)
  101. {
  102. nInsertIndex = i + 1;
  103. break;
  104. }
  105. }
  106. sequencePlayList.Insert(nInsertIndex, data);
  107. }
  108. /// <summary>
  109. /// Adds the sequences specified by their names to the play list.
  110. /// Creation of sequence play data and addition of it to the list
  111. /// can be performed at the same time.
  112. ///
  113. /// 名前で指定したシーケンスを再生リストに追加します。
  114. /// シーケンス再生データの作成と、リストへの追加を同時に行えます。
  115. /// </summary>
  116. /// <param name="name">
  117. /// Sequence name to be added
  118. ///
  119. /// 追加するシーケンス名
  120. /// </param>
  121. public void AddPlaySeqData(String name)
  122. {
  123. AddPlaySeqData(CreatePlaySeqData(name));
  124. }
  125. /// <summary>
  126. /// Sets the sequence time in the play list forward.
  127. /// Updates the scene data.
  128. ///
  129. /// 再生リストにあるシーケンスの時間を進めます。
  130. /// シーンデータの更新関数です。
  131. /// </summary>
  132. /// <param name="elapsedGameTime">
  133. /// Time to be forwarded
  134. ///
  135. /// 進める時間
  136. /// </param>
  137. public void Update(TimeSpan elapsedGameTime)
  138. {
  139. foreach (SequencePlayData data in sequencePlayList)
  140. data.Update(elapsedGameTime);
  141. }
  142. /// <summary>
  143. /// Draws the sequence in the play list.
  144. ///
  145. /// 再生リストにあるシーケンスを描画します。
  146. /// </summary>
  147. /// <param name="sb">
  148. /// SpriteBatch
  149. ///
  150. /// スプラインバッチ
  151. /// </param>
  152. /// <param name="baseDrawData">
  153. /// Conversion information that affects the entire drawing target
  154. ///
  155. /// 描画対象すべてに影響する変換情報
  156. /// </param>
  157. public void Draw(SpriteBatch sb, DrawData baseDrawData)
  158. {
  159. foreach (SequencePlayData data in sequencePlayList)
  160. data.Draw(sb, baseDrawData);
  161. }
  162. /// <summary>
  163. /// Displays the pattern group specified by its name.
  164. ///
  165. /// 名前で指定したパターングループを表示します。
  166. /// </summary>
  167. /// <param name="sb">
  168. /// SpriteBatch
  169. ///
  170. /// スプラインバッチ
  171. /// </param>
  172. /// <param name="name">
  173. /// Pattern group name
  174. ///
  175. /// パターングループの名前
  176. /// </param>
  177. /// <param name="baseDrawData">
  178. /// Conversion information that affects the entire drawing target
  179. ///
  180. /// 描画対象すべてに影響する変換情報
  181. /// </param>
  182. public void DrawPattern(SpriteBatch sb, String name, DrawData baseDrawData)
  183. {
  184. PatternGroupData group = PatternGroupDictionary[name];
  185. foreach (PatternObjectData pattern in group.PatternObjectList)
  186. pattern.Draw(sb, pattern.Data, baseDrawData);
  187. }
  188. /// <summary>
  189. /// Specifies a pattern group by its name and specifies a pattern object
  190. /// in this pattern group by its index to obtain the position information.
  191. ///
  192. /// パターングループを名前で指定し、
  193. /// その内部にあるパターンオブジェクトをインデックスで指定。
  194. /// 位置情報を取得します。
  195. /// </summary>
  196. /// <param name="name">
  197. /// Pattern group name
  198. ///
  199. /// パターングループの名前
  200. /// </param>
  201. /// <param name="nObjectId">
  202. /// Pattern object ID
  203. ///
  204. /// パターンオブジェクトのID
  205. /// </param>
  206. /// <returns></returns>
  207. public Point GetPatternPosition(String name, int nObjectId)
  208. {
  209. return PatternGroupDictionary[name].PatternObjectList[nObjectId].
  210. Data.Position;
  211. }
  212. }
  213. }