Пример #1
0
        private bool AddStartingState(GameStateBase startingState)
        {
            foreach (var gameState in _gameStates)
            {
                if (gameState.Type == startingState.Type)
                {
                    return(false);
                }
            }

            _gameStates.Add(startingState);
            CurrentState = startingState;
            CurrentState.Activate();
            return(true);
        }
Пример #2
0
        public bool ChangeState(GameStateType targetState)
        {
            if (!CurrentState.IsValidTargetState(targetState))
            {
                return(false);
            }

            GameStateBase nextState = GetStateByType(targetState);

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

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

            return(true);
        }