/// <summary> /// Allows user to define the number of players and the number of rounds /// Creates the players whether it be as AI or Player controlled as determined by the player /// Author Greyden Scott & Sean O'Connell October 2017 /// Written, edited and tested by both team members /// </summary> private void setupGame_Click(object sender, EventArgs e) { Opponent[] players = new Opponent[(int)playerNumUpDown.Value]; numOfPlayers = (int)playerNumUpDown.Value; numOfRounds = (int)roundsNumUpDown.Value; Gameplay game = new Gameplay(numOfPlayers, numOfRounds); for (int i = 1; i <= numOfPlayers; i++) { SetupPlayer form = new SetupPlayer(); //Give the new form the Correct Values form.BackColor = Gameplay.GetColour(i); form.Text = "Setup Player #" + i; form.playNumName = "Player # " + i + " Name:"; form.textBoxName = "Player " + i; form.whichPlayer = i - 1; form.playersArray = players; form.SetupGamePlay(); form.ShowDialog(); //Return Values and Create player players = form.playersArray; game.CreatePlayer(i, players[i - 1]); } game.BeginGame(); Close(); }
private void newGameButton_Click(object sender, EventArgs e) { Gameplay game = new Gameplay(2, 1); Opponent player1 = new Human("Player 1", Chassis.GetTank(1), Gameplay.GetColour(1)); Opponent player2 = new Human("Player 2", Chassis.GetTank(1), Gameplay.GetColour(2)); game.RegisterPlayer(1, player1); game.RegisterPlayer(2, player2); game.CommenceGame(); }
/// <summary> /// Changes the players in the array playersArray so that they are either playercontrolled or AIControlled /// Checks the AI or Human button checked with playerNameBox /// Author Greyden Scott & Sean O'Connell October 2017 /// Written, edited and tested by both team members /// </summary> private void nextPlayerButton_Click_1(object sender, EventArgs e) { if (AIRButton.Checked) { //Create player with AIController playersArray[whichPlayer] = new AIPlayer(playerNameBox.Text, TankModel.GetTank(1), Gameplay.GetColour(whichPlayer + 1)); } else { //Create player with PlayerController playersArray[whichPlayer] = new PlayerController(playerNameBox.Text, TankModel.GetTank(1), Gameplay.GetColour(whichPlayer + 1)); } this.Close(); }