using FairyGUI; using UnityEngine; using ET; namespace GFGGame { public class GameController { public static async ET.ETTask Start() { await LoginController.CheckVersion(); CheckShowLoginView(); } private static void CheckShowLoginView() { LauncherView.Instance.Close(); ViewManager.Show(); } public static bool CheckLoginCache(bool doLogin) { string account = PlayerPrefs.GetString(GameConst.ACCOUNT_LAST_LOGIN_KEY, null); string password = PlayerPrefs.GetString(GameConst.PASSWORD_LAST_LOGIN_KEY, null); bool lastLoginIsVisitor = LocalCache.GetBool(GameConst.LAST_LOGIN_IS_VISITOR_KEY, false); if (lastLoginIsVisitor) { long id = (long)PlayerPrefs.GetFloat(GameConst.VISITOR_ID_KEY, -1); if (id >= 0) { if (doLogin) { //LoginProxy.LoginAsVisitor(); } return true; } } else if (account != null && account.Length > 0) { if (password != null && password.Length > 0) { if (doLogin) { LoginController.Login(account, password, true).Coroutine(); } return true; } } return false; } public static void CheckSpecialAccount(string account) { GameGlobal.antiAddiction = !(account.IndexOf("sygfg") == 0); } public static void ShowCreateRole() { ViewManager.Show(ViewName.CREATE_ROLE_VIEW); } public static void PreEnterGame() { //RoleInfo roleInfo = null; GetSuitItemController.enable = false; //roleInfo = result.roleInfo; //bool rerult = AntiAddictionController.CheckAntiAddiction(roleInfo.onlineTimeSecs, roleInfo.onlineDurationSecs, roleInfo.onlineDurationSecsDay); //if (rerult) //{ // return; //} //ServerDataManager.SetServerTime(roleInfo.serverTime); RoleDataManager.InitServerData(); //ItemDataManager.InitServerData(result.roleItemList); //CustomSuitDataManager.InitServerData(roleInfo.suitIndex, result.roleSuitList); //StoryDataManager.InitServerData(roleInfo); //GuideDataManager.InitServerData(result.roleGuideList); //CardDataManager.InitServerData(result.roleCardList); //SkillDataManager.Instance.InitServerData(result.roleSkillList); //SkillDataManager.Instance.SetDicPassivitySkillCfg(); GetSuitItemController.enable = true; RoleDataHandler.StartUpdate(); GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame")); GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main")); Alert.Show("是否跳过引导?如果您是第一次体验,建议不要跳过引导!") .SetLeftButton(true, "不用", (obj) => { EnterGame(); }) .SetRightButton(true, "跳过", (obj) => { GameGlobal.skipGuide = true; EnterGame(); }); } public static void QuitToLoginView(bool logout) { GetSuitItemController.enable = false; GameGlobal.isVisitor = false; GameGlobal.antiAddiction = true; GameGlobal.userId = 0; GameGlobal.userAge = 0; GameGlobal.skipGuide = false; RoleDataHandler.StopUpdate(); CardDataManager.Clear(); DecomposeDataManager.Instance.Clear(); PhotographDataManager.Instance.Clear(); SkillDataManager.Instance.Clear(); SuitFosterDataManager.Instance.Clear(); if (logout) { Logout(); } ViewManager.Hide(ViewName.ROLE_INFO_VIEW); ViewManager.Hide(ViewName.MAINUI_VIEW); ViewManager.Show(); if (logout) { ViewManager.Show(); } } //注销 public static void Logout() { PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY); } public static void GoBackToMainView() { ViewManager.Show(ViewName.MAINUI_VIEW, null, null, true); } private static void EnterGame() { ViewManager.Hide(); if (StoryDataManager.CheckOpenMainUI() || GameGlobal.skipGuide) { ViewManager.Show(ViewName.MAINUI_VIEW); } else { StoryDataManager.currentChapterCfgId = 10001; if (GameGlobal.isFirstEntry == true) { // ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW, }); StoryController.ShowPriorStoryDialog(); } else { ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapterCfgId, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW }); } } Timers.inst.CallLater(AfterEnterGame); } private static void AfterEnterGame(object param) { //GameProxy.ReqGetStoryScoreList(); //GameProxy.ReqGetStoryStarList(); ItemHelper.GetItemAttributeInfos().Coroutine(); SuitFosterProxy.SendGetSuitInfos().Coroutine(); InstanceZonesSProxy.GetStoryInfos().Coroutine(); MainStorySProxy.GetStoryInfos().Coroutine(); } public static void PrepareUpdateTreasure() { if (!Timers.inst.Exists(UpdateTreasure)) { Timers.inst.Add(0.1f, 1, UpdateTreasure); } } private static void UpdateTreasure(object param) { GameProxy.ReqUpdateTreasure(); } } }