TitleCtrl.cs 7.9 KB

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