VsDanceDataMgr.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using wf;
  6. public class VsDanceDataMgr
  7. {
  8. public static VsDanceDataMgr Instance { get; private set; }
  9. public VsDanceDataMgr.DanceBattleSetting CurrentSetting
  10. {
  11. get
  12. {
  13. return this.m_NowSetting;
  14. }
  15. }
  16. private void Init()
  17. {
  18. CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "dancebattle_setting_enabled_list", ref this.m_SettingEnableList);
  19. KasaiUtility.CsvReadY("dancebattle_setting.nei", new Action<CsvParser, int>(this.ReadSettingData), 1, null);
  20. CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "dance_enemy_enabled_list", ref this.m_EnemyEnableList);
  21. KasaiUtility.CsvReadY("dance_enemy.nei", new Action<CsvParser, int>(this.ReadEnemyData), 1, null);
  22. KasaiUtility.CsvReadY("substitute_dance_enemy.nei", new Action<CsvParser, int>(this.ReadSubstituteEnemyData), 1, null);
  23. foreach (DanceData danceData in DanceSelect.GetDanceDataList())
  24. {
  25. this.m_DanceDataList.Add(danceData.ID, danceData);
  26. }
  27. }
  28. private void ReadSettingData(CsvParser csv, int cy)
  29. {
  30. int cellAsInteger = csv.GetCellAsInteger(0, cy);
  31. if (!this.m_SettingEnableList.Contains(cellAsInteger))
  32. {
  33. return;
  34. }
  35. this.m_BattleSettingData.Add(cellAsInteger, new VsDanceDataMgr.DanceBattleSetting(csv, cy));
  36. }
  37. private void ReadEnemyData(CsvParser csv, int cy)
  38. {
  39. int cellAsInteger = csv.GetCellAsInteger(0, cy);
  40. if (!this.m_EnemyEnableList.Contains(cellAsInteger))
  41. {
  42. return;
  43. }
  44. this.m_DanceEnemyData.Add(cellAsInteger, this.CreateEnemyData(csv, cy));
  45. }
  46. private void ReadSubstituteEnemyData(CsvParser csv, int cy)
  47. {
  48. int cellAsInteger = csv.GetCellAsInteger(0, cy);
  49. if (!this.m_EnemyEnableList.Contains(cellAsInteger))
  50. {
  51. return;
  52. }
  53. this.m_SubstituteEnemyData.Add(cellAsInteger, this.CreateEnemyData(csv, cy));
  54. }
  55. private DanceEnemyParam CreateEnemyData(CsvParser csv, int cy)
  56. {
  57. int num = 0;
  58. DanceEnemyParam danceEnemyParam = new DanceEnemyParam();
  59. danceEnemyParam.ID = csv.GetCellAsInteger(num++, cy);
  60. danceEnemyParam.Name = csv.GetCellAsString(num++, cy);
  61. num++;
  62. danceEnemyParam.UseVoltage = csv.GetCellAsInteger(num++, cy);
  63. danceEnemyParam.EvalueRate.Add(Dance_Note.Evaluation.PERFECT, csv.GetCellAsInteger(num++, cy));
  64. danceEnemyParam.EvalueRate.Add(Dance_Note.Evaluation.GREAT, csv.GetCellAsInteger(num++, cy));
  65. danceEnemyParam.EvalueRate.Add(Dance_Note.Evaluation.GOOD, csv.GetCellAsInteger(num++, cy));
  66. danceEnemyParam.EvalueRate.Add(Dance_Note.Evaluation.BAD, csv.GetCellAsInteger(num++, cy));
  67. danceEnemyParam.EvalueRate.Add(Dance_Note.Evaluation.MISS, csv.GetCellAsInteger(num++, cy));
  68. danceEnemyParam.PushRate = csv.GetCellAsInteger(num++, cy);
  69. danceEnemyParam.InitialAppeal = csv.GetCellAsInteger(num++, cy);
  70. danceEnemyParam.ApeealRate = csv.GetCellAsInteger(num++, cy);
  71. danceEnemyParam.ApeealMax = csv.GetCellAsInteger(num++, cy);
  72. danceEnemyParam.AppealCutInEffect = Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/AppealCutIn/" + csv.GetCellAsString(num++, cy));
  73. danceEnemyParam.ReversalCutInEffect = Resources.Load<GameObject>("SceneDance/Rhythm_Action/Prefab/ReversalCutIn/" + csv.GetCellAsString(num++, cy));
  74. danceEnemyParam.PersonalVoice1 = csv.GetCellAsString(num++, cy);
  75. danceEnemyParam.PersonalVoice2 = csv.GetCellAsString(num++, cy);
  76. danceEnemyParam.JobVoice = csv.GetCellAsString(num++, cy);
  77. danceEnemyParam.ReversalVoice = csv.GetCellAsString(num++, cy);
  78. danceEnemyParam.ConfrontCutin = Resources.Load<Sprite>("SceneDance/Rhythm_Action/Sprite/CutInTex/" + csv.GetCellAsString(num++, cy));
  79. danceEnemyParam.PersonalCutin1 = Resources.Load<Sprite>("SceneDance/Rhythm_Action/Sprite/CutInTex/" + csv.GetCellAsString(num++, cy));
  80. danceEnemyParam.PersonalCutin2 = Resources.Load<Sprite>("SceneDance/Rhythm_Action/Sprite/CutInTex/" + csv.GetCellAsString(num++, cy));
  81. danceEnemyParam.JobCutin = Resources.Load<Sprite>("SceneDance/Rhythm_Action/Sprite/CutInTex/" + csv.GetCellAsString(num++, cy));
  82. danceEnemyParam.ReversalCutin = Resources.Load<Sprite>("SceneDance/Rhythm_Action/Sprite/CutInTex/" + csv.GetCellAsString(num++, cy));
  83. danceEnemyParam.Icon = Resources.Load<Sprite>("SceneDance/Rhythm_Action/Sprite/EnemyIcon/" + csv.GetCellAsString(num++, cy));
  84. return danceEnemyParam;
  85. }
  86. public void SelectSetting(int id)
  87. {
  88. this.m_NowSetting = this.m_BattleSettingData[id];
  89. }
  90. public DanceEnemyParam GetCurrentEnemy(bool is_2nd)
  91. {
  92. int key = (!is_2nd) ? this.CurrentSetting.Enemy1stID : this.CurrentSetting.Enemy2ndID;
  93. if (!GameMain.Instance.CharacterMgr.status.lockUserDraftMaid)
  94. {
  95. return this.m_DanceEnemyData[key];
  96. }
  97. return this.m_SubstituteEnemyData[key];
  98. }
  99. public void MusicRelese(int setting_id)
  100. {
  101. foreach (int key in this.m_BattleSettingData[setting_id].ClearReleaseList)
  102. {
  103. this.m_DanceDataList[key].IsPlayable = true;
  104. RhythmAction_Mgr.MusicReleaseFlag = this.m_DanceDataList[key].scenario_progress;
  105. }
  106. }
  107. public void Serialize(BinaryWriter bw)
  108. {
  109. bw.Write("COM3D2_DANCEDATA");
  110. bw.Write(1f);
  111. bw.Write("COM3D2_DANCE_ID_START");
  112. foreach (int num in this.m_DanceDataList.Keys)
  113. {
  114. bw.Write(num.ToString());
  115. }
  116. bw.Write("COM3D2_DANCE_ID_END");
  117. foreach (DanceData danceData in this.m_DanceDataList.Values)
  118. {
  119. bw.Write(danceData.IsPlayable);
  120. }
  121. }
  122. public void Deserialize(BinaryReader br, int misc_ver)
  123. {
  124. foreach (DanceData danceData in this.m_DanceDataList.Values)
  125. {
  126. danceData.Recet();
  127. }
  128. if (misc_ver <= 1060)
  129. {
  130. foreach (DanceData danceData2 in this.m_DanceDataList.Values)
  131. {
  132. danceData2.IsPlayable = (danceData2.scenario_progress <= RhythmAction_Mgr.MusicReleaseFlag);
  133. }
  134. return;
  135. }
  136. string a = br.ReadString();
  137. NDebug.Assert(a == "COM3D2_DANCEDATA", "VsDanceDataMgr.ヘッダーが違います");
  138. int num = br.ReadInt32();
  139. List<int> list = new List<int>();
  140. string text = br.ReadString();
  141. string text2 = br.ReadString();
  142. while (text2 != "COM3D2_DANCE_ID_END")
  143. {
  144. list.Add(int.Parse(text2));
  145. text2 = br.ReadString();
  146. }
  147. foreach (int key in list)
  148. {
  149. if (this.m_DanceDataList.ContainsKey(key))
  150. {
  151. this.m_DanceDataList[key].IsPlayable = br.ReadBoolean();
  152. }
  153. else
  154. {
  155. br.ReadBoolean();
  156. }
  157. }
  158. }
  159. public static void CreateInstance()
  160. {
  161. VsDanceDataMgr.Instance = new VsDanceDataMgr();
  162. VsDanceDataMgr.Instance.Init();
  163. }
  164. private const int m_CheckMiscVer = 1060;
  165. private const string m_SaveHeader = "COM3D2_DANCEDATA";
  166. private const float m_SaveVer = 1f;
  167. private HashSet<int> m_SettingEnableList = new HashSet<int>();
  168. private Dictionary<int, VsDanceDataMgr.DanceBattleSetting> m_BattleSettingData = new Dictionary<int, VsDanceDataMgr.DanceBattleSetting>();
  169. private VsDanceDataMgr.DanceBattleSetting m_NowSetting;
  170. private HashSet<int> m_EnemyEnableList = new HashSet<int>();
  171. private Dictionary<int, DanceEnemyParam> m_DanceEnemyData = new Dictionary<int, DanceEnemyParam>();
  172. private Dictionary<int, DanceEnemyParam> m_SubstituteEnemyData = new Dictionary<int, DanceEnemyParam>();
  173. private Dictionary<int, DanceData> m_DanceDataList = new Dictionary<int, DanceData>();
  174. public class DanceBattleSetting
  175. {
  176. public DanceBattleSetting(CsvParser csv, int cy)
  177. {
  178. int num = 0;
  179. this.ID = csv.GetCellAsInteger(num++, cy);
  180. num++;
  181. this.Enemy1stID = csv.GetCellAsInteger(num++, cy);
  182. this.Enemy2ndID = csv.GetCellAsInteger(num++, cy);
  183. string cellAsString = csv.GetCellAsString(num++, cy);
  184. this.Music2ndID = ((!(cellAsString != "Free")) ? -1 : int.Parse(cellAsString));
  185. this.ClearReleaseList = new List<int>();
  186. string cellAsString2 = csv.GetCellAsString(num++, cy);
  187. if (!string.IsNullOrEmpty(cellAsString2))
  188. {
  189. foreach (string s in cellAsString2.Split(new char[]
  190. {
  191. ','
  192. }))
  193. {
  194. this.ClearReleaseList.Add(int.Parse(s));
  195. }
  196. }
  197. this.BattlePersonalList = new List<string>();
  198. string cellAsString3 = csv.GetCellAsString(num++, cy);
  199. if (!string.IsNullOrEmpty(cellAsString3))
  200. {
  201. foreach (string item in cellAsString3.Split(new char[]
  202. {
  203. ','
  204. }))
  205. {
  206. this.BattlePersonalList.Add(item);
  207. }
  208. }
  209. else
  210. {
  211. this.BattlePersonalList = new List<string>
  212. {
  213. "Muku",
  214. "Majime",
  215. "Rindere"
  216. };
  217. }
  218. }
  219. public bool IsCanBattleParticipate(Maid maid)
  220. {
  221. if (!maid.status.mainChara)
  222. {
  223. return false;
  224. }
  225. string uniqueName = maid.status.personal.uniqueName;
  226. return this.BattlePersonalList.Contains(uniqueName);
  227. }
  228. public readonly int ID;
  229. public readonly int Enemy1stID;
  230. public readonly int Enemy2ndID;
  231. public readonly int Music2ndID;
  232. public readonly List<int> ClearReleaseList;
  233. public readonly List<string> BattlePersonalList;
  234. }
  235. }