using LitJson; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System; using System.Xml; using System.Collections; using System.Collections.Generic; using System.Linq.Expressions; public class LogoSceneLabel { public static string DebugText = "DebugText"; public static string ManagerGame = "ManagerGame"; } public class Initializer : MonoBehaviour { #region Config //public Texture2D Texture2D; public bool AuditEdition; public bool DebugMode; public bool CatchException; public GameObject DebugModeGo; public static bool Inited; public static string InitScriptProgress; public static Text DebugText; public static Initializer Instance; public static List RegistList = new List(); #endregion private void Awake() { if (CatchException) { try { InitDataEye(); } catch (Exception) { } } else { InitDataEye(); } if (CatchException) { try { InitScript(); } catch (Exception e) { Text debugText = GameObject.Find(LogoSceneLabel.DebugText).GetComponent(); debugText.SetAlpha(1); debugText.text = InitScriptProgress + "\n" + e; throw new Exception(); } } else { InitScript(); } } private void InitDataEye() { if (Application.platform == RuntimePlatform.IPhonePlayer) { DataEyeGA.Init("C5790DBD2CFE97BD18C7BE9A95482C05", DataEyeGA.PlatformType.IOS, "Official", "IOS"); } else if (Application.isMobilePlatform) { DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.ADR, "Official", "Android"); } else if (Application.isEditor) { DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.WP, "Official", "Windows"); } } private void InitScript() { int index = 1; InitScriptProgress = index++.ToString(); Application.targetFrameRate = 50; InitScriptProgress = index++.ToString(); DontDestroyOnLoad(gameObject); InitScriptProgress = index++.ToString(); HttpManager.Login(Manager.FirstTimeLoginCallback); InitScriptProgress = index++.ToString(); HttpManager.GetMailAwardData(); InitScriptProgress = index++.ToString(); HttpManager.GetRankData(); InitScriptProgress = index++.ToString(); HttpManager.GetAlipayFlag(); InitScriptProgress = index++.ToString(); HttpManager.GetAnnounceData(); Instance = this; InitScriptProgress = index++.ToString(); if (DebugMode) { Instantiate(DebugModeGo, transform); } else { gameObject.AddComponent(); } InitScriptProgress = index++.ToString(); gameObject.AddComponent(); InitScriptProgress = index++.ToString(); gameObject.AddComponent(); InitScriptProgress = index++.ToString(); gameObject.AddComponent(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); gameObject.AddScript(); InitScriptProgress = index++.ToString(); StartCoroutine(WaitToInit()); } public static void InitEntrance() { if (Instance.CatchException) { DebugManager.TryCatch(Init, EnableDebugLab); } else { Init(); } } public static void Init() { DebugText = GameObject.Find(CanvasLabel.U_DebugLab).GetComponent(); DebugText.text = "Error code : 1"; TutorialManager.NewplayerTutorial = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.NewplayerTutorial); DebugText.text = "Error code : 1-1"; TutorialManager.memoryMinigameTutorial = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.MemoryMinigameTutorial); DebugText.text = "Error code : 1-2"; TutorialManager.visitTutorial = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.VisitTutorial); DebugText.text = "Error code : 1-3"; TutorialManager.dressroomTutorial = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.DressroomTutorial); DebugText.text = "Error code : 1-4"; TutorialManager.findMinigameTutorial = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.FindMinigameTutorial); DebugText.text = "Error code : 1-5"; TutorialManager.plazaRoomTutorial = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.TutorialPlazaRoom); DebugText.text = "Error code : 1-5-1"; TutorialManager.NewplayerTutorialIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.NewplayerTutorialIndex); DebugText.text = "Error code : 1-6"; TutorialManager.MemoryMinigameTutorialIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.MemoryMinigameTutorialIndex); DebugText.text = "Error code : 1-7"; TutorialManager.VisitTutorialIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.VisitTutorialIndex); DebugText.text = "Error code : 1-8"; TutorialManager.DressroomTutorialIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.DressroomIndex); DebugText.text = "Error code : 1-9"; TutorialManager.FindMinigameTutorialIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.FindMinigameTutorialIndex); DebugText.text = "Error code : 1-10"; TutorialManager.PlazaRoomTutorialIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.TutorialIndexPlazaRoom); DebugText.text = "Error code : 1-10-1"; Bundle.LoadAtlasSprites(); DebugText.text = "Error code : 1-11"; for (int i = 0; i < RegistList.Count; i++) { DebugText.text = "Error code : 1-12-" + i; //Debug.Log(i + " " + RegistList[i].GetType()); RegistList[i].InstantiatePrefabs(); } DebugText.text = "Error code : 2"; for (int i = 0; i < RegistList.Count; i++) { DebugText.text = "Error code : 2-" + i; RegistList[i].RegistReference(); } DebugText.text = "Error code : 3"; for (int i = 0; i < RegistList.Count; i++) { DebugText.text = "Error code : 3-" + i; RegistList[i].FirstInit(); } DebugText.text = "Error code : 4"; for (int i = 0; i < RegistList.Count; i++) { DebugText.text = "Error code : 4-" + i; RegistList[i].SecondInit(); } DebugText.text = "Error code : 5"; for (int i = 0; i < RegistList.Count; i++) { DebugText.text = "Error code : 5-" + i; RegistList[i].ThirdInit(); RegistList[i].enabled = true; } DebugText.text = "Error code : 6"; Inited = true; if (HttpManager.IsAnnounceReady) { ResourceManager.SetActive(CanvasLabel.C_NotifyParent, true); ResourceManager.Get(CanvasLabel.C_Notify).TweenForCG(); } DebugText.text = "Error code : 7"; PlayerManager.InitDressRoom(); DebugText.text = "Error code : 8"; Manager.FirstTimeLoginCallback(new JsonData()); //debugLab.text = "Error code : 9"; //SFSManager.GardenSmartFox.Connector.Connect(); DebugText.text = "Error code : 10"; StringFilter.Init(); DebugText.text = "Error code : 11"; IAPManager.Init(); DebugText.text = "Error code : 12"; VisitManager.Init(); DebugText.text = "Error code : 13"; SocialManager.InitRankPanel(); if (Instance.DebugMode) { ActivateGame(); } else { ShowLoadingPanel(); } } public IEnumerator WaitToInit() { while (!Logo.Complete) { yield return null; } while (!Bundle.Complete) { yield return null; } while (ConfigManager.PlayerDocumentDamageFlag) { yield return null; } InitEntrance(); } private static float LoadingDelayTime = 3f; private static void ShowLoadingPanel() { ResourceManager.Get(CanvasLabel.U_Group).TweenForCG(); ResourceManager.Get(CanvasLabel.C_Main).alpha = 0; ResourceManager.SetText(CanvasLabel.U_Lab, Language.GetStr(LanguageLabel.UI__U_Lab)); Auxiliary.Instance.DelayCall(ActivateGame, LoadingDelayTime); } public static void SetWarningTitleAndText() { SystemLanguage language = Application.systemLanguage; if (Instance.AuditEdition) { language = SystemLanguage.ChineseSimplified; } ResourceManager.SetText(CanvasLabel.U_WarningTitle, Language.GetStr(LanguageLabel.UI__U_WarningTitle, language)); if (language == SystemLanguage.ChineseSimplified) { ResourceManager.SetText(CanvasLabel.U_WarningText, Language.GetStr(LanguageLabel.UI__U_WarningText, language)); } else if (language == SystemLanguage.ChineseTraditional) { ResourceManager.SetActive(CanvasLabel.U_WarningText, false); } else { ResourceManager.SetActive(CanvasLabel.U_WarningText, false); } } private static void ActivateGame() { ResourceManager.Get(CanvasLabel.U_LoadingPanel).TweenForCG(); ResourceManager.Get(CanvasLabel.C_Main).alpha = 1; AudioManager.GardenThemeAudio.TweenForAudio(); } public static void EnableDebugLab() { ResourceManager.Get(CanvasLabel.U_Group).alpha = 0; ResourceManager.Get(CanvasLabel.U_DebugLab).enabled = true; } }