//public Opponent[] players; private void nextPlayerButton_Click(object sender, EventArgs e) { //setupGame = new SetupGameForm(); //playerAmount = setupGame.getPlayerAmount(); //roundAmount = setupGame.getRoundAmount(); //game = new Gameplay(playerAmount, roundAmount); //players = new Opponent[setupGame.playerAmount]; //for (int i = 0; i < players.Length; i++) { // players[i] = new HumanOpponent("Player " + i, TankModel.GetTank(1), Gameplay.GetTankColour(1)); //} //for (int i = 0; i < players.Length; i++) { // game.SetPlayer(i + 1, players[i]); //} game = new Gameplay(2, 1); Opponent player1 = new HumanOpponent("Player 1", TankModel.GetTank(1), Gameplay.GetTankColour(1)); Opponent player2 = new HumanOpponent("Player 2", TankModel.GetTank(1), Gameplay.GetTankColour(2)); game.SetPlayer(1, player1); game.SetPlayer(2, player2); game.NewGame(); }
/// <summary> /// /// When this button is pressed, the next player can select their /// name, tank and controller. When all players have selected their loadouts /// the game will begin. /// /// Author John Santias and Hoang Nguyen October 2017 /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void nextPlayerButton_Click(object sender, EventArgs e) { playerNames.Add(playerNameInput.Text); if (humanRadioButton.Checked) { humans[player - 1] = "human"; } else if (aiRadioButton.Checked) { AIs[player - 1] = "Ai"; } // If not all players have not assign player name, tank types and controller if (player != playerAmount) { player++; PlayerLabel.Text = "Player #" + player + "'s name:"; playerNameInput.Text = "Player " + player; BackColor = Gameplay.GetTankColour(player); // If all players have put in their details, game starts } else if (player == playerAmount) { Gameplay game = new Gameplay(playerAmount, roundAmount); //create human players for (int i = 0; i < playerAmount; i++) { if (humans[i] == "human") { Opponent a = new HumanOpponent(playerNames[i], TankModel.GetTank(1), Gameplay.GetTankColour(i + 1)); game.SetPlayer(i + 1, a); } else if (AIs[i] == "Ai") { Opponent a = new AIOpponent(playerNames[i], TankModel.GetTank(1), Gameplay.GetTankColour(i + 1)); game.SetPlayer(i + 1, a); } } game.NewGame(); Close(); } }