Exemple #1
0
 public MZFlow(MZPosition pos, MZDirection dir, int length, double speed)
 {
     _position  = pos;
     _direction = dir;
     _length    = length;
     _speed     = speed;
     _isInUse   = false;
 }
Exemple #2
0
        public void move(MZDirection direction)
        {
            switch (direction)
            {
            case MZDirection.LEFT:
                _x--;
                break;

            case MZDirection.UP:
                _y++;
                break;

            case MZDirection.RIGHT:
                _x++;
                break;

            case MZDirection.DOWN:
                _y--;
                break;
            }
        }
Exemple #3
0
        public MZMoveResultCode makeStepTo(MZDirection direction)
        {
            if (_isPaused)
            {
                return(MZMoveResultCode.GAME_PAUSED);
            }

            /*
             * List<MZFlow> flowList = _maze.flowList();
             * for (int i = 0; i < flowList.Count(); i++)
             * {
             *  if (flowList[i].isInFlow(_currentPosition))
             *  {
             *      if ((direction == flowList[i].direction()) || (direction == (flowList[i].direction() + 2) % 2))
             *      {
             *          return MZMoveResultCode.MOTION_IMPOSSIBLE;
             *      }
             *  }
             * }*/

            if (!_maze.cells().cellAtPosition(_currentPosition).hasWallAtDirection(direction))
            {
                _currentPosition.move(direction);
                _stepsCount++;
                visitPosition(_currentPosition);
                if ((_maze.winningPosition().x() == _currentPosition.x()) && (_maze.winningPosition().y() == _currentPosition.y()))
                {
                    _isEnded = true;
                    return(MZMoveResultCode.GAME_ENDED);
                }
                else
                {
                    return(MZMoveResultCode.MOTION_PERFORMED);
                }
            }
            return(MZMoveResultCode.MOTION_IMPOSSIBLE);
        }
Exemple #4
0
        public bool hasWallAtDirection(MZDirection direction)
        {
            int result = (int)(_walls.value()) & (1 << (int)direction);

            return(result != 0 ? true : false);
        }
Exemple #5
0
 public MZMotion(double speed, MZDirection direction)
 {
     _speed     = speed;
     _direction = direction;
     _timesUsed = 0;
 }