Пример #1
0
        /// <summary>
        /// 状态开始
        /// </summary>
        /// <param name="currStateName"></param>
        /// <param name="nextStateName"></param>
        public void OnBeginStateEnter(string currStateName, string nextStateName)
        {
            _loadLevelExceptionCount = 0;
            CreateDynamicManager();

            GameStateConf _stateConf = GameStateConf.GetInstance();

            if (null == _stateConf)
            {
                this.Error("OnBeginStateEnter()::The game state conf is invalid!!!");
                return;
            }

            GameStateInfo _nextStateInfo = Array.Find(
                _stateConf.States.ToArray(), c => c.Name == nextStateName);

            if (null != _nextStateInfo)
            {
                List <string> _managerNames = _nextStateInfo.Managers;
                if ((null != _managerNames) && (0 < _managerNames.Count))
                {
                    try
                    {
                        AddDynamicManager(_managerNames.ToArray());
                    }
                    catch (Exception e)
                    {
                        ShowExceptionPopup(e, _evtOnExceptionPopupConfirm, "AddDynamicManager");
                    }
                }
            }

            for (int i = 0; i < _constManagers.Count; i++)
            {
                IManagerBase manager = _constManagers[i];
                try
                {
                    manager.OnBeginStateEnter(currStateName, nextStateName);
                }
                catch (Exception e)
                {
                    ShowExceptionPopup(e, _evtOnExceptionPopupConfirm, manager.GetType().Name);
                }
            }

            for (int i = 0; i < _dynamicManagers.Count; i++)
            {
                IManagerBase mgr = _dynamicManagers[i];
                try
                {
                    mgr.OnBeginStateEnter(currStateName, nextStateName);
                }
                catch (Exception e)
                {
                    ShowExceptionPopup(e, _evtOnExceptionPopupConfirm, mgr.GetType().Name);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 状态结束
 /// </summary>
 /// <param name="currStateName"></param>
 /// <param name="nextStateName"></param>
 public void OnEndStateExit(string currStateName, string nextStateName)
 {
     _loadLevelExceptionCount = 0;
     for (int i = 0; i < _constManagers.Count; i++)
     {
         IManagerBase mamager = _constManagers[i];
         try
         {
             mamager.OnEndStateExit(currStateName, nextStateName);
         }
         catch (Exception e)
         {
             ShowExceptionPopup(e, _evtOnExceptionPopupConfirm, mamager.GetType().Name);
         }
     }
     DestroyDynamicManager();
     Facade.Facade.Instance.ClearAll();
 }