示例#1
0
 public void Rotate(Robot robot)
 {
     if (Direction == Rotation.Clockwise)
         robot.RotateRight();
     else
         robot.RotateLeft();
 }
示例#2
0
        public void Convey(Robot robot)
        {
            // Convey the robot a single square
            Coordinate target = robot.Position;

            if (Exit == Orientation.Bottom)
                target.Y += 1;
            else if (Exit == Orientation.Top)
                target.Y -= 1;
            else if (Exit == Orientation.Left)
                target.X -= 1;
            else
                target.X += 1;

            ITile targetTile = robot.Game.Board.GetTile(target);
            if (targetTile == null || targetTile is Pit)
            {
                // Robot conveyed off the board or into a pit
                robot.Position = new Coordinate {X = -1, Y = -1};
                return;
            }

            var conveyer = targetTile as Conveyer;
            if (conveyer != null)
            {
                Rotation rotation = conveyer.ConveyerRotation(Utilities.GetOppositeOrientation(Exit));
                if (rotation == Rotation.Clockwise)
                    robot.RotateRight();
                else if (rotation == Rotation.CounterClockwise)
                    robot.RotateLeft();
            }

            robot.Position = target;
        }