Esempio n. 1
0
        private static bool AddStartingState(GameStateBase startingState)
        {
            foreach (GameStateBase state in _gameStates)
            {
                if (state.StateType == startingState.StateType)
                {
                    return(false);
                }
            }

            _gameStates.Add(startingState);
            CurrentState = startingState;
            CurrentState.Activate();
            return(true);
        }
Esempio n. 2
0
        public static bool PerformTransition(GameStateType targetStateType)
        {
            if (!CurrentState.IsValidTargetState(targetStateType))
            {
                return(false);
            }

            GameStateBase state = GetStateByType(targetStateType);

            if (state == null)
            {
                return(false);
            }

            CurrentState.Deactivate();
            CurrentState = state;
            CurrentState.Activate();

            return(true);
        }
Esempio n. 3
0
        public static bool PerformTransition(GameStateType targetStateType)
        {
            if (CurrentState.IsValidTargetState(targetStateType) == false)
            {
                Debug.Log(CurrentState);
                Debug.Log(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);

                return(false);
            }

            GameStateBase state = GetStateByType(targetStateType);

            if (state == null)
            {
                return(false);
            }

            CurrentState.Deactivate();
            CurrentState = state;
            CurrentState.Activate();

            return(true);
        }