【发布时间】:2012-11-02 02:28:28
【问题描述】:
我在大学的任务是使用 c# 创建一个吟游诗人游戏。
有 2-4 名玩家,每个玩家轮流掷骰子。目标是到达网格上的最后一个方格。
与这个问题唯一相关的规则是,同一方格中不能有超过一个玩家。
例如
两名球员都从位置 0 开始。
玩家 (A) 在方格 1 掷出 1 = 玩家(A)。 玩家 (B) 掷出 1 = 玩家(B) “跳过”玩家 (A) 并降落在第 2 格。
我省略了掷骰子方法,据我所知,主要的方法与问题无关。
private static void PlayerTurn(int playerNo)
{
playerPositions[playerNo] = playerPositions[playerNo] + RollDice();
// The selected player rolls the dice and moves x amount of squares
//(dependant on dice roll value)
}
这就是移动每个玩家的方法。
我正在努力的是以下方法。
static bool RocketInSquare(int squareNo)
{
//TODO: write a method that checks through the
//rocket positions and returns true if there is a rocket in the given square
}
该方法需要检查数组中的冲突。因此,如果玩家 (A) 在第一轮投出 1,而玩家 (B) 在第一轮投出 1,我需要让玩家 (B) '跳跃式' 玩家 (A) 进入方格 2。
如果有帮助的话,目前游戏只是在控制台中运行。很抱歉这个问题的格式,以前从未在这里问过。
非常感谢
【问题讨论】: