VsDanceDataMgr.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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.ContainsKey(key)) ? null : this.m_DanceEnemyData[key];
  96. }
  97. return (!this.m_SubstituteEnemyData.ContainsKey(key)) ? null : 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 enum ForcedVictory
  175. {
  176. Nothing,
  177. ForceWin,
  178. ForceLose
  179. }
  180. public class DanceBattleSetting
  181. {
  182. public DanceBattleSetting(CsvParser csv, int cy)
  183. {
  184. int num = 0;
  185. this.ID = csv.GetCellAsInteger(num++, cy);
  186. num++;
  187. this.Enemy1stID = csv.GetCellAsInteger(num++, cy);
  188. this.Enemy2ndID = csv.GetCellAsInteger(num++, cy);
  189. string cellAsString = csv.GetCellAsString(num++, cy);
  190. int num2 = (!(cellAsString != "Free")) ? -1 : int.Parse(cellAsString);
  191. if (num2 != -1)
  192. {
  193. this.specifyDanceData = DanceSelect.GetDanceData(num2);
  194. }
  195. else
  196. {
  197. this.specifyDanceData = null;
  198. }
  199. this.ClearReleaseList = new List<int>();
  200. string cellAsString2 = csv.GetCellAsString(num++, cy);
  201. if (!string.IsNullOrEmpty(cellAsString2))
  202. {
  203. foreach (string s in cellAsString2.Split(new char[]
  204. {
  205. ','
  206. }))
  207. {
  208. this.ClearReleaseList.Add(int.Parse(s));
  209. }
  210. }
  211. this.BattlePersonalList = new List<string>();
  212. string cellAsString3 = csv.GetCellAsString(num++, cy);
  213. if (!string.IsNullOrEmpty(cellAsString3))
  214. {
  215. foreach (string item in cellAsString3.Split(new char[]
  216. {
  217. ','
  218. }))
  219. {
  220. this.BattlePersonalList.Add(item);
  221. }
  222. }
  223. else
  224. {
  225. this.BattlePersonalList = new List<string>
  226. {
  227. "Muku",
  228. "Majime",
  229. "Rindere"
  230. };
  231. }
  232. string cellAsString4 = csv.GetCellAsString(num++, cy);
  233. if (!string.IsNullOrEmpty(cellAsString4))
  234. {
  235. this.specifyVictoryState = (VsDanceDataMgr.ForcedVictory)Enum.Parse(typeof(VsDanceDataMgr.ForcedVictory), cellAsString4);
  236. }
  237. else
  238. {
  239. this.specifyVictoryState = VsDanceDataMgr.ForcedVictory.Nothing;
  240. }
  241. string cellAsString5 = csv.GetCellAsString(num++, cy);
  242. if (!string.IsNullOrEmpty(cellAsString5))
  243. {
  244. this.fixedMaidOrder = cellAsString5.Split(new char[]
  245. {
  246. ','
  247. });
  248. }
  249. else
  250. {
  251. this.fixedMaidOrder = new string[0];
  252. }
  253. }
  254. public bool isSpecifiedVictoryState
  255. {
  256. get
  257. {
  258. return this.specifyVictoryState != VsDanceDataMgr.ForcedVictory.Nothing;
  259. }
  260. }
  261. public bool isFixedMaidOrder
  262. {
  263. get
  264. {
  265. return this.fixedMaidOrder != null && this.fixedMaidOrder.Length > 0;
  266. }
  267. }
  268. public bool IsCanBattleParticipate(Maid maid)
  269. {
  270. if (!maid.status.mainChara)
  271. {
  272. return false;
  273. }
  274. string uniqueName = maid.status.personal.uniqueName;
  275. return this.BattlePersonalList.Contains(uniqueName);
  276. }
  277. public readonly int ID;
  278. public readonly int Enemy1stID;
  279. public readonly int Enemy2ndID;
  280. public readonly DanceData specifyDanceData;
  281. public readonly List<int> ClearReleaseList;
  282. public readonly List<string> BattlePersonalList;
  283. public readonly VsDanceDataMgr.ForcedVictory specifyVictoryState;
  284. public readonly string[] fixedMaidOrder;
  285. }
  286. }