using FairyGUI; using UnityEngine; using ET; using static GFGGame.LauncherConfig; namespace GFGGame { public class GameController { public static void Start() { //界面 ViewManager.Init(); //日志 LogController.Instance.Init(); //全局 GameGlobal.Init(); //缓存 LocalCache.InitLocalData(); //sqlite SqliteController.Instance.Init(false, ResPathUtil.SQLITE_FILE_PATH); //全局点击效果 ViewGlobal.CreatClickEffect(); //获取游戏配置 GetGameCfg(); } /// /// 获取游戏配置 /// public static void GetGameCfg() { var url = LauncherConfig.cfgUrl.Replace("{cfgName}", GameGlobal.cfgName); HttpTool.Instance.Get(url, (string data) => { GameGlobal.InitData(data); //显示登录 LoginController.ShowLogin(); }); } 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 (!string.IsNullOrEmpty(account)) { if (!string.IsNullOrEmpty(password)) { if (doLogin) { LoginController.Login(account, password, true).Coroutine(); } return true; } else if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL && PlayerPrefs.HasKey(GameConst.PASSWORD_LAST_LOGIN_KEY)) { if (doLogin) { LoginController.LoginTest(account).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 async ETTask PreEnterGameAsync() { RoleDataHandler.StartUpdate(); GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame")); GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main")); await InstanceZonesSProxy.GetInstanceZonesInfos(); await StorageSProxy.ReqGetClientValues(); int skipGuide = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_SKIP_GUIDE); if (skipGuide <= 0 && LauncherConfig.netType == EnumNetType.LOCAL) { Alert.Show("是否跳过引导?如果您是第一次体验,建议不要跳过引导!") .SetLeftButton(true, "不用", (obj) => { EnterGame(); StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_SKIP_GUIDE, 1).Coroutine(); }) .SetRightButton(true, "跳过", (obj) => { GameGlobal.skipGuide = true; EnterGame(); StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_SKIP_GUIDE, 2).Coroutine(); }); } else { if (skipGuide == 2 && LauncherConfig.netType == EnumNetType.LOCAL) GameGlobal.skipGuide = true; EnterGame(); } } public static void QuitToLoginView(bool logout) { GameGlobal.isVisitor = false; GameGlobal.antiAddiction = true; GameGlobal.userId = 0; GameGlobal.userAge = 0; GameGlobal.skipGuide = false; if(GameGlobal.myUnit != null) { GameGlobal.myUnit.Dispose(); GameGlobal.myUnit = null; } RoleDataHandler.StopUpdate(); CardDataManager.Clear(); DecomposeDataManager.Instance.Clear(); PhotographDataManager.Instance.Clear(); SkillDataManager.Instance.Clear(); SuitFosterDataManager.Instance.Clear(); StudioDataManager.Instance.Clear(); StorageDataManager.Instance.Clear(); RechargeDataManager.Instance.Clear(); GameGlobal.zoneScene.GetComponent()?.Disconnect(); GameGlobal.zoneScene.GetComponent()?.ServerInfoList?.Clear(); if (logout) { Logout(); } ViewManager.Show(null, null, true); if (logout) { ViewManager.Show(); } LoginController.Logout(); } //注销 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(); // LoadingView.Instance.Close(); GameGlobal.isEnterGame = true; if (MainStoryDataManager.CheckOpenMainUI() || GameGlobal.skipGuide) { ViewManager.Show(ViewName.MAINUI_VIEW); } else { MainStoryDataManager.currentChapterCfgId = 10001; if (GameGlobal.isFirstEntry == true) { GameGlobal.isFirstEntry = false; StoryController.ShowPriorStoryDialog(); } else { ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, MainStoryDataManager.currentChapterCfgId, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW }); } } Timers.inst.Add(1f, 1, AfterEnterGame); } private static async void AfterEnterGame(object param) { ItemHelper.GetItemAttributeInfos().Coroutine(); SuitFosterProxy.SendGetSuitInfos().Coroutine(); MainStorySProxy.GetStoryInfos().Coroutine(); CardSProxy.GetCardInfos().Coroutine(); RechargeSProxy.ReqRechargeInfo().Coroutine(); RechargeSProxy.ReqRequestGiftBagInfo().Coroutine(); RechargeSProxy.ReqExchangeInfo().Coroutine(); DailyTaskSProxy.ReqDailyTaskInfos().Coroutine(); ActivitySProxy.ReqDailyLoginInfos().Coroutine(); NoticeSProxy.ReqSystemNoticeList().Coroutine(); StudioSProxy.ReqStudioInfos().Coroutine(); MailSProxy.ReqMailCount().Coroutine(); EquipDataCache.cacher.autoPlay = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY) <= 0 ? false : true; EquipDataCache.cacher.fightSpeed = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY_SPEED) <= 1 ? 1 : StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY_SPEED); GameGlobal.skipCheckOpen = StorageDataManager.Instance.GetStorageValue(ConstStorageId.SKIP_CHECK_OPEN) <= 0 ? false : true; bool result = await FieldSProxy.ReqFieldInstanceInfos(); if (result && FieldDataManager.Instance.fieldInfos.hasBonus) { bool result1 = await FieldSProxy.ReqFieldInstanceResult(); if (result1) { ViewManager.Show(); } } } } }