Ejemplo n.º 1
0
        /// <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);
        }