/// <summary> /// Newly-created method used to update form elemtns to reflect who the current player is. It involves /// a number of things like changing the colours, angles, power, round number etc. /// /// Author John Santias and Hoang Nguyen October 2017 /// </summary> private void NewTurn() { currentControlledTank = currentGame.GetCurrentGameplayTank(); currentOpponent = currentControlledTank.GetPlayerNumber(); Text = "Tank Battle - Round " + currentGame.GetRound() + " of " + currentGame.GetTotalRounds(); controlPanel.BackColor = currentOpponent.GetColour(); playerLabel.Text = currentOpponent.Name(); currentControlledTank.SetAimingAngle(angleSet); currentControlledTank.SetPower(powerSet); windSpeed = currentGame.GetWindSpeed(); if (windSpeed > 0) { windStatusLabel.Text = windSpeed + " E"; } else if (windSpeed < 0) { windStatusLabel.Text = -windSpeed + " W"; } weaponComboBox.Items.Clear(); currentTankModel = currentControlledTank.GetTank(); string[] weapons = currentTankModel.WeaponList(); for (int i = 0; i < weapons.Length; i++) { weaponComboBox.Items.Add(weapons[i]); } weaponSet = currentControlledTank.GetWeaponIndex(); SetWeaponIndex(weaponSet); currentOpponent.BeginTurn(this, currentGame); }
/// <summary> /// This method is used to update form elements to reflect who the current player is. /// </summary> private void NewTurn() { currentTank = currentGame.GetCurrentPlayerTank(); Opponent opponentTank = currentTank.GetPlayer(); Text = String.Format("Tank Battle - Round {0} of {1}", currentGame.GetRoundNumber(), currentGame.GetMaxRounds()); BackColor = opponentTank.GetColour(); playerNameLabel.Text = opponentTank.Identifier(); SetAngle(currentTank.GetTankAngle()); SetPower(currentTank.GetCurrentPower()); int currentWind = currentGame.GetWindSpeed(); if (currentWind > 0) { currWindLabel.Text = String.Format("{0} E", currentWind); } else { currentWind = currentWind * -1; currWindLabel.Text = String.Format("{0} W", currentWind); } weaponComboBox.Items.Clear(); TankModel currentTankModel = currentTank.GetTank(); foreach (String weapon in currentTankModel.WeaponList()) { weaponComboBox.Items.Add(weapon); } SetWeapon(weaponComboBox.SelectedIndex); opponentTank.NewTurn(this, currentGame); controlPanel.BackColor = opponentTank.GetColour(); }