public void Fire() { BattleTank player = currentGame.CurrentPlayerTank(); player.Fire(); controlPanel.Enabled = false; }
/// <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(); }
private void NewTurn() { BattleTank player = currentGame.CurrentPlayerTank(); GenericPlayer tankController = player.GetPlayerById(); this.Text = "Tank Battle - Round " + currentGame.GetCurrentRound() + "of " + currentGame.GetRounds(); BackColor = tankController.GetTankColour(); lblPlayerName.Text = tankController.Identifier(); Aim(player.GetPlayerAngle()); SetTankPower(player.GetPower()); if (currentGame.WindSpeed() > 0) { lblWindValue.Text = currentGame.WindSpeed() + " E"; } else { lblWindValue.Text = currentGame.WindSpeed() * -1 + " W"; } scrollWeapon.Items.Clear(); TankModel tank = player.CreateTank(); String[] lWeaponsAvailable = tank.ListWeapons(); scrollWeapon.Items.AddRange(lWeaponsAvailable); SetWeaponIndex(player.GetCurrentWeapon()); tankController.BeginTurn(this, currentGame); }
/// <summary> /// This method is called both externally (by the computer player when it wants to fire) and by the /// 'Fire!' button when it is clicked. /// </summary> public void Fire() { BattleTank bTank = currentGame.GetCurrentPlayerTank(); bTank.Fire(); controlPanel.Enabled = false; timer1.Enabled = true; }
public override void FireWeapon(int weapon, BattleTank playerTank, Game currentGame) { int x = playerTank.GetX(); int y = playerTank.YPos(); float xPos = (float)x + (TankModel.HEIGHT / 2); float yPos = (float)y + (TankModel.WIDTH / 2); GenericPlayer player = playerTank.GetPlayerById(); Boom explosion = new Boom(100, 4, 4); Bullet projectile = new Bullet(xPos, yPos, playerTank.GetPlayerAngle(), playerTank.GetPower(), 0.01f, explosion, player); currentGame.AddEffect(projectile); }
public void NewRound() { this.currentPlayer = this.startingGenericPlayer; //initialising map this.drawBattleGround = new Map(); ///making an array to store the positions of players int[] positionPlayers = new int[arrNumPlayer.Length]; positionPlayers = CalculatePlayerPositions(arrNumPlayer.Length); //random positioning for players Randomise(positionPlayers); //player to keep start looping through the player int player = 0; do { //if null means its all matching and no need to create anymore players //so we break it if (modelPlayerController[player] == null) { break; } //if not null then keep making each player else { //for each player to start the round modelPlayerController[player].StartRound(); //taking the horizontal position from positionPlayer array at the current index int tHorizontalPosition = positionPlayers[player]; //getting positioning for tank from map class int tVerticalPosition = drawBattleGround.TankVerticalPosition(tHorizontalPosition); //create the tank itself with values that we gathered from above BattleTank tank = new BattleTank(modelPlayerController[player], tHorizontalPosition, tVerticalPosition, this); //each instance that we are looping through creates a tank modelPlayerTank[player] = tank; player++; } } while (player < this.arrNumPlayer.Length); //random number, wind speed, initialising form Random rnd = new Random(); this.windSpeed = rnd.Next(-100, 100); GameForm newForm = new GameForm(this); newForm.Show(); }
/// <summary> /// This method is used to handle firing the specified weapon from the tank playerTank. /// Author Greyden Scott & Sean O'Connell October 2017 /// Written, edited and tested by both team members /// </summary> /// <param name="weapon">The index of the weapon selected</param> /// <param name="playerTank">the player tank</param> /// <param name="currentGame">the current GamePlay</param> /// <returns> Returns the starting durability of this type of tank </returns> public override void ActivateWeapon(int weapon, BattleTank playerTank, Gameplay currentGame) { float gravity = 0; float x_pos = (float)playerTank.GetX() + (TankModel.WIDTH / 2); float y_pos = (float)playerTank.Y() + (TankModel.HEIGHT / 2); Opponent player = playerTank.GetPlayer(); int explosionDmg = 0; int explosionRad = 0; int explosionDes = 0; gravity = 0.01f; explosionDmg = 100; explosionRad = 4; explosionDes = 4; Blast blast = new Blast(explosionDmg, explosionRad, explosionDes); Shell shell = new Shell(x_pos, y_pos, playerTank.GetTankAngle(), playerTank.GetCurrentPower(), gravity, blast, player); currentGame.AddWeaponEffect(shell); }
/// <summary> /// Sets the current player to the starting player /// Creates a new map /// populates a list of player positions and calls commence round on each player /// Shuffles the positions /// Createsa a list of battle tanks and stores the battle tanks in the list /// Sets the windspeed for the game /// Calsl teh gameplayForm and shows it /// Author Greyden Scott & Sean O'Connell October 2017 /// Written, edited and tested by both team members /// </summary> public void CommenceRound() { curr_player = start_player; arena = new Map(); //Setup players positions and change them about int [] positions = GetPlayerLocations(noPlayers.Length); for (int i = 0; i < noPlayers.Length; i++) { noPlayers[i].CommenceRound(); } Shuffle(positions); //Setup BattleTanks in their given positions battleTanks = new BattleTank[noPlayers.Length]; for (int i = 0; i < noPlayers.Length; i++) { int X_pos = positions[i]; int Y_pos = arena.TankYPosition(X_pos); battleTanks[i] = new BattleTank(noPlayers[i], X_pos, Y_pos, this); } wind = GetWindSpeed(); //Show Form GameplayForm gameplayForm = new GameplayForm(this); gameplayForm.Show(); }
public override void ShootWeapon(int weapon, BattleTank playerTank, GameController currentGame) { throw new NotImplementedException(); }
public abstract void ShootWeapon(int weapon, BattleTank playerTank, GameController currentGame);
public abstract void ActivateWeapon(int weapon, BattleTank playerTank, Gameplay currentGame);
public abstract void FireWeapon(int weapon, BattleTank playerTank, Game currentGame);