Пример #1
0
        public StatesTypes NextMove()
        {
            // Find next move from current state and input
            StatesTypes nextMove = _currentState.NextAction();

            // Find next state from current state and input
            _currentState = _currentState.NextState();

            return(nextMove);
        }
Пример #2
0
        public bool DoNextMove(StatesTypes move)
        {
            bool inside = true;

            switch (move)
            {
            //TODO Alter so it changes an ACreature objects Tile values instead

            case StatesTypes.NORTH:
                _headrow--;
                break;

            case StatesTypes.SOUTH:
                _headrow++;
                break;

            case StatesTypes.EAST:
                _headcol++;
                break;

            case StatesTypes.WEST:
                _headcol--;
                break;
            }

            //TODO Alter somehow
            // check if snake is moving outside playground
            if (_headrow == maxHeight || _headrow == -1 ||
                _headcol == maxWidth || _headcol == -1)
            {
                inside = false; // snake is outside playground
            }
            else
            {
                PrintPlayground(); // snake still inside
            }

            return(inside);
        }