0
我是新來的C#,對我的工作,我需要創建一個基於文本的遊戲添加GameTurn方法與移動所有的球員。最後一點爲它添加GameTurn方法。我需要做一個循環來移動遊戲中的每個玩家。它需要爲每個玩家調用我的PlayerTurn方法。C#需要在同一時間
我不得不努力研究這幾次,但沒有得到任何地方,如果有人可以得到一些援助,我會非常感激。
謝謝
巴蒂爾
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TacticalCheeseRacer
{
class Program
{
struct Player
{
public string Name;
public int Pos;
}
static Player[] players = new Player[4];
static int[] PlayerPositions= new int[4];
private static void GameTurn()
{
//TODO: plays a turn for all the players in the game
//TODO: stops moving players when some has won
}
private static bool PlayerTurn(int playerNo, int distance)
{
//TODO: Makes a move the given player
if (players[playerNo].Pos >= 64)//Checks if players position is below 64
{
return true;
}
if (distance > 64)
Console.WriteLine("You have won the game");//distance greater then 64, you have won
players[0].Name = "Shane";
players[0].Pos = 0;
PlayerTurn(0, 5);
return false;
}
public static void ResetGame()
{
int NumberofPlayers;
{
do
{
Console.WriteLine("Please enter number of player (1-4): ");//enter the number of players to play
string StringNumberofPlayers = Console.ReadLine();
NumberofPlayers = int.Parse(StringNumberofPlayers);
}
while (NumberofPlayers > 4 || NumberofPlayers < 2);
}
for (int i = 0; i < NumberofPlayers; i++)
{
int Name = i + 1;
players[i].Pos = 0;
Console.WriteLine("Enter your name");//enter your name at the start of game
players[i].Name = Console.ReadLine();
}
//gets the numbers of playes and sets the required elements in
//playerPositions to 0 on the board
}
static void Main()
{
ResetGame();// reset game method
}
}
}
它的作品,使一個遊戲simular蛇爬梯子,使用Windows控制檯應用程序在C sharp。目標是: 輸入名爲A,B,C和D的四名球員。 完成一個遊戲回合並將所有玩家移動到他們距離爲3的方格3上。 遊戲應報告每個玩家的新位置播放器。 通過移動每位玩家65的距離,完成遊戲回合並檢測出該玩家A獲勝(以便B,C和D未獲得回合)。 – shaneo 2014-11-23 15:39:55