SceneFreeModeSelectManager.cs 12 KB

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