TitleMgr.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System;
  2. using com.workman.cm3d2.scene.dailyEtc;
  3. using Kasizuki;
  4. using UnityEngine;
  5. public class TitleMgr : BaseMgr<TitleMgr>
  6. {
  7. public void Awake()
  8. {
  9. Debug.Log("Title::Awake");
  10. }
  11. private void Start()
  12. {
  13. }
  14. private void Init()
  15. {
  16. GameObject gameObject = GameObject.Find("/UI Root");
  17. NDebug.Assert(gameObject != null, string.Format("{0}が見つかりませんでした。", "UI Root"));
  18. gameObject.transform.Find("TitlePanel").gameObject.SetActive(false);
  19. gameObject.transform.Find("TitlePanel_Trial").gameObject.SetActive(false);
  20. gameObject.transform.Find("TitlePanel_PlayReview").gameObject.SetActive(false);
  21. this.m_goTitlePanel = gameObject.transform.Find("TitlePanel").gameObject;
  22. this.m_goTitlePanel.SetActive(true);
  23. NDebug.Assert(this.m_goTitlePanel != null, string.Format("{0}が見つかりませんでした。", "TitlePanel"));
  24. this.m_goTitlePanel.SetActive(true);
  25. this.m_titleCtrl = this.m_goTitlePanel.GetComponent<TitleCtrl>();
  26. NDebug.Assert(this.m_titleCtrl != null, string.Format("{0}が見つかりませんでした。", "TitleCtrlコンポーネント"));
  27. this.m_sceneMgr = this.getSceneManager();
  28. this.m_titleCtrl.Init(this, this.m_sceneMgr, this.m_goTitlePanel);
  29. GameObject childObject = UTY.GetChildObject(gameObject, "Manager/SaveAndLoadMgr", false);
  30. NDebug.Assert(childObject != null, string.Format("{0}が見つかりませんでした。", "Manager/SaveAndLoadMgr"));
  31. this.m_saveAndLoadMgr = childObject.GetComponent<SaveAndLoadMgr>();
  32. this.m_saveAndLoadMgr.BaseInit();
  33. this.InitKasizukiSaveLoadCtrl();
  34. this.InitCommand();
  35. GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr.CloseMessageWindowPanel();
  36. GameMain.Instance.Serialize(-1, "タイトルへ戻る");
  37. GameMain.Instance.BgMgr.DeleteBg();
  38. GameMain.Instance.SoundMgr.StopAll();
  39. GameMain.Instance.SoundMgr.PlayBGM("BGM004.ogg", 0f, true);
  40. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, false);
  41. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  42. GameMain.Instance.MainCamera.FadeIn(3f, false, null, true, true, default(Color));
  43. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(-9.30211f, 1.579518f, 17.12966f), true);
  44. GameMain.Instance.MainCamera.SetDistance(0.5999951f, true);
  45. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(-221.6162f, -9.254665f), true);
  46. GameMain.Instance.MainCamera.SetControl(true);
  47. GameMain.Instance.MainLight.Reset();
  48. if (GameMain.Instance.VRMode)
  49. {
  50. GameMain.Instance.MainCamera.SetPos(new Vector3(0f, 1.855f, 20f));
  51. GameMain.Instance.MainCamera.SetRotation(new Vector3(0f, -180f, 0f));
  52. GameMain.Instance.OvrMgr.OvrCamera.ReCallcOffset();
  53. }
  54. GameMain.Instance.SysShortcut.gameObject.SetActive(true);
  55. this.m_titleCtrl.StartComponentAnimation();
  56. GameMain.Instance.LoadIcon.force_draw_new = false;
  57. }
  58. private SceneMgr getSceneManager()
  59. {
  60. SceneMgr result = null;
  61. GameObject f_goParent = GameObject.Find("/UI Root");
  62. GameObject childObject = UTY.GetChildObject(f_goParent, "Manager", false);
  63. if (childObject != null)
  64. {
  65. result = childObject.GetComponent<SceneMgr>();
  66. }
  67. return result;
  68. }
  69. private void InitCommand()
  70. {
  71. if (this.m_goTitleCommand == null)
  72. {
  73. this.m_goTitleCommand = UnityEngine.Object.Instantiate<GameObject>(new GameObject());
  74. this.m_goTitleCommand.name = "TitleCommand";
  75. }
  76. this.m_goTitleCommand.AddComponent<TitleUpArrowCommand>().Init();
  77. this.m_goTitleCommand.AddComponent<TitleDownArrowCommand>().Init();
  78. this.m_goTitleCommand.AddComponent<TitleReturnCommand>().Init();
  79. }
  80. private void InitKasizukiSaveLoadCtrl()
  81. {
  82. if (this.m_KasizukiSaveAndLoadCtrl == null)
  83. {
  84. return;
  85. }
  86. SaveAndLoadMgr saveAndLoadMgr = this.m_saveAndLoadMgr;
  87. saveAndLoadMgr.OnOpenLoadPanelKasizukiLocal = (Action)Delegate.Combine(saveAndLoadMgr.OnOpenLoadPanelKasizukiLocal, new Action(delegate
  88. {
  89. this.m_saveAndLoadMgr.CloseSaveAndLoadPanel();
  90. this.m_KasizukiSaveAndLoadCtrl.Open(0.25f, null);
  91. this.m_KasizukiSaveAndLoadCtrl.Open(SaveAndLoadMgr.ViewType.Load, true);
  92. this.m_KasizukiSaveAndLoadCtrl.GetChildObject("DisplayButtonGroup/DisplaySave").SetActive(false);
  93. }));
  94. KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl = this.m_KasizukiSaveAndLoadCtrl;
  95. kasizukiSaveAndLoadCtrl.onClickCancel = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl.onClickCancel, new Action(delegate
  96. {
  97. this.m_KasizukiSaveAndLoadCtrl.Close(0.25f, delegate
  98. {
  99. GameMain.Instance.Deserialize(-1, false);
  100. this.m_saveAndLoadMgr.CallbackAfterFadeOut = new Action(this.OpenTitlePanel);
  101. this.m_saveAndLoadMgr.OpenLoadPanelKasiduki();
  102. });
  103. }));
  104. KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl2 = this.m_KasizukiSaveAndLoadCtrl;
  105. kasizukiSaveAndLoadCtrl2.onLoad = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl2.onLoad, new Action(delegate
  106. {
  107. this.m_KasizukiSaveAndLoadCtrl.Close(0.5f, delegate
  108. {
  109. GameMain.Instance.CharacterMgr.status.SetFlag("傅きモード", 1);
  110. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  111. });
  112. }));
  113. KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl3 = this.m_KasizukiSaveAndLoadCtrl;
  114. kasizukiSaveAndLoadCtrl3.onClickNewGame = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl3.onClickNewGame, new Action(delegate
  115. {
  116. this.m_KasizukiSaveAndLoadCtrl.Close(0.5f, delegate
  117. {
  118. GameMain.Instance.CharacterMgr.status.SetFlag("傅きモード", 1);
  119. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  120. });
  121. }));
  122. KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl4 = this.m_KasizukiSaveAndLoadCtrl;
  123. kasizukiSaveAndLoadCtrl4.onDelete = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl4.onDelete, new Action(delegate
  124. {
  125. int nowOriginSaveDataNumber = GameMain.Instance.KasizukiMgr.NowOriginSaveDataNumber;
  126. if (GameMain.Instance.GetSaveDataHeader(nowOriginSaveDataNumber) == null)
  127. {
  128. NDebug.Assert("本編セーブデータ" + nowOriginSaveDataNumber + "番の取得に失敗しました", false);
  129. return;
  130. }
  131. GameMain.Instance.SerializeKasizukiOnly(nowOriginSaveDataNumber);
  132. this.m_KasizukiSaveAndLoadCtrl.GetChildObject("DisplayButtonGroup/DisplaySave").SetActive(false);
  133. }));
  134. }
  135. public void ClickButton()
  136. {
  137. string name = UIButton.current.name;
  138. this.EnterButton(name);
  139. }
  140. public void EnterButton(string buttonName)
  141. {
  142. if (!base.IsValidateButton<TitleMgr.ButtonType>(buttonName))
  143. {
  144. return;
  145. }
  146. TitleMgr.ButtonType activeButton = (TitleMgr.ButtonType)Enum.Parse(typeof(TitleMgr.ButtonType), buttonName);
  147. switch (activeButton)
  148. {
  149. case TitleMgr.ButtonType.Start:
  150. this.m_titleCtrl.OnStart();
  151. break;
  152. case TitleMgr.ButtonType.Continue:
  153. this.m_titleCtrl.OnContinue(this.m_saveAndLoadMgr);
  154. break;
  155. case TitleMgr.ButtonType.Guest:
  156. this.m_titleCtrl.OnGuestMode(this.m_saveAndLoadMgr);
  157. break;
  158. case TitleMgr.ButtonType.Config:
  159. this.m_titleCtrl.OnConfig();
  160. break;
  161. case TitleMgr.ButtonType.End:
  162. this.m_titleCtrl.OnEnd();
  163. break;
  164. case TitleMgr.ButtonType.Shop:
  165. this.m_titleCtrl.OnShop();
  166. break;
  167. }
  168. this.m_titleCtrl.SetActiveButton(activeButton);
  169. }
  170. public void MoveNextButton()
  171. {
  172. int num = (int)this.m_currentActiveButton;
  173. num++;
  174. if (num > Enum.GetValues(typeof(TitleMgr.ButtonType)).Length - 1)
  175. {
  176. num = 0;
  177. }
  178. this.m_titleCtrl.SetActiveButton((TitleMgr.ButtonType)num);
  179. this.m_currentActiveButton = (TitleMgr.ButtonType)num;
  180. }
  181. public void MovePreviousButton()
  182. {
  183. int num = (int)this.m_currentActiveButton;
  184. num--;
  185. if (num < 0)
  186. {
  187. num = Enum.GetValues(typeof(TitleMgr.ButtonType)).Length - 1;
  188. }
  189. this.m_titleCtrl.SetActiveButton((TitleMgr.ButtonType)num);
  190. this.m_currentActiveButton = (TitleMgr.ButtonType)num;
  191. }
  192. public void OpenTitlePanel()
  193. {
  194. if (!this.m_bInit)
  195. {
  196. this.Init();
  197. this.m_bInit = true;
  198. }
  199. this.FadeInPanel();
  200. }
  201. protected void FadeInPanel()
  202. {
  203. this.m_goTitlePanel.SetActive(true);
  204. TweenAlpha tweenAlpha = this.m_goTitlePanel.AddComponent<TweenAlpha>();
  205. tweenAlpha.from = 0f;
  206. tweenAlpha.to = 1f;
  207. tweenAlpha.duration = 0.5f;
  208. tweenAlpha.PlayForward();
  209. }
  210. public void CloseTitlePanel(Action OnFinished = null)
  211. {
  212. this.FadeOutPanel(OnFinished);
  213. }
  214. protected void FadeOutPanel(Action OnFinished = null)
  215. {
  216. TweenAlpha tweenAlpha = TweenAlpha.Begin(this.m_goTitlePanel, 0.5f, 0f);
  217. EventDelegate.Set(tweenAlpha.onFinished, delegate
  218. {
  219. this.m_goTitlePanel.SetActive(false);
  220. if (OnFinished != null)
  221. {
  222. OnFinished();
  223. }
  224. });
  225. }
  226. public void NextScene(string labelName)
  227. {
  228. string label_name = GameMain.Instance.ScriptMgr.adv_kag.tag_backup[labelName];
  229. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(label_name);
  230. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  231. }
  232. public TitleMgr.ButtonType m_currentActiveButton;
  233. public TitleCtrl m_titleCtrl;
  234. private SceneMgr m_sceneMgr;
  235. private SaveAndLoadMgr m_saveAndLoadMgr;
  236. [SerializeField]
  237. private GameObject m_goTitlePanel;
  238. private GameObject m_goTitleCommand;
  239. private TitleCommand m_command;
  240. [SerializeField]
  241. private KasizukiSaveAndLoadCtrl m_KasizukiSaveAndLoadCtrl;
  242. private bool m_bInit;
  243. private const string uiRootPath = "/UI Root";
  244. private const string TITLE_COMMAND_NAME = "TitleCommand";
  245. private const float DURATION_TO_FADE = 0.5f;
  246. public enum ButtonType
  247. {
  248. Start,
  249. Continue,
  250. Guest,
  251. Config,
  252. End,
  253. Shop
  254. }
  255. }