GameController.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using FairyGUI;
  2. using UnityEngine;
  3. using UI.CommonGame;
  4. using UI.Main;
  5. using UI.Common;
  6. namespace GFGGame
  7. {
  8. public class GameController
  9. {
  10. public static async ET.ETTask Start()
  11. {
  12. await LoginController.CheckVersion();
  13. CheckShowLoginView();
  14. }
  15. private static void CheckShowLoginView()
  16. {
  17. LauncherView.Instance.Close();
  18. ViewManager.Show<LoginView>();
  19. }
  20. public static bool CheckLoginCache(bool doLogin)
  21. {
  22. string account = PlayerPrefs.GetString(GameConst.ACCOUNT_LAST_LOGIN_KEY, null);
  23. string password = PlayerPrefs.GetString(GameConst.PASSWORD_LAST_LOGIN_KEY, null);
  24. bool lastLoginIsVisitor = LocalCache.GetBool(GameConst.LAST_LOGIN_IS_VISITOR_KEY, false);
  25. if (lastLoginIsVisitor)
  26. {
  27. long id = (long)PlayerPrefs.GetFloat(GameConst.VISITOR_ID_KEY, -1);
  28. if (id >= 0)
  29. {
  30. if (doLogin)
  31. {
  32. //LoginProxy.LoginAsVisitor();
  33. }
  34. return true;
  35. }
  36. }
  37. else if (account != null && account.Length > 0)
  38. {
  39. if (password != null && password.Length > 0)
  40. {
  41. if (doLogin)
  42. {
  43. LoginController.Login(account, password, true).Coroutine();
  44. }
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. public static void CheckSpecialAccount(string account)
  51. {
  52. GameGlobal.antiAddiction = !(account.IndexOf("sygfg") == 0);
  53. }
  54. public static void ShowCreateRole()
  55. {
  56. ViewManager.Show(ViewName.CREATE_ROLE_VIEW);
  57. }
  58. public static void PreEnterGame()
  59. {
  60. //RoleInfo roleInfo = null;
  61. GetSuitItemController.enable = false;
  62. DressUpMenuSuitDataManager.InitData();
  63. DressUpMenuItemDataManager.InitData();
  64. //roleInfo = result.roleInfo;
  65. //bool rerult = AntiAddictionController.CheckAntiAddiction(roleInfo.onlineTimeSecs, roleInfo.onlineDurationSecs, roleInfo.onlineDurationSecsDay);
  66. //if (rerult)
  67. //{
  68. // return;
  69. //}
  70. //ServerDataManager.SetServerTime(roleInfo.serverTime);
  71. //RoleDataManager.InitServerData(roleInfo);
  72. //ItemDataManager.InitServerData(result.roleItemList);
  73. //CustomSuitDataManager.InitServerData(roleInfo.suitIndex, result.roleSuitList);
  74. //StoryDataManager.InitServerData(roleInfo);
  75. //GuideDataManager.InitServerData(result.roleGuideList);
  76. //DressUpMenuSuitDataManager.InitServerData(result.systemSuitList);
  77. //CardDataManager.InitServerData(result.roleCardList);
  78. //SkillDataManager.Instance.InitServerData(result.roleSkillList);
  79. //SkillDataManager.Instance.SetDicPassivitySkillCfg();
  80. GetSuitItemController.enable = true;
  81. //RoleDataHandler.StartUpdate();
  82. GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
  83. GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main"));
  84. Alert.Show("是否跳过引导?如果您是第一次体验,建议不要跳过引导!")
  85. .SetLeftButton(true, "不用", (obj) =>
  86. {
  87. EnterGame();
  88. })
  89. .SetRightButton(true, "跳过", (obj) =>
  90. {
  91. GameGlobal.skipGuide = true;
  92. EnterGame();
  93. });
  94. }
  95. public static void QuitToLoginView(bool logout)
  96. {
  97. GetSuitItemController.enable = false;
  98. GameGlobal.isVisitor = false;
  99. GameGlobal.antiAddiction = true;
  100. GameGlobal.userId = 0;
  101. GameGlobal.userAge = 0;
  102. GameGlobal.skipGuide = false;
  103. RoleDataHandler.StopUpdate();
  104. CardDataManager.Clear();
  105. DecomposeDataManager.Instance.Clear();
  106. PhotographDataManager.Instance.Clear();
  107. SkillDataManager.Instance.Clear();
  108. if (logout)
  109. {
  110. Logout();
  111. }
  112. ViewManager.Hide(ViewName.ROLE_INFO_VIEW);
  113. ViewManager.Hide(ViewName.MAINUI_VIEW);
  114. ViewManager.Show<LoginView>();
  115. if (logout)
  116. {
  117. ViewManager.Show<LoginInputView>();
  118. }
  119. }
  120. //注销
  121. public static void Logout()
  122. {
  123. PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
  124. }
  125. public static void GoBackToMainView()
  126. {
  127. ViewManager.Show(ViewName.MAINUI_VIEW, null, null, true);
  128. }
  129. private static void EnterGame()
  130. {
  131. ViewManager.Hide<LoginView>();
  132. if (StoryDataManager.CheckOpenMainUI() || GameGlobal.skipGuide)
  133. {
  134. ViewManager.Show(ViewName.MAINUI_VIEW);
  135. }
  136. else
  137. {
  138. StoryDataManager.currentChapter = 1;
  139. if (GameGlobal.isFirstEntry == true)
  140. {
  141. // ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW, });
  142. StoryController.ShowPriorStoryDialog();
  143. }
  144. else
  145. {
  146. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW });
  147. }
  148. }
  149. AfterEnterGame();
  150. }
  151. private static void AfterEnterGame()
  152. {
  153. //GameProxy.ReqGetStoryScoreList();
  154. //GameProxy.ReqGetStoryStarList();
  155. }
  156. public static void PrepareUpdateTreasure()
  157. {
  158. if (!Timers.inst.Exists(UpdateTreasure))
  159. {
  160. Timers.inst.Add(0.1f, 1, UpdateTreasure);
  161. }
  162. }
  163. private static void UpdateTreasure(object param)
  164. {
  165. GameProxy.ReqUpdateTreasure();
  166. }
  167. }
  168. }