TitleCtrl.cs 7.4 KB

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