Пример #1
0
        private void Awake()
        {
            ReceiveMessage(HiddenObjectMessage.MsgStopGame, p =>
            {
                string info = p.Values as string;
                if (info == "True")
                {
                    _isGameStop = true;
                }
                if (info == "False")
                {
                    _isGameStop = false;
                }
            });
            ReceiveMessage(HiddenObjectMessage.MsgQuitGame, p =>
            {
                //CloseGameAndUI(false);
                // Break flow normally and loading scene
                FlowMediator.Instance.BreakFlow(true);
            });
            ReceiveMessage("MsgFaultFinish", p =>
            {
                // Break flow not normally and not loading scene
                FlowMediator.Instance.BreakFlow(false);
                CommandFunctions.IsHalt = true;
            });
            // Clear Flag
            GlobalApplication.ResetFlag();
            _isGameStop   = false;
            _canStartGame = false;

            // Clear prefabs
            if (GameObject.Find(HiddenObjectString.GameResources) != null)
            {
                Destroy(GameObject.Find(HiddenObjectString.GameResources));
            }
            if (GetComponent <PlayerStateMachine>() != null)
            {
                _playerStateMachine = GetComponent <PlayerStateMachine>();
            }
            else
            {
                Debug.LogError("No PlayerStateMachine!!!");
            }
        }
Пример #2
0
        /// <summary>
        /// Set the value of GameSetting
        /// </summary>
        void InitializeGameSettingData()
        {
            HOGGameSettingGenerator.Instance.CreateGameSetting();

            int _trainType = HOGGameSettingGenerator.Instance.GameSetting.TrainType;
            //int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.TrainType), out _trainType);
            int _gameCategory = HOGGameSettingGenerator.Instance.GameSetting.GameCategory;

            //int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.GameType), out _gameCategory);
            //int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.TrainTime), out _trainTime);

            #region GetStressValue
            int _stressValue    = 0;
            int _stressLevel    = 0;
            int _obstacleLength = 0;
            switch (_trainType)
            {
            case 2:
                int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.MaxAssist), out _stressValue);
                if (_stressValue == 100)
                {
                    _stressLevel = 1;
                }
                else if (_stressValue == 200)
                {
                    _stressLevel = 2;
                }
                else if (_stressValue == 300)
                {
                    _stressLevel = 3;
                }
                else if (_stressValue == 400)
                {
                    _stressLevel = 4;
                }
                else if (_stressValue == 500)
                {
                    _stressLevel = 5;
                }
                _trainTypeName = "Assistance";
                break;

            case 3:
                if (_gameCategory == 2)
                {
                    int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.ObstacleLength), out _obstacleLength);
                }
                int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.ActiveAssist), out _stressValue);
                if (_stressValue == 20)
                {
                    _stressLevel = 1;
                }
                else if (_stressValue == 35)
                {
                    _stressLevel = 2;
                }
                else if (_stressValue == 40)
                {
                    _stressLevel = 3;
                }
                else if (_stressValue == 55)
                {
                    _stressLevel = 4;
                }
                else if (_stressValue == 70)
                {
                    _stressLevel = 5;
                }
                _trainTypeName = "Active";
                break;

            case 4:
                if (_gameCategory == 3)
                {
                    int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.Mass), out _stressValue);
                    if (_stressValue == 60000)
                    {
                        _stressLevel = 1;
                    }
                    else if (_stressValue == 46000)
                    {
                        _stressLevel = 2;
                    }
                    else if (_stressValue == 34000)
                    {
                        _stressLevel = 3;
                    }
                    else if (_stressValue == 22000)
                    {
                        _stressLevel = 4;
                    }
                    else if (_stressValue == 10000)
                    {
                        _stressLevel = 5;
                    }
                    _trainTypeName = "Mass";
                }
                if (_gameCategory == 1)
                {
                    int.TryParse(GameSettingMgr.GetInstance().ShowValue(HiddenObjectKey.ResistiveAssist), out _stressValue);
                    if (_stressValue == 50)
                    {
                        _stressLevel = 1;
                    }
                    else if (_stressValue == 100)
                    {
                        _stressLevel = 2;
                    }
                    else if (_stressValue == 150)
                    {
                        _stressLevel = 3;
                    }
                    else if (_stressValue == 200)
                    {
                        _stressLevel = 4;
                    }
                    else if (_stressValue == 250)
                    {
                        _stressLevel = 5;
                    }
                    _trainTypeName = "Resistance";
                }
                break;

            default:
                break;
            }
            #endregion

            #region GetScoreDependOnStress
            string levelName = "Level" + _stressLevel;
            _minTargetScore = GlobalApplication.GetDataFromPropExpJson(_trainTypeName, levelName, "Min");
            _maxTargetScore = GlobalApplication.GetDataFromPropExpJson(_trainTypeName, levelName, "Max");
            #endregion

            #region SetRecorder
            _currentGameRecorder = new InGameRecord(_trainType);
            _currentGameRecorder.GameCategory   = _gameCategory;
            _currentGameRecorder.StressValue    = _stressValue;
            _currentGameRecorder.StressLevel    = _stressLevel;
            _currentGameRecorder.ObstacleLength = _obstacleLength;
            // Get level and exp.
            int playerLevel = 0;
            int.TryParse(PatientinfoMgr.GetInstance().ShowValue(HiddenObjectKey.Level), out playerLevel);
            _currentGameRecorder.PlayerLevel = playerLevel;
            int playerExp = 0;
            int.TryParse(PatientinfoMgr.GetInstance().ShowValue(HiddenObjectKey.Exp), out playerExp);
            _currentGameRecorder.PlayerExp = playerExp;
            _currentGameRecorder.GameLevel = 1;
            _currentGameRecorder.Score     = 0;
            _currentGameRecorder.LostTime  = 0;
            #endregion

            GetNextLevelExp(playerLevel);

            // Get Victory Message
            _victoryMessage = LanguageMgr.GetInstance().ShowText(HiddenObjectKey.VictoryMessage).Split('#');

            // Get TimeUp Message
            _timeUpMessage = LanguageMgr.GetInstance().ShowText(HiddenObjectKey.TimeUpMessage);

            // Get Target String
            _targetString = LanguageMgr.GetInstance().ShowText(HiddenObjectKey.TargetString);

            // Get Reward String
            _rewardString = LanguageMgr.GetInstance().ShowText(HiddenObjectKey.RandomReward);

            // Get TopBarTipMessage
            _topBarTipMessage = LanguageMgr.GetInstance().ShowText(HiddenObjectKey.TopBarTipMessage);
        }