Пример #1
0
        /// <summary>
        /// Performs a robot movement.
        /// </summary>
        /// <param name="position">Position of the robot before the action.</param>
        /// <param name="board">Board to perform action on.</param>
        /// <returns>Position of robot after performing the action.</returns>
        public override RoboPosition PerformAction(RoboPosition position, RoboBoard board)
        {
            RoboField field = board.GetField(position);

            if (!field.CanLeave(this.Direction))
            {
                return(position);
            }

            RoboPosition result = PerformAction(position);

            RoboField neighbor = board.GetField(result);

            if (neighbor == null || !neighbor.CanEnter(RoboRotation.Rotate(this.Direction, Rotation.Around)))
            {
                return(position);
            }

            return(result);
        }
Пример #2
0
        public static RoboPosition PerformAction(RoboBoard board, ActionPhase actionPhase, RoboAction action, RoboPosition position)
        {
            if (action == null)
            {
                return(position);
            }

            position.Assign(action.PerformAction(position, board));
            position.Assign(PerformAction(board, actionPhase, board.GetField(position).OnRobotAction(actionPhase, action, position), position));
            return(position);
        }
Пример #3
0
        public static RoboPosition PlayCardCore(RoboBoard board, RoboCard card, RoboPosition position)
        {
            foreach (RoboAction action in card.GetActionList(position))
            {
                if (position.IsDead || board.GetField(position).IsDestination)
                {
                    return(position);
                }
                position.Assign(PerformAction(board, ActionPhase.ActionCard, action, position));
            }

            position.Assign(PerformAction(board, ActionPhase.ActionConveyor, RoboAction.EMPTY, position));
            position.Assign(PerformAction(board, ActionPhase.ActionPusher, RoboAction.EMPTY, position));
            position.Assign(PerformAction(board, ActionPhase.ActionRotator, RoboAction.EMPTY, position));

            return(position);
        }
Пример #4
0
        private RoboBoard GetBoard(RoboBoard original, RoboPlayer actualPlayer, IEnumerable <RoboPlayer> players)
        {
            RoboBoard board = Board.CopyBoard();

            if (Interaction == RoboPlayerInteraction.Blocked)
            {
                foreach (RoboPlayer player in players)
                {
                    if (player == actualPlayer ||
                        board.GetField(player.Position).IsDestination ||
                        player.Position.IsDead)
                    {
                        continue;
                    }

                    board.Fields[player.Position.X, player.Position.Y] =
                        RoboField.CreateField(FieldType.WallDown | FieldType.WallUp | FieldType.WallLeft | FieldType.WallRight);
                }
            }

            return(board);
        }