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); }
/// <summary> /// Constructs a new Shell. /// </summary> /// <param name="x">the x coordinate of the tank</param> /// <param name="y">y position of the tank</param> /// <param name="angle">angle shell is leaving</param> /// <param name="power">power of the shell</param> /// <param name="gravity">The gravity the shell experiences</param> /// <param name="explosion">the explosion to produce</param> /// <param name="player">the player who fired the shell</param> public Shell(float x, float y, float angle, float power, float gravity, Boom explosion, GenericPlayer player) { this.x = x; this.y = y; this.gravity = gravity; this.explosion = explosion; this.player = player; float angleRadians = (90 - angle) * (float)Math.PI / 180; float magnitude = power / 50; //use the angle to determine which way to send the shell xVelocity = (float)Math.Cos(angleRadians) * magnitude; yVelocity = (float)Math.Sin(angleRadians) * -magnitude; }
public Bullet(float x, float y, float angle, float power, float gravity, Boom explosion, GenericPlayer player) { this.angle = angle; this.power = power; this.gravity = gravity; this.explosion = explosion; this.player = player; this.x = x; this.y = y; float angleRadiant = (90 - angle) * (float)Math.PI / 180; float magnitude = power / 50; this.xVelocity = (float)Math.Cos(angleRadiant) * magnitude; this.yVelocity = (float)Math.Sin(angleRadiant) * magnitude; }
/// <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); }
public Bullet(float x, float y, float angle, float power, float gravity, Boom explosion, TankController player) { throw new NotImplementedException(); }