SceneFreeModeSelectManager.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. public class SceneFreeModeSelectManager : WfScreenManager
  6. {
  7. public void Awake()
  8. {
  9. this.adv_kag_ = GameMain.Instance.ScriptMgr.adv_kag;
  10. this.adv_kag_.kag.AddTagCallBack("freecall", new KagScript.KagTagCallBack(this.TagFreeCall));
  11. this.adv_kag_.kag.AddTagCallBack("freerestorebackupdata", new KagScript.KagTagCallBack(this.TagFreeRestoreBackupData));
  12. }
  13. public override void Start()
  14. {
  15. SceneFreeModeSelectManager.IsFreeMode = true;
  16. base.Start();
  17. GameMain.Instance.MainLight.Reset();
  18. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  19. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  20. GameMain.Instance.SoundMgr.VoiceStopAll();
  21. this.move_screen_ = base.children_dic["Move"].GetComponent<WfScreenMoveChildren>();
  22. string empty = string.Empty;
  23. string empty2 = string.Empty;
  24. if (this.adv_kag_.tag_backup != null && 0 < this.adv_kag_.tag_backup.Count && this.adv_kag_.tag_backup["name"] == "SceneFreeModeSelect")
  25. {
  26. NDebug.Assert(this.adv_kag_.tag_backup.ContainsKey("scene_label_everyday"), "SceneFreeModeSelectManagerにscene_label_everydayの設定がされていませんでした");
  27. NDebug.Assert(this.adv_kag_.tag_backup.ContainsKey("scene_label_vip"), "SceneFreeModeSelectManagerにscene_label_everydayの設定がされていませんでした");
  28. NDebug.Assert(this.adv_kag_.tag_backup.ContainsKey("yotogi_label"), "SceneFreeModeSelectManagerにyotogi_labelの設定がされていませんでした");
  29. NDebug.Assert(this.adv_kag_.tag_backup.ContainsKey("cancel_label"), "SceneFreeModeSelectManagerにcancel_labelの設定がされていませんでした");
  30. NDebug.Assert(this.adv_kag_.tag_backup.ContainsKey("scene_label_life_mode"), "SceneFreeModeSelectManagerにscene_label_life_modeの設定がされていませんでした");
  31. NDebug.Assert(this.adv_kag_.tag_backup.ContainsKey("life_mode_chara_select"), "SceneFreeModeSelectManagerにlife_mode_chara_selectの設定がされていませんでした");
  32. this.scene_label_mainstory_ = this.adv_kag_.tag_backup["scene_label_mainstory"];
  33. this.scene_label_everyday_ = this.adv_kag_.tag_backup["scene_label_everyday"];
  34. this.scene_label_vip_ = this.adv_kag_.tag_backup["scene_label_vip"];
  35. this.yotogi_label_ = this.adv_kag_.tag_backup["yotogi_label"];
  36. this.cancel_label_ = this.adv_kag_.tag_backup["cancel_label"];
  37. this.scene_label_life_mode_ = this.adv_kag_.tag_backup["scene_label_life_mode"];
  38. this.life_mode_chara_select_label_ = this.adv_kag_.tag_backup["life_mode_chara_select"];
  39. this.is_life_mode_init = this.adv_kag_.tag_backup.ContainsKey("start_life_mode");
  40. }
  41. this.init_mgr_ = base.children_dic["Init"].GetComponent<FreeModeInit>();
  42. this.init_mgr_.next_screen = "Select";
  43. if (this.is_life_mode_init)
  44. {
  45. this.init_mgr_.next_screen = "LifeMode";
  46. }
  47. this.StoreBackupData();
  48. this.CallScreen("Init");
  49. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  50. GameObject gameObject = base.gameObject.transform.parent.gameObject;
  51. UIGrid component = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton", false).GetComponent<UIGrid>();
  52. GameObject childObject = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton/ストーリー", false);
  53. GameObject childObject2 = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton/日常", false);
  54. GameObject childObject3 = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton/夜伽", false);
  55. GameObject childObject4 = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton/VIP", false);
  56. GameObject childObject5 = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton/VIP_HEvent", false);
  57. GameObject childObject6 = UTY.GetChildObject(gameObject, "MenuSelect/Menu/FreeModeMenuButton/ライフモード", false);
  58. if (DailyMgr.IsLegacy)
  59. {
  60. if (childObject != null)
  61. {
  62. childObject.SetActive(false);
  63. }
  64. childObject5.gameObject.SetActive(false);
  65. childObject4.gameObject.SetActive(true);
  66. if (childObject6 != null)
  67. {
  68. childObject6.SetActive(false);
  69. }
  70. }
  71. else
  72. {
  73. if (maid.status.subCharaData != null)
  74. {
  75. if (childObject != null)
  76. {
  77. childObject.SetActive(false);
  78. }
  79. if (childObject3 != null)
  80. {
  81. childObject3.SetActive(false);
  82. }
  83. }
  84. else if (maid.status.mainChara)
  85. {
  86. List<FreeModeItemEveryday> list = FreeModeItemEveryday.CreateItemEverydayList(FreeModeItemEveryday.ScnearioType.Story, null);
  87. if (list.Count <= 0)
  88. {
  89. UIButton component2 = childObject.GetComponent<UIButton>();
  90. component2.isEnabled = false;
  91. }
  92. }
  93. else if (childObject != null)
  94. {
  95. childObject.SetActive(false);
  96. }
  97. if (childObject6 != null)
  98. {
  99. childObject6.SetActive(FreeModeItemLifeMode.CreateItemList(true).Count > 0);
  100. }
  101. childObject5.gameObject.SetActive(true);
  102. childObject4.gameObject.SetActive(false);
  103. }
  104. if (childObject3.gameObject.activeSelf)
  105. {
  106. UIButton component3 = childObject3.GetComponent<UIButton>();
  107. if (maid.status.playCountYotogi == 0)
  108. {
  109. component3.isEnabled = false;
  110. }
  111. }
  112. if (childObject2.gameObject.activeSelf)
  113. {
  114. List<FreeModeItemEveryday> list2 = FreeModeItemEveryday.CreateItemEverydayList(FreeModeItemEveryday.ScnearioType.Nitijyou, maid.status);
  115. if (list2.Count <= 0)
  116. {
  117. childObject2.gameObject.SetActive(false);
  118. }
  119. }
  120. component.Reposition();
  121. }
  122. public void OnPreFinalize()
  123. {
  124. SceneFreeModeSelectManager.IsFreeMode = false;
  125. this.adv_kag_ = null;
  126. }
  127. public void OnDestroy()
  128. {
  129. SceneFreeModeSelectManager.IsFreeMode = false;
  130. if (this.adv_kag_ != null)
  131. {
  132. if (this.adv_kag_.kag != null)
  133. {
  134. this.adv_kag_.kag.RemoveTagCallBack("freecall");
  135. this.adv_kag_.kag.RemoveTagCallBack("freerestorebackupdata");
  136. }
  137. this.adv_kag_ = null;
  138. }
  139. }
  140. public bool TagFreeCall(KagTagSupport tag_data)
  141. {
  142. this.adv_kag_.CheckAbsolutelyNecessaryTag(tag_data, "freecall", new string[]
  143. {
  144. "name"
  145. });
  146. this.init_mgr_.next_screen = tag_data.GetTagProperty("name").AsString();
  147. this.CallScreen("Init");
  148. return false;
  149. }
  150. public bool TagFreeRestoreBackupData(KagTagSupport tag_data)
  151. {
  152. this.RestoreBackupData();
  153. return false;
  154. }
  155. public void StoreBackupData()
  156. {
  157. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  158. if (maid != null)
  159. {
  160. this.backup_0_maid_guid = maid.status.guid;
  161. }
  162. this.backup_data_dic_.Clear();
  163. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  164. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  165. {
  166. Maid stockMaid = characterMgr.GetStockMaid(i);
  167. Status status = stockMaid.status;
  168. if (stockMaid != null)
  169. {
  170. SceneFreeModeSelectManager.BackupData value = default(SceneFreeModeSelectManager.BackupData);
  171. value.guid = status.guid;
  172. value.maid_flag = new Dictionary<string, int>();
  173. foreach (string key in status.flags.GetKeyArray())
  174. {
  175. value.maid_flag.Add(key, status.flags.Get(key));
  176. }
  177. value.seikeiken = status.seikeiken;
  178. value.init_seikeiken = status.initSeikeiken;
  179. value.relation = status.relation;
  180. value.feature_set = new HashSet<Feature.Data>();
  181. foreach (int key2 in status.features.GetKeyArray())
  182. {
  183. value.feature_set.Add(status.features.Get(key2));
  184. }
  185. value.propensity_set = new HashSet<Propensity.Data>();
  186. foreach (int key3 in status.propensitys.GetKeyArray())
  187. {
  188. value.propensity_set.Add(status.propensitys.Get(key3));
  189. }
  190. this.backup_data_dic_.Add(value.guid, value);
  191. }
  192. }
  193. }
  194. public void RestoreBackupData()
  195. {
  196. if (!string.IsNullOrEmpty(this.backup_0_maid_guid))
  197. {
  198. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(this.backup_0_maid_guid);
  199. if (stockMaid != null && stockMaid.ActiveSlotNo != 0)
  200. {
  201. GameMain.Instance.CharacterMgr.SetActiveMaid(stockMaid, 0);
  202. }
  203. }
  204. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  205. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  206. {
  207. Maid stockMaid2 = characterMgr.GetStockMaid(i);
  208. Status status = stockMaid2.status;
  209. if (stockMaid2 != null && this.backup_data_dic_.ContainsKey(status.guid))
  210. {
  211. SceneFreeModeSelectManager.BackupData backupData = this.backup_data_dic_[status.guid];
  212. string[] keyArray = status.flags.GetKeyArray();
  213. foreach (string flagName in keyArray)
  214. {
  215. status.RemoveFlag(flagName);
  216. }
  217. foreach (KeyValuePair<string, int> keyValuePair in backupData.maid_flag)
  218. {
  219. status.SetFlag(keyValuePair.Key, keyValuePair.Value);
  220. }
  221. status.seikeiken = backupData.seikeiken;
  222. status.initSeikeiken = backupData.init_seikeiken;
  223. status.relation = backupData.relation;
  224. int[] keyArray2 = status.features.GetKeyArray();
  225. foreach (int featureId in keyArray2)
  226. {
  227. status.RemoveFeature(featureId);
  228. }
  229. foreach (Feature.Data data in backupData.feature_set)
  230. {
  231. status.AddFeature(data);
  232. }
  233. keyArray2 = status.propensitys.GetKeyArray();
  234. foreach (int featureId2 in keyArray2)
  235. {
  236. status.RemovePropensity(featureId2);
  237. }
  238. foreach (Propensity.Data data2 in backupData.propensity_set)
  239. {
  240. status.AddPropensity(data2);
  241. }
  242. }
  243. }
  244. }
  245. public void CallScenePlayMainStory()
  246. {
  247. if (string.IsNullOrEmpty(this.scene_label_mainstory_))
  248. {
  249. return;
  250. }
  251. this.move_screen_.SetNextLabel(this.scene_label_mainstory_);
  252. this.CallScreen("Move");
  253. }
  254. public void CallScenePlayEveryday()
  255. {
  256. if (string.IsNullOrEmpty(this.scene_label_everyday_))
  257. {
  258. return;
  259. }
  260. this.move_screen_.SetNextLabel(this.scene_label_everyday_);
  261. this.CallScreen("Move");
  262. }
  263. public void CallScenePlayVip()
  264. {
  265. if (string.IsNullOrEmpty(this.scene_label_vip_))
  266. {
  267. return;
  268. }
  269. this.move_screen_.SetNextLabel(this.scene_label_vip_);
  270. this.CallScreen("Move");
  271. }
  272. public void CallStoryMode()
  273. {
  274. this.CallScreen("Story");
  275. }
  276. public void CallEverydayMode()
  277. {
  278. this.CallScreen("Everyday");
  279. }
  280. public void CallVipMode()
  281. {
  282. this.CallScreen("Vip");
  283. }
  284. public void CallYotogiMode()
  285. {
  286. if (string.IsNullOrEmpty(this.yotogi_label_))
  287. {
  288. return;
  289. }
  290. this.move_screen_.SetNextLabel(this.yotogi_label_);
  291. this.CallScreen("Move");
  292. }
  293. public void CallCharaSelect()
  294. {
  295. if (string.IsNullOrEmpty(this.cancel_label_))
  296. {
  297. return;
  298. }
  299. this.move_screen_.SetNextLabel(this.cancel_label_);
  300. this.CallScreen("Move");
  301. }
  302. public void CallEmpireLifeMode()
  303. {
  304. if (string.IsNullOrEmpty(this.life_mode_chara_select_label_))
  305. {
  306. return;
  307. }
  308. this.move_screen_.SetNextLabel(this.life_mode_chara_select_label_);
  309. this.CallScreen("Move");
  310. }
  311. public void CallScenePlayLifeMode()
  312. {
  313. if (string.IsNullOrEmpty(this.scene_label_life_mode_))
  314. {
  315. return;
  316. }
  317. this.move_screen.SetNextLabel(this.scene_label_life_mode_);
  318. this.CallScreen("Move");
  319. }
  320. protected override void SettingChildrenList(Dictionary<string, WfScreenChildren> children_dic)
  321. {
  322. string[] array = new string[]
  323. {
  324. "Select",
  325. "Init",
  326. "Vip",
  327. "Story",
  328. "Everyday",
  329. "LifeMode",
  330. "Move"
  331. };
  332. for (int i = 0; i < array.Length; i++)
  333. {
  334. WfScreenChildren component = UTY.GetChildObject(base.gameObject, array[i], false).GetComponent<WfScreenChildren>();
  335. component.parent_mgr = this;
  336. children_dic.Add(array[i], component);
  337. }
  338. }
  339. public WfScreenMoveChildren move_screen
  340. {
  341. get
  342. {
  343. return this.move_screen_;
  344. }
  345. }
  346. public bool is_life_mode_init { get; private set; }
  347. public FreeModeItemEveryday.ScnearioType ScnearioItemType
  348. {
  349. get
  350. {
  351. return this.itemType;
  352. }
  353. set
  354. {
  355. this.itemType = value;
  356. }
  357. }
  358. public static bool IsFreeMode;
  359. private Dictionary<string, SceneFreeModeSelectManager.BackupData> backup_data_dic_ = new Dictionary<string, SceneFreeModeSelectManager.BackupData>();
  360. private string backup_0_maid_guid;
  361. private WfScreenMoveChildren move_screen_;
  362. private ADVKagManager adv_kag_;
  363. private FreeModeInit init_mgr_;
  364. private string scene_label_mainstory_;
  365. private string scene_label_everyday_;
  366. private string scene_label_vip_;
  367. private string yotogi_label_;
  368. private string cancel_label_;
  369. private string scene_label_life_mode_;
  370. private string life_mode_chara_select_label_;
  371. [SerializeField]
  372. private FreeModeItemEveryday.ScnearioType itemType;
  373. private struct BackupData
  374. {
  375. public string guid;
  376. public Dictionary<string, int> maid_flag;
  377. public Seikeiken seikeiken;
  378. public HashSet<Feature.Data> feature_set;
  379. public HashSet<Propensity.Data> propensity_set;
  380. public Seikeiken init_seikeiken;
  381. public Relation relation;
  382. }
  383. }