/// <summary> /// used to handle firing the specified weapon from the tank playerTank. /// </summary> /// <param name="weapon">The weapon chosen from ListWeapons</param> /// <param name="playerTank">The tank that is shooting the weapons</param> /// <param name="currentGame">The battle the shot takes place in</param> public override void ShootWeapon(int weapon, GameplayTank playerTank, Battle currentGame) { float x = playerTank.XPos(); float y = playerTank.GetY(); //find the center of the tank x = x + Chassis.WIDTH / 2; y = y + Chassis.HEIGHT / 2; GenericPlayer player = playerTank.GetPlayerNumber(); Boom boom = new Boom(100, 4, 4); Shell shell = new Shell(x, y, playerTank.GetTankAngle(), playerTank.GetTankPower(), 0.01f, boom, player); Shell shell2 = new Shell(x, y, playerTank.GetTankAngle(), playerTank.GetTankPower() + 10, 0.01f, boom, player); Shell shell3 = new Shell(x, y, playerTank.GetTankAngle(), playerTank.GetTankPower() - 10, 0.01f, boom, player); currentGame.AddWeaponEffect(shell); currentGame.AddWeaponEffect(shell2); currentGame.AddWeaponEffect(shell3); }
private void NewTurn() { GameplayTank tank = currentGame.GetCurrentGameplayTank(); GenericPlayer player = tank.GetPlayerNumber(); //Sets the form caption Text = String.Format("Tank Battle - Round {0} of {1}", currentGame.GetCurrentRound(), currentGame.GetRounds()); controlPanel.BackColor = player.GetColour(); playerLabel.Text = player.PlayerName(); SetAngle(tank.GetTankAngle()); SetForce(tank.GetTankPower()); int wind = currentGame.WindSpeed(); if (wind >= 0) { windLabel.Text = String.Format("{0} E", wind); } else { windLabel.Text = String.Format("{0} W", Math.Abs(wind)); } //Remove all the current selectable weapons and replace them with the current tanks weapons. weaponSelector.Items.Clear(); String[] weapons = tank.GetTank().ListWeapons(); foreach (String weapon in weapons) { weaponSelector.Items.Add(weapon); } //tank.SelectWeapon SelectWeapon(tank.GetCurrentWeapon()); player.NewTurn(this, currentGame); }