/// <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(); }
/// <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 sets the ControlledTank's current aiming angle. /// /// Author John Santias and Hoang Nguyen October 2017 /// /// </summary> /// <param name="angle"> Sets the angle of the Controlled Tank </param> public void SetAimingAngle(float angle) { if (angle >= -90 && angle <= 180) { this.angle = (int)angle; } colour = tankModel.CreateBitmap(player.GetColour(), angle); }
public void AimTurret(float angle) { //Alex Holm N9918205 this.angle = angle; Color tankColour = current_player.GetColour(); current_tBMP = current_chassis.CreateTankBitmap(tankColour, angle); }
/// <summary> /// /// This constructor initializes a new instance of the ControlledTank class. /// It also stores the tankModel by usubg the Opponents GetTank() method, and /// GetArmour() for the current durability of the TankModel. In addition, it also /// stores the angle, power, current weapons and colour of the tank which is a bitmap. /// /// Author John Santias and Hoang Nguyen October 2017 /// /// </summary> /// <param name="player"> A reference of Opponent stored as player </param> /// <param name="tankX"> The x coordinate of the tank </param> /// <param name="tankY"> The y coordinate of the tank </param> /// <param name="game"> A reference of Gameplay stored as game </param> public ControlledTank(Opponent player, int tankX, int tankY, Gameplay game) { this.player = player; this.tankX = tankX; this.tankY = tankY; this.game = game; tankModel = player.GetTank(); currentDur = tankModel.GetArmour(); angle = 0; power = 25; tankWeapon = 0; colour = tankModel.CreateBitmap(player.GetColour(), angle); }
protected void NewTurn() { //<Summary> //Alex Holm N9918205 //</Summary> Debug.WriteLine("CurrentTank Get Start"); current_tank = currentGame.GetCurrentPlayerTank(); Debug.WriteLine("CurrentTank Get Finalized"); Debug.WriteLine("CurrentPlayer Get Start"); current_player = current_tank.GetPlayer(); Debug.WriteLine("CurrentTank Get Finalized"); Debug.WriteLine("CurrentForm Title Get Start"); string Title = ("Tank Battle - Round " + currentGame.CurrentRound() + " of " + currentGame.GetMaxRounds()); this.Text = Title; Debug.WriteLine("CurrentForm Title Get Finalized"); Debug.WriteLine("Current Player colour to control panel start"); controlPanel.BackColor = current_player.GetColour(); Debug.WriteLine("Current player colour to control panel done"); PlayerLabel.Text = current_player.Identifier(); AimTurret(current_tank.GetAngle()); PowerIndicatorLabel.Text = current_tank.GetPower().ToString(); SetForce(current_tank.GetPower()); if (currentGame.WindSpeed() > 0) { Wind.Text = currentGame.WindSpeed().ToString() + " E"; } else { Wind.Text = Math.Abs(currentGame.WindSpeed()).ToString() + " W"; } weaponComboBox.Items.Clear(); Chassis current_chassiss = current_tank.GetTank(); foreach (String weapon in current_chassiss.Weapons()) { weaponComboBox.Items.Add(weapon); } ChangeWeapon(weaponComboBox.SelectedIndex); current_player.BeginTurn(this, currentGame); Debug.WriteLine("Newturn"); }
public PlayerTank(Opponent player, int tankX, int tankY, Gameplay game) { //Alex Holm N9918205 TX = tankX; TY = tankY; current_player = player; current_game = game; current_chassis = current_player.GetTank(); startingArmour = current_chassis.GetTankHealth(); angle = 0; power = 25; current_weapon = GetPlayerWeapon(); AimTurret(GetAngle()); armour = current_chassis.GetTankHealth(); colour = current_player.GetColour(); current_tBMP = current_chassis.CreateTankBitmap(colour, angle); }
/// <summary> /// Creates a BattleTank with the passed information /// Setting the colour with GetColour() /// Durability with GetTankArmour(); /// TankModel with GetTank(); /// Author Greyden Scott & Sean O'Connell October 2017 /// Written, edited and tested by both team members /// </summary> /// <param name="player">The player associated with the Battle Tanks</param> /// <param name="tankX">The X Position</param> /// <param name="tankY">The Y position</param> /// <param name="game">Current games</param> /// <returns>explanation of return value</returns> public BattleTank(Opponent player, int tankX, int tankY, Gameplay game) { this.player = player; this.tankX = tankX; this.tankY = tankY; tankModel = player.GetTank(); currDurability = tankModel.GetTankArmour(); angle = 0; power = 25; curr_weapon = 0; plColour = player.GetColour(); tankBmp = tankModel.CreateBMP(plColour, angle); this.game = game; }