This scirpt handles all logic associated with loading levels and displaying loading screens. Created by Simon Jonasson
Inheritance: MonoBehaviour
Exemple #1
0
    private void Awake()
    {
#if !UNITY_EDITOR
        try
        {
#endif

        Instance = this;
        var res = ResourceManager.PrepareResourceSync <GameObject>("UI/LoadingWindow");
        LoadingRoot      = Instantiate(res) as GameObject;
        LoadingRoot.name = res.name;
        //LoadingRoot.transform.parent = UIManager.Instance.GetUIRoot(UIType.TYPE_BASE);
        LoadingRoot.transform.parent        = UIManager.Instance.UIRoot.transform;
        LoadingRoot.transform.localPosition = new Vector3(0, 0, -3000);
        LoadingRoot.transform.localScale    = Vector3.one;
        LoadingRoot.transform.rotation      = Quaternion.identity;

        EventDispatcher.Instance.DispatchEvent(new LoadingPercentEvent(0.1f));
#if !UNITY_EDITOR
    }
    catch (Exception ex)
    {
        Logger.Error(ex.ToString());
    }
#endif
    }
Exemple #2
0
        private void ClearLightMap(List <LevelInfo> levelInfos)
        {
            LoadingLogic.AddCustomProgress(10, "ClearLightMap.Begin");
            //将之前还在内存里的释放掉
            List <enZoneType> clearList = new List <enZoneType>();

            foreach (enZoneType zoneType in m_LightmapDataDic.Keys)
            {
                LevelInfo info = levelInfos.Find(p => p.v_ZoneType == zoneType);

                if (info == null)
                {
                    clearList.Add(zoneType);
                }
            }

            for (int i = 0; i < clearList.Count; i++)
            {
                Resources.UnloadAsset(m_LightmapDataDic[clearList[i]].lightmapColor);
                m_LightmapDataDic.Remove(clearList[i]);
            }

            #region 登陆游戏在主城时,此处结束loading
            if (_isEnterMainView)
            {
                _isEnterMainView = false;
                UIStack.Instance.HideLoadingScreen();
            }
            #endregion
        }
Exemple #3
0
        IEnumerator OnInitSceneSucced(SceneRootEntry sceneRoot)
        {
            LoadingLogic.AddCustomProgress(5);
            if (m_SceneRootEntry != null)
            {
                m_SceneRootEntry.ShowLevel();
            }
            SetShadowQuality(sceneRoot);
            SetLayerMask(sceneRoot);
            sceneRoot.SetZonesTag();
            sceneRoot.SetMainLight();
            LoadingLogic.AddCustomProgress(15);
            PSPoolManager.Instance.LoadStandardMainlandFX();
            yield return(new WaitUntil(() =>
            {
                LoadingLogic.AddCustomProgress(1);
                return HudLoadManager.Completed;
            }));

            GlobalMenuManager.PopCaches();
            MainLandLogic.GetInstance().FreshMapName();
            MainLandLogic.GetInstance().OnSceneViewLoaded();
            MainLandLogic.GetInstance().RobDartFight();
            GameEngine.Instance.IsRunFromEnterGameBtn = false;
            LoadingLogic.AddCustomProgress(5);
        }
Exemple #4
0
        public override IEnumerator Start()
        {
            if (!UIStack.Instance.IsLoadingScreenUp)
            {
                UIStack.Instance.ShowLoadingScreen(null, true, false);
            }
            if (m_FlowControlObject == null)
            {
                LoadingLogic.AddCustomProgress(2);
                string path = "Assets/_GameAssets/Res/MISC/GameFlowControl/GameFlowControl";
                EB.Assets.LoadAsync(path, typeof(GameObject), o =>
                {
                    if (o != null)
                    {
                        var go = GameObject.Instantiate(o) as GameObject;
                        DownloadComplete(path, go);
                    }
                });

                while (m_FlowControlObject == null)
                {
                    yield return(null);
                }
            }

            ChatController.instance.Init();

            SparxHub.Instance.PushManager.OnScheduleLocalNotification += ScheduleLocalNotification;
            SparxHub.Instance.ChatManager.OnConnected += RegisterChatChannels;
        }
Exemple #5
0
        private IEnumerator WaitForReady()
        {
            DateTime t = DateTime.Now;

            EB.Debug.Log("WaitForReady=====>_{0}", t.ToString("yyyy-MM-dd hh:mm:ss fff"));
            while (!HudLoadManager.IsReady)
            {
                if (!HudLoadManager.IsLoadingConfig)
                {
                    HudLoadManager.LoadConfigAsync();
                }
                yield return(null);
            }
            LoadingLogic.AddCustomProgress(5);
            while (!SceneLoadManager.IsReady)
            {
                if (!SceneLoadManager.IsLoadingConfig)
                {
                    SceneLoadManager.LoadConfigAsync();
                }
                yield return(null);
            }
            LoadingLogic.AddCustomProgress(5);

            Mgr.SetGameState <GameStateLoadGame>();

            t = DateTime.Now;
            EB.Debug.Log("<=====WaitForReady_{0}", t.ToString("yyyy-MM-dd hh:mm:ss fff"));
        }
Exemple #6
0
 public override void OnEnter()
 {
     LegionLogic.GetInstance();
     GuideManager.Instance.InitGuideState();//tOdo为什么删掉了
     //预先加载主城场景
     LoadingLogic.AddCustomProgress(2);
     SceneLoadManager.LoadOTALevelGroupAsync("MainLandView", SceneLoadBegin, SceneLoadFailed, SceneLoadLoading, SceneLoadFinished);
 }
Exemple #7
0
 public override void OnEnter()
 {
     LoadingLogic.AddCustomProgress(10);
     EventManager.instance.Raise(eSimpleEventID.Combat_Enter);
     //日志记录
     GM.AssetManager.RecordLoadStart("CombatViewAction", "OnEnter");
     base.OnEnter();
     FusionAudio.PostGlobalMusicEvent("MUS_CombatView_Demo", true);
 }
Exemple #8
0
 protected override void SceneLoadFinished(SceneRootEntry sceneRoot)
 {
     LoadingLogic.AddCustomProgress(15);
     if (sceneRoot != null)
     {
         sceneRoot.ShowLevel();
     }
     SceneLogic.SceneState = SceneLogic.eSceneState.SceneLoop;
     //UIStack.Instance.HideLoadingScreen(false);
 }
Exemple #9
0
 public override void OnEnter()
 {
     LoadingLogic.AddCustomProgress(10);
     base.OnEnter();
     LTInstanceMapModel.Instance.LoadInstanceSpriteAtlas();
     FusionAudio.PostGlobalMusicEvent("MUS_FuBen", true);
     if (LTMainHudManager.Instance.GetFromFirstBattleType())
     {
         LTMainHudManager.Instance.SetsFromFirstBattleType(false);
     }
     Instance.LTInstanceConfigManager.LoadDatas();
 }
Exemple #10
0
        protected override void SceneLoadFinished(SceneRootEntry sceneRoot)
        {
            if (sceneRoot != null && sceneRoot.IsLoaded())
            {
                var themeLoadManager = sceneRoot.GetComponentInChildren <ThemeLoadManager>();

                if (themeLoadManager != null)
                {
                    LoadingLogic.AddCustomProgress(2);
                    string levelName = SceneManager.MainLandName;
                    themeLoadManager.LoadOTALevelAsync(levelName, levelName + ".unity.json", null, OnMainLandSceneLoadFailed, null, OnMainLandSceneLoaded);
                }
            }
        }
Exemple #11
0
        public override void OnEnter()
        {
            LoadingLogic.AddCustomProgress(10);
            hudLoaded   = false;
            sceneLoaded = false;
            PartitionObject.FlushAllAndUnload();
            base.OnEnter();
            FusionAudio.PostGlobalMusicEvent("MUS_CampaignView_Demo", true);

            Hotfix_LT.Messenger.AddListener <EnemyController, eBattleType>("AttackEnemyImediatly", AttackEnemyImediatly);
            Hotfix_LT.Messenger.Raise("LTSpeedSnatchEvent.IdleFollow");
            MainlandViewAction();

            LTWelfareModel.Instance.SetMaxCampaignLevel();//更新通关的最大章节
        }
Exemple #12
0
    // Update is called once per frame
    private void OnDestroy()
    {
#if !UNITY_EDITOR
        try
        {
#endif
        GameObject.Destroy(LoadingRoot);
        Instance = null;
#if !UNITY_EDITOR
    }
    catch (Exception ex)
    {
        Logger.Error(ex.ToString());
    }
#endif
    }
Exemple #13
0
    // Update is called once per frame
    private void OnDestroy()
    {
#if !UNITY_EDITOR
        try
        {
#endif

        Instance = null;

#if !UNITY_EDITOR
    }
    catch (Exception ex)
    {
        Logger.Error(ex.ToString());
    }
#endif
    }
Exemple #14
0
    /// <summary>
    /// 显示loading界面
    /// </summary>
    /// <param name="onReady">回调</param>
    /// <param name="showSplash">显示loading的Label</param>
    /// <param name="showDownloading">显示下载的Label</param>
    /// <param name="showBlock">显示蒙版,防止点击</param>
    /// <param name="showUpdateAsk">显示下载请求</param>
    /// <param name="showCloud">显示云</param>
    public void ShowLoadingScreen(System.Action onReady, bool showSplash = true, bool showBlock = false, bool showCloud = false)
    {
        _ShowLoadingScreen_CounterOnce++;

        if (IsLoadingScreenUp)
        {
            EB.Debug.Log("loading界面正在显示,新的回调立即执行!");
            onReady?.Invoke();
            return;
        }

        EB.Debug.Log("loading界面开始=====>");
        FusionAudio.StopMusic();
        FusionAudio.StopAmbience();

        if (null == UIHierarchyHelper.Instance)
        {
            EB.Debug.LogWarning("ShowLoadingScreen: UIHierarchyHelper is null");
            return;
        }

        if (!UIHierarchyHelper.Instance.gameObject.activeSelf)
        {
            EB.Debug.LogWarning("ShowLoadingScreen: UIHierarchyHelper is disabled");
            return;
        }

        ClearEnstackQueue();

        IsLoadingScreenUp = true;
        RemoveTimer();

        if (_loadingScreen == null)
        {
            UIHierarchyHelper.Instance.LoadAndPlaceAsync(go =>
            {
                _loadingScreen       = go;
                _loadingScreen_logic = go.GetComponent <LoadingLogic>();
                ShowLoadingScreen_AfterFunc(showSplash, showBlock, showCloud, onReady);
            }, loadingScreenPrefabPath, UIHierarchyHelper.eUIType.None, null, true);
        }
        else
        {
            ShowLoadingScreen_AfterFunc(showSplash, showBlock, showCloud, onReady);
        }
    }
Exemple #15
0
    IEnumerator WaitForFadeout(bool fade, System.Action fn = null)
    {
        EnstackQueue();
        if (_loadingScreen != null)
        {
            EB.Debug.Log("WaitForFadeout!");
            yield return(_loadingScreen_logic.OnRemoveFromStack());

            GameObject.Destroy(_loadingScreen);
            _loadingScreen       = null;
            _loadingScreen_logic = null;
        }
        EB.Debug.Log("WaitForFadeout——Finish!");
        IsLoadingScreenUp = false;
        yield return(null);

        fn?.Invoke();
    }
Exemple #16
0
        void _PostLogin(Hashtable reqData)
        {
            LogWithTime("_PostLogin=====>");
            LoadingLogic.AddCustomProgress(5);
            _api.LoginData(reqData, delegate(string err, Hashtable data) {
                LogWithTime("_api.LoginData=====>1");
                LoadingLogic.AddCustomProgress(5);
                if (!string.IsNullOrEmpty(err))
                {
                    _LoginFailed(err);
                    return;
                }

                LogWithTime("_api.LoginData=====>2");
                Hub.Instance.DataStore.LoginDataStore.LoginData = data ?? Hub.Instance.DataStore.LoginDataStore.LoginData;

                LogWithTime("_api.LoginData=====>3");
                var user = Dot.Object("user", data, null);
                if (user == null)
                {
                    return;
                }

                LogWithTime("_api.LoginData=====>4");
                LocalUser = Hub.Instance.UserManager.GetUser(user);
                _account.Add(_user);
                BugReport.AddData("uid", _user.Id.ToString());
                Hashtable configs = EB.Dot.Object("configs", Hub.Instance.DataStore.LoginDataStore.LoginData, null);
                Hub.Instance.DataStore.LoginDataStore.LoginData.Remove("configs");
                LogWithTime("_api.LoginData=====>5");

                //从服务器拉取表,解析表
                Hub.Instance.DataCacheManager.ProcessCaches(configs, error =>
                {
                    LogWithTime("<=====ProcessCaches");
                    if (!string.IsNullOrEmpty(error))
                    {
                        _LoginFailed(error);
                        return;
                    }
                    SetState(LoginState.LoggedIn);
                }, LoadingLogic.AddCustomProgress);
            });
        }
Exemple #17
0
        protected override void SceneLoadFinished(SceneRootEntry sceneRoot)
        {
            EB.Debug.Log("MainLandViewAction.SceneLoadFinished=====>");
            LoadingLogic.AddCustomProgress(15);
            if (sceneRoot != null && sceneRoot.IsLoaded())
            {
                m_SceneRootEntry   = sceneRoot;
                m_ThemeLoadManager = sceneRoot.GetComponentInChildren <ThemeLoadManager>();

                sceneLoaded = true;
                LoadingLogic.AddCustomProgress(5);
                OnComplete();

                if (m_ThemeLoadManager != null && !string.IsNullOrEmpty(MainLandLogic.GetInstance().CurrentEnvironmentName))
                {
                    string levelName = MainLandLogic.GetInstance().CurrentEnvironmentName;
                    m_ThemeLoadManager.LoadOTALevelAsync(levelName, levelName + ".unity.json", null, OnInitSceneFailed, null, (SceneRootEntry entry) => { EB.Coroutines.Run(OnInitSceneSucced(entry)); });
                }
            }
            LoadingLogic.AddCustomProgress(5);
        }
Exemple #18
0
    private void Awake()
    {
#if !UNITY_EDITOR
        try
        {
#endif

        Instance = this;

        var res = ResourceManager.PrepareResourceSync <GameObject>("UI/LoadingRoot");
        var go  = Instantiate(res) as GameObject;
        go.name = "UIRoot";
        DontDestroyOnLoad(go);
        DestroyObj = go.GetComponentInChildren <LoadingWindow>().gameObject;

#if !UNITY_EDITOR
    }
    catch (Exception ex)
    {
        Logger.Error(ex.ToString());
    }
#endif
    }
Exemple #19
0
        protected override void SceneLoadFinished(SceneRootEntry sceneRoot)
        {
            LoadingLogic.AddCustomProgress(15);
            UIStack.Instance.ResetNextStackDepth();
            EB.Debug.Log("LoginProfile {0}", ((float)((System.DateTime.UtcNow.Ticks / 10000) % 100000) / 1000));
            if (sceneRoot != null && sceneRoot.IsLoaded())
            {
                m_SceneRootEntry   = sceneRoot;
                m_ThemeLoadManager = sceneRoot.GetComponentInChildren <ThemeLoadManager>();
                if (m_ThemeLoadManager != null)
                {
                    LoadingLogic.AddCustomProgress(5);
                    Combat_Scene_Name = GetCombatSceneName();
                    if (string.IsNullOrEmpty(Combat_Scene_Name))
                    {
                        Combat_Scene_Name = DEFAULT_COMBAT_NAME;
                    }
                    m_ThemeLoadManager.LoadOTALevelAsync(Combat_Scene_Name, Combat_Scene_Name + ".unity.json", null, InitializeSceneFailed, null, InitializeScene);
                }

                InteractableObjectManager.Instance.SetParent(sceneRoot.m_SceneRoot.transform);
            }
            LoadingLogic.AddCustomProgress(10);
        }
Exemple #20
0
        IEnumerator InitializeSceneCoroutine(SceneRootEntry sceneRoot)
        {
            LoadingLogic.AddCustomProgress(10);
            EB.Debug.Log("LoginProfile {0}", ((float)((System.DateTime.UtcNow.Ticks / 10000) % 100000) / 1000));

            if (m_SceneRootEntry != null)
            {
                m_SceneRootEntry.ShowLevel();
            }

            while (!SceneLogic.MainHeroLoadComplete)
            {
                yield return(null);
            }
            LoadingLogic.AddCustomProgress(15);
            SetShadowQuality(sceneRoot);

            while (!HudLoadManager.Completed)
            {
                yield return(null);
            }

            UI3DLobby[] lobbys = GameObjectExtension.FindMonoILRObjectsOfType <UI3DLobby>("Hotfix_LT.UI.UI3DLobby", "Hotfix_LT.UI.UI3DVsLobby");

            if (lobbys != null)
            {
                if (lobbys != null && lobbys.Length > 0)
                {
                    for (var i = 0; i < lobbys.Length; i++)
                    {
                        var lobby = lobbys[i];

                        if (lobby != null)
                        {
                            EB.Debug.LogWarning("CombatViewAction: SceneLoadFinished Clean lobby = {0} ---> gameObject name: {1}", lobby, lobby.mDMono.name);
                            GameObject.Destroy(lobby.mDMono.gameObject);
                        }
                    }
                }
            }

            LTMainHudManager.Instance.SetsFromFirstBattleType(false);

            if (SceneLogic.BattleType == eBattleType.FirstBattle)
            {
                LTMainHudManager.Instance.SetsFromFirstBattleType(true);
                UIStack.Instance.HideLoadingScreenImmediately(false, false);
            }
            else if (SceneLogic.isPVP())
            {
                UIStack.Instance.WaitForOtherPlayer();
            }
            else
            {
                //UIStack.Instance.HideLoadingScreenImmediately(false, false);
            }


            GM.AssetManager.RecordLoadEnd("CombatViewAction", "HideLoadingScreen");

            LTCombatEventReceiver.Instance?.OnCombatViewLoaded();

            MainLandLogic.GetInstance().OnCombatViewLoaded();
            EB.Debug.Log("LoginProfile {0}", ((float)((System.DateTime.UtcNow.Ticks / 10000) % 100000) / 1000));
            EB.Debug.Log("To initialize scene.");
            LoadingLogic.AddCustomProgress(5);
        }
Exemple #21
0
        /// <summary>
        /// 加载相应的区域
        /// </summary>
        /// <param name="zone">区域类型</param>
        private void LoadLevelZone(enZoneType zone)
        {
            LoadingLogic.AddCustomProgress(10, "LoadLevelZone.Begin");
            for (var i = 0; i < _coroutines.Count; i++)
            {
                if (_coroutines[i] != null)
                {
                    StopCoroutine(_coroutines[i]);
                }
            }
            _coroutines.Clear();

            LevelInfo  levelInfo                 = null;
            enZoneType tempType                  = (enZoneType)0;
            int        lightmapIndex             = 0;
            int        count                     = 0;
            Dictionary <string, enZoneType> dict = new Dictionary <string, enZoneType>();

            for (int i = 0; i <= m_LightmapStr.Count; i++)
            {
                tempType = (enZoneType)(1 << i);

                if ((zone & tempType) > 0)
                {
                    levelInfo = m_StackObj.Find(p => p.v_ZoneType == tempType);

                    if (levelInfo == null)
                    {
                        dict.Add(m_LightmapStr[tempType], tempType);

                        var c1 = EB.Assets.LoadAsync(string.Format("_GameAssets/Res/Environment/s001a/MainLevelZone/Lightmap_{0}", m_LightmapStr[tempType]), typeof(Texture2D), (obj) => {
                            var lightmapData           = new LightmapData();
                            lightmapData.lightmapColor = obj as Texture2D;
                            var key = dict[obj.name.Replace("Lightmap_", "")];

                            if (!m_LightmapDataDic.ContainsKey(key))
                            {
                                m_LightmapDataDic.Add(key, lightmapData);
                            }
                            else
                            {
                                m_LightmapDataDic[key] = lightmapData;
                            }

                            var c2 = EB.Assets.LoadAsync(string.Format("_GameAssets/Res/Environment/s001a/MainLevelZone/{0}", m_LightmapStr[key]), typeof(GameObject), (o) => {
                                var li             = new LevelInfo();
                                li.v_LevelObj      = Instantiate <GameObject>((GameObject)o);
                                li.v_ZoneType      = dict[o.name];
                                li.v_LightmapIndex = lightmapIndex;
                                m_StackObj.Add(li);
                                count++;
                                lightmapIndex++;

                                if (count > m_LightmapStr.Count)
                                {
                                    ClearZone(zone);
                                    dict.Clear();
                                }
                            });
                            _coroutines.Add(c2);
                        });
                        _coroutines.Add(c1);
                    }
                    else
                    {
                        levelInfo.v_LightmapIndex = lightmapIndex;
                        count++;
                        lightmapIndex++;

                        if (count > m_LightmapStr.Count)
                        {
                            ClearZone(zone);
                            dict.Clear();
                        }
                    }
                }
                else
                {
                    count++;

                    if (count > m_LightmapStr.Count)
                    {
                        ClearZone(zone);
                        dict.Clear();
                    }
                }
            }
        }
Exemple #22
0
        private void Update_CheckMapDataUpdate(bool isInit = false)
        {
            if (WaitOptimize || !IsPlayerReady())
            {
                return;
            }

            if (!_CheckMapDataUpdate_Dirty)
            {
                return;
            }
            if (_DelayUpdateNum > 0)
            {
                _DelayUpdateNum--;
                return;
            }
            int counterOnce = 0;

            if (PlayerObj.transform.localPosition.Equals(Vector3.zero) && LTInstanceMapModel.Instance.CurNode != null)
            {
                PlayerObj.transform.localPosition = new Vector3(PlayerObj.transform.localPosition.x, PlayerObj.transform.localPosition.y, -LTInstanceMapModel.Instance.CurNode.y * LTInstanceConfig.MAP_YZ + LTInstanceMapModel.Instance.CurNode.x * LTInstanceConfig.MAP_XZ);
            }
            //特殊初始化处理
            if (setRowObjContainerPos && LTInstanceMapModel.Instance.CurNode != null)
            {
                var end = LTInstanceMapModel.Instance.CurNode;
                RowObjContainer.transform.localPosition = new Vector3(-(end.x + end.y) * LTInstanceConfig.MAP_X, (end.y - end.x) * LTInstanceConfig.MAP_Y, 0);
                setRowObjContainerPos = false;
            }
            if (setSpecialBoob)
            {
                SetSpecialBoob();
                setSpecialBoob = false;
            }
            //

            while (_CheckMapDataUpdate_Queue.Count > 0)
            {
                var node = _CheckMapDataUpdate_Queue.Dequeue();
                //_CheckMapDataUpdate_Queue.RemoveAt(0);
                LTInstanceRowCtrl row;
                if (rowCtrlDic.TryGetValue(node.y, out row))
                {
                    row.mDMono.gameObject.CustomSetActive(true);
                    LTInstanceNodeTemp cell;
                    if (row.itemObjDic.TryGetValue(node.x, out cell))
                    {
                        if ((node.Type == LTInstanceNode.NodeType.WALL && !(cell is Instance.LTInstanceWallTemp)) || (node.Type == LTInstanceNode.NodeType.Floor && !(cell is Instance.LTInstanceFloorTemp)))//密道或格子类型发生反转的时候处理
                        {
                            GameObject.Destroy(cell.mDMono.gameObject);
                            row.itemObjDic.Remove(cell.Num);
                            row.CreateNodeFromCache(node);
                        }
                        else
                        {
                            if (!isInit && node.Type == LTInstanceNode.NodeType.WALL)
                            {
                                continue;
                            }
                            cell.mDMono.gameObject.CustomSetActive(true);
                            cell.UpdateData(node);
                            continue;
                        }
                    }
                    else
                    {
                        row.CreateNodeFromCache(node);
                    }
                }
                else
                {
                    CreateRowFromCache(node);
                }

                counterOnce++;
                if (LTInstanceMapModel.Instance.isFirstCreatFloor)
                {
                    if (counterOnce % _CheckMapDataUpdate_MaxMore == 0)
                    {
                        LoadingLogic.AddCustomProgress(1);
                        break;
                    }
                }
                else if (counterOnce % _CheckMapDataUpdate_MaxOnce == 0)
                {
                    _DelayUpdateNum = 1;
                    break;
                }
            }


            if (_CheckMapDataUpdate_Queue.Count == 0)
            {
                if (LTInstanceMapModel.Instance.isFirstCreatFloor)
                {
                    LTInstanceMapModel.Instance.isFirstCreatFloor = false;
                }
                OpenCloud();
                _CheckMapDataUpdate_Dirty = false;
            }
        }