TitleCtrl.cs 7.1 KB

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