FreeModeSceneSelectBase.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using Schedule;
  6. using UnityEngine;
  7. public class FreeModeSceneSelectBase : WfScreenChildren
  8. {
  9. public override void Awake()
  10. {
  11. base.Awake();
  12. EventDelegate.Add(UTY.GetChildObject(base.root_obj, "Cancel", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnClickCancel));
  13. this.ok_btn_ = UTY.GetChildObject(base.root_obj, "OK", false).GetComponent<UIButton>();
  14. EventDelegate.Add(this.ok_btn_.onClick, new EventDelegate.Callback(this.OnClickOk));
  15. if (this.mode == FreeModeSceneSelectBase.SelectMode.Vip)
  16. {
  17. this.night_task_viewer_ = UTY.GetChildObject(base.root_obj, "TaskViewer", false).GetComponent<ScheduleTaskViewer>();
  18. this.night_task_viewer_.gameObject.SetActive(true);
  19. this.night_task_viewer_.AlwaysDrawDescriptionViewer = true;
  20. }
  21. }
  22. protected override void OnCall()
  23. {
  24. SubtitleMovieManager.DestroyGlobalInstance();
  25. this.is_scenario_load_ = false;
  26. if (this.maid_ != null)
  27. {
  28. this.maid_.Visible = true;
  29. return;
  30. }
  31. this.mgr_ = (base.parent_mgr as SceneFreeModeSelectManager);
  32. NDebug.AssertNull(this.mgr_ != null);
  33. this.maid_ = GameMain.Instance.CharacterMgr.GetMaid(0);
  34. this.freemode_item_list_ = UTY.GetChildObject(base.root_obj, "FreeModeItemList", false).GetComponent<FreeModeItemList>();
  35. bool isEnabled;
  36. if (this.mode == FreeModeSceneSelectBase.SelectMode.Story)
  37. {
  38. isEnabled = this.freemode_item_list_.SetList(FreeModeItemEveryday.CreateItemEverydayList(FreeModeItemEveryday.ScnearioType.Story, null).ToArray(), this.maid_);
  39. }
  40. else if (this.mode == FreeModeSceneSelectBase.SelectMode.Everyday)
  41. {
  42. isEnabled = this.freemode_item_list_.SetList(FreeModeItemEveryday.CreateItemEverydayList(FreeModeItemEveryday.ScnearioType.Nitijyou, this.maid_.status).ToArray(), this.maid_);
  43. }
  44. else if (this.mode == FreeModeSceneSelectBase.SelectMode.LifeMode)
  45. {
  46. isEnabled = this.freemode_item_list_.SetList(FreeModeItemLifeMode.CreateItemList(true).ToArray(), this.maid_);
  47. }
  48. else
  49. {
  50. this.freemode_item_list_.gameObject.SetActive(false);
  51. this.night_task_viewer_.gameObject.SetActive(true);
  52. ScheduleCSVData.Yotogi yotogi = null;
  53. int num = int.MaxValue;
  54. int num2 = int.MaxValue;
  55. this.vip_list_ = FreeModeItemVip.CreateItemVipList(this.maid_.status);
  56. List<ScheduleTaskViewer.ViewData> list = new List<ScheduleTaskViewer.ViewData>();
  57. foreach (FreeModeItemVip freeModeItemVip in this.vip_list_)
  58. {
  59. ScheduleTaskViewer.ViewData item = default(ScheduleTaskViewer.ViewData);
  60. item.is_enabled = freeModeItemVip.isEnabled(this.maid_);
  61. item.schedule = freeModeItemVip.vip_data;
  62. if (!GameMain.Instance.CharacterMgr.status.lockNTRPlay || !ScheduleCSVData.NetorareFlag.Contains(item.schedule.id))
  63. {
  64. if (ScheduleAPI.VisibleNightWork(item.schedule.id, this.maid_, false))
  65. {
  66. list.Add(item);
  67. if (item.is_enabled)
  68. {
  69. if (item.schedule.categoryID == num)
  70. {
  71. if (item.schedule.id <= num2)
  72. {
  73. yotogi = (ScheduleCSVData.Yotogi)item.schedule;
  74. num2 = item.schedule.id;
  75. }
  76. }
  77. else if (item.schedule.categoryID <= num)
  78. {
  79. yotogi = (ScheduleCSVData.Yotogi)item.schedule;
  80. num = item.schedule.categoryID;
  81. num2 = item.schedule.id;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. this.night_task_viewer_.onClickWorkUnitEvent = delegate(ScheduleCSVData.ScheduleBase click_data)
  88. {
  89. if (click_data == null)
  90. {
  91. this.freemode_item_list_.select_item_data = null;
  92. return;
  93. }
  94. foreach (FreeModeItemVip freeModeItemVip2 in this.vip_list_)
  95. {
  96. if (freeModeItemVip2.vip_data == click_data)
  97. {
  98. this.freemode_item_list_.select_item_data = freeModeItemVip2;
  99. break;
  100. }
  101. }
  102. };
  103. this.night_task_viewer_.onClickWorkUnitEvent(yotogi);
  104. Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleTaskViewer.ViewData>> dictionary = new Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleTaskViewer.ViewData>>();
  105. Dictionary<ScheduleMgr.ScheduleTime, ScheduleCSVData.ScheduleBase> dictionary2 = new Dictionary<ScheduleMgr.ScheduleTime, ScheduleCSVData.ScheduleBase>();
  106. dictionary.Add(ScheduleTaskCtrl.TaskType.Yotogi, list);
  107. dictionary2.Add(ScheduleMgr.ScheduleTime.Night, yotogi);
  108. this.night_task_viewer_.Call(this.maid_, ScheduleMgr.ScheduleTime.Night, dictionary, dictionary2);
  109. isEnabled = (this.freemode_item_list_.select_item_data != null);
  110. }
  111. this.ok_btn_.isEnabled = isEnabled;
  112. this.maid_.Visible = true;
  113. }
  114. private void OnClickOk()
  115. {
  116. if (this.freemode_item_list_ == null || this.freemode_item_list_.select_item_data == null)
  117. {
  118. return;
  119. }
  120. GameMain.Instance.SoundMgr.StopBGM(0.3f);
  121. this.is_scenario_load_ = true;
  122. AbstractFreeModeItem select_item_data = this.freemode_item_list_.select_item_data;
  123. string text = select_item_data.play_file_name;
  124. text = ScriptManager.ReplacePersonal(this.maid_, text);
  125. GameMain.Instance.ScriptMgr.EvalScript("tf['シーン再生_ファイル名'] = '" + text + "';");
  126. if (select_item_data.type == AbstractFreeModeItem.ItemType.Vip)
  127. {
  128. this.mgr_.CallScenePlayVip();
  129. }
  130. else if (select_item_data.type == AbstractFreeModeItem.ItemType.Normal)
  131. {
  132. this.mgr_.CallScenePlayEveryday();
  133. }
  134. else if (select_item_data.type == AbstractFreeModeItem.ItemType.MainStory)
  135. {
  136. this.mgr_.CallScenePlayMainStory();
  137. }
  138. else if (select_item_data.type == AbstractFreeModeItem.ItemType.LifeMode)
  139. {
  140. this.Finish();
  141. }
  142. }
  143. protected override void OnFinish()
  144. {
  145. base.OnFinish();
  146. if (this.is_scenario_load_)
  147. {
  148. if (this.IsLifeModeData())
  149. {
  150. this.LifeModeScenarioMaidActivate(this.freemode_item_list_.select_item_data as FreeModeItemLifeMode, delegate
  151. {
  152. this.mgr_.CallScenePlayLifeMode();
  153. });
  154. }
  155. GameMain.Instance.MainLight.Reset();
  156. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  157. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  158. GameMain.Instance.SoundMgr.VoiceStopAll();
  159. GameMain.Instance.CharacterMgr.SetCharaAllPos(Vector3.zero);
  160. GameMain.Instance.CharacterMgr.SetCharaAllRot(Vector3.zero);
  161. GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
  162. GameMain.Instance.ScriptMgr.StopMotionScript();
  163. }
  164. this.is_scenario_load_ = false;
  165. }
  166. private void OnClickCancel()
  167. {
  168. this.mgr_.CallScreen("Select");
  169. }
  170. private bool IsLifeModeData()
  171. {
  172. return !(this.freemode_item_list_ == null) && this.freemode_item_list_.select_item_data != null && this.freemode_item_list_.select_item_data.type == AbstractFreeModeItem.ItemType.LifeMode;
  173. }
  174. private void LifeModeScenarioMaidActivate(FreeModeItemLifeMode freeModeItemLifeMode, Action onFinish)
  175. {
  176. List<Maid> list = new List<Maid>();
  177. using (Dictionary<int, string>.Enumerator enumerator = freeModeItemLifeMode.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic.GetEnumerator())
  178. {
  179. while (enumerator.MoveNext())
  180. {
  181. KeyValuePair<int, string> slotPersonalPair = enumerator.Current;
  182. Maid maid = GameMain.Instance.LifeModeMgr.lifeModeAllMaidList.First((Maid data) => data.status.personal.uniqueName == slotPersonalPair.Value);
  183. GameMain.Instance.CharacterMgr.SetActiveMaid(maid, slotPersonalPair.Key);
  184. list.Add(maid);
  185. }
  186. }
  187. base.StartCoroutine(this.CoWaitAllCharacterLoad(list, onFinish));
  188. }
  189. private IEnumerator CoWaitAllCharacterLoad(IEnumerable<Maid> maids, Action onFinish)
  190. {
  191. foreach (Maid maid in maids)
  192. {
  193. maid.Visible = true;
  194. maid.AllProcPropSeqStart();
  195. while (maid.IsBusy)
  196. {
  197. yield return null;
  198. }
  199. }
  200. if (onFinish != null)
  201. {
  202. onFinish();
  203. }
  204. yield break;
  205. }
  206. public FreeModeSceneSelectBase.SelectMode mode;
  207. private Maid maid_;
  208. private SceneFreeModeSelectManager mgr_;
  209. private UIButton ok_btn_;
  210. private FreeModeItemList freemode_item_list_;
  211. private ScheduleTaskViewer night_task_viewer_;
  212. private bool is_scenario_load_;
  213. private List<FreeModeItemVip> vip_list_;
  214. public enum SelectMode
  215. {
  216. Everyday,
  217. Vip,
  218. Story,
  219. LifeMode
  220. }
  221. }