TitleCtrl.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using com.workman.cm3d2.scene.dailyEtc;
  5. using I2.Loc;
  6. using UnityEngine;
  7. using wf;
  8. public class TitleCtrl : MonoBehaviour
  9. {
  10. public void Init(TitleMgr titleMgr, SceneMgr sceneMgr, GameObject goTitlePanel)
  11. {
  12. this.m_titleMgr = titleMgr;
  13. this.m_sceneMgr = sceneMgr;
  14. this.m_goTitlePanel = goTitlePanel;
  15. if (Product.isPublic)
  16. {
  17. Localize component = UTY.GetChildObject(goTitlePanel, "Title/TitleLogo", false).GetComponent<Localize>();
  18. Utility.SetLocalizeTerm(component, "SceneTitle/タイトルロゴ_全年齢", true);
  19. }
  20. this.m_listButton = new List<GameObject>();
  21. this.m_dicTitleButton = new Dictionary<TitleMgr.ButtonType, TitleCtrl.TitleButton>();
  22. int num = 0;
  23. IEnumerator enumerator = Enum.GetValues(typeof(TitleMgr.ButtonType)).GetEnumerator();
  24. try
  25. {
  26. while (enumerator.MoveNext())
  27. {
  28. object obj = enumerator.Current;
  29. TitleMgr.ButtonType buttonType = (TitleMgr.ButtonType)obj;
  30. TitleCtrl.TitleButton titleButton = new TitleCtrl.TitleButton();
  31. string text = buttonType.ToString();
  32. GameObject childObject = UTY.GetChildObject(goTitlePanel, "ButtonGroup/" + text + "Group/" + text, false);
  33. if (buttonType == TitleMgr.ButtonType.Shop)
  34. {
  35. if (!GameMain.Instance.CMSystem.NetUse)
  36. {
  37. childObject.SetActive(false);
  38. continue;
  39. }
  40. childObject.SetActive(true);
  41. }
  42. if (Product.isPublic && buttonType == TitleMgr.ButtonType.Guest)
  43. {
  44. num += -61;
  45. childObject.SetActive(false);
  46. }
  47. else
  48. {
  49. Vector3 localPosition = childObject.transform.localPosition;
  50. childObject.transform.localPosition = new Vector3(localPosition.x, localPosition.y - (float)num, localPosition.z);
  51. childObject.AddComponent<TitleMouseOver>();
  52. UIButton component2 = childObject.GetComponent<UIButton>();
  53. EventDelegate.Add(component2.onClick, new EventDelegate.Callback(BaseMgr<TitleMgr>.Instance.ClickButton));
  54. GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
  55. titleButton.selectCursor = childObject2;
  56. titleButton.name = buttonType;
  57. titleButton.active = false;
  58. this.m_dicTitleButton.Add(titleButton.name, titleButton);
  59. this.m_listButton.Add(UTY.GetChildObject(goTitlePanel, "ButtonGroup/" + text + "Group", false));
  60. }
  61. }
  62. }
  63. finally
  64. {
  65. IDisposable disposable;
  66. if ((disposable = (enumerator as IDisposable)) != null)
  67. {
  68. disposable.Dispose();
  69. }
  70. }
  71. this.SetActiveButton(TitleMgr.ButtonType.Start);
  72. this.PrepareAnimation(goTitlePanel);
  73. }
  74. public void SetActiveButton(TitleMgr.ButtonType activeButton)
  75. {
  76. IEnumerator enumerator = Enum.GetValues(typeof(TitleMgr.ButtonType)).GetEnumerator();
  77. try
  78. {
  79. while (enumerator.MoveNext())
  80. {
  81. object obj = enumerator.Current;
  82. TitleMgr.ButtonType buttonType = (TitleMgr.ButtonType)obj;
  83. if (buttonType != TitleMgr.ButtonType.Shop || GameMain.Instance.CMSystem.NetUse)
  84. {
  85. if (!Product.isPublic || buttonType != TitleMgr.ButtonType.Guest)
  86. {
  87. if (activeButton == buttonType)
  88. {
  89. this.m_dicTitleButton[buttonType].active = true;
  90. this.m_dicTitleButton[buttonType].selectCursor.SetActive(true);
  91. BaseMgr<TitleMgr>.Instance.m_currentActiveButton = activeButton;
  92. }
  93. else
  94. {
  95. this.m_dicTitleButton[buttonType].active = false;
  96. this.m_dicTitleButton[buttonType].selectCursor.SetActive(false);
  97. }
  98. }
  99. }
  100. }
  101. }
  102. finally
  103. {
  104. IDisposable disposable;
  105. if ((disposable = (enumerator as IDisposable)) != null)
  106. {
  107. disposable.Dispose();
  108. }
  109. }
  110. }
  111. private void PrepareAnimation(GameObject goTitlePanel)
  112. {
  113. foreach (GameObject gameObject in this.m_listButton)
  114. {
  115. gameObject.transform.localPosition = new Vector2(-600f, 0f);
  116. }
  117. }
  118. public void StartComponentAnimation()
  119. {
  120. this.TitleButtonAnimation();
  121. }
  122. private IEnumerator StartAnimator(Animator animator, float wait)
  123. {
  124. yield return new WaitForSeconds(wait);
  125. animator.SetBool("Active", true);
  126. yield break;
  127. }
  128. private void TitleLogoAnimation()
  129. {
  130. TweenAlpha tweenAlpha = this.m_goTitleLogo.AddComponent<TweenAlpha>();
  131. tweenAlpha.from = 0f;
  132. tweenAlpha.to = 1f;
  133. tweenAlpha.delay = 4f;
  134. tweenAlpha.duration = 1.5f;
  135. TweenScale tweenScale = this.m_goTitleLogo.AddComponent<TweenScale>();
  136. tweenScale.from = new Vector2(0f, 0f);
  137. tweenScale.to = new Vector2(1f, 1f);
  138. tweenScale.delay = 4f;
  139. tweenScale.duration = 1.5f;
  140. EventDelegate.Set(tweenScale.onFinished, new EventDelegate.Callback(this.TitleButtonAnimation));
  141. tweenAlpha.PlayForward();
  142. tweenScale.PlayForward();
  143. }
  144. private void TitleButtonAnimation()
  145. {
  146. base.StartCoroutine(this.TweenAniamtion());
  147. }
  148. private IEnumerator TweenAniamtion()
  149. {
  150. foreach (GameObject go in this.m_listButton)
  151. {
  152. iTween.MoveTo(go, iTween.Hash(new object[]
  153. {
  154. "x",
  155. 0,
  156. "y",
  157. 0,
  158. "time",
  159. 0.7f,
  160. "islocal",
  161. true
  162. }));
  163. yield return new WaitForSeconds(0.3f);
  164. }
  165. yield break;
  166. }
  167. public void OnStart()
  168. {
  169. GameMain.Instance.MainCamera.FadeOut(3f, false, delegate
  170. {
  171. this.m_sceneMgr.CloseScene();
  172. }, true, default(Color));
  173. TweenAlpha.Begin(this.m_goTitlePanel, 3f, 0f);
  174. }
  175. public void OnContinue(SaveAndLoadMgr saveAndLoadMgr)
  176. {
  177. saveAndLoadMgr.CallbackAfterFadeOut = new Action(this.m_titleMgr.OpenTitlePanel);
  178. this.m_titleMgr.CloseTitlePanel(new Action(saveAndLoadMgr.OpenLoadPanel));
  179. }
  180. public void OnConfig()
  181. {
  182. BaseMgr<ConfigMgr>.Instance.OpenConfigPanel();
  183. }
  184. public void OnEnd()
  185. {
  186. GameMain.Instance.ToApplicationQuit(false);
  187. }
  188. public void OnShop()
  189. {
  190. Application.OpenURL(GameMain.Instance.CMSystem.ShopURL);
  191. }
  192. public void OnGuestMode(SaveAndLoadMgr saveAndLoadMgr)
  193. {
  194. saveAndLoadMgr.CallbackAfterFadeOut = new Action(this.m_titleMgr.OpenTitlePanel);
  195. this.m_titleMgr.CloseTitlePanel(new Action(saveAndLoadMgr.OpenLoadPanelKasiduki));
  196. }
  197. public void OnBenchMark()
  198. {
  199. GameMain.Instance.MainCamera.FadeOut(3f, false, delegate
  200. {
  201. this.m_sceneMgr.GoToLabel("label_benchmarksetting");
  202. }, true, default(Color));
  203. TweenAlpha.Begin(this.m_goTitlePanel, 3f, 0f);
  204. }
  205. public void OnDance()
  206. {
  207. GameMain.Instance.MainCamera.FadeOut(3f, false, delegate
  208. {
  209. this.m_sceneMgr.GoToLabel("label_vsdance");
  210. }, true, default(Color));
  211. TweenAlpha.Begin(this.m_goTitlePanel, 3f, 0f);
  212. }
  213. public void OnCredit()
  214. {
  215. GameMain.Instance.MainCamera.FadeOut(3f, false, delegate
  216. {
  217. this.m_sceneMgr.GoToLabel("label_staffroll");
  218. }, true, default(Color));
  219. TweenAlpha.Begin(this.m_goTitlePanel, 3f, 0f);
  220. }
  221. private TitleMgr m_titleMgr;
  222. private SceneMgr m_sceneMgr;
  223. private GameObject m_goTitleLogo;
  224. private GameObject m_goTitleForScale;
  225. private GameObject m_goTitlePanel;
  226. private Dictionary<TitleMgr.ButtonType, TitleCtrl.TitleButton> m_dicTitleButton;
  227. private TitleMgr.ButtonType m_currentActiveButton;
  228. private List<GameObject> m_listButton;
  229. private const string SCENE_NAME_FROM_START = "SceneUserEdit";
  230. private const string SCENE_NAME_FROM_CONTINUE = "SceneGeneral";
  231. private const string SCENE_NAME_FROM_CONFIG = "SceneConfig";
  232. private const float INIT_TITLE_LOGO_SCALE = 0f;
  233. private const float INIT_BUTTON_POS = -600f;
  234. private const float TITLELOGO_FADEIN_DELAY = 4f;
  235. private const float TITLELOGO_FADEIN_DURATION = 1.5f;
  236. private const float BUTTON_FADEIN_DURATION = 0.7f;
  237. private const float BUTTON_FADEIN_INTERVAL = 0.3f;
  238. private const float DURATION_TO_FADE = 3f;
  239. [SerializeField]
  240. private Animator m_animatorBenchMark;
  241. [SerializeField]
  242. private Animator m_animatorDance;
  243. private class TitleButton
  244. {
  245. public TitleMgr.ButtonType name;
  246. public GameObject selectCursor;
  247. public bool active;
  248. }
  249. }