Exemplo n.º 1
0
        /// <summary>
        /// Handles firing the specified weapon from the tank.
        ///
        /// Author John Santias and Hoang Nguyen October 2017
        /// </summary>
        /// <param name="weapon">int based on string returned from Weaponlist()</param>
        /// <param name="playerTank">Controlledtank associated with this</param>
        /// <param name="currentGame">the current Game being played</param>
        public override void FireWeapon(int weapon, ControlledTank playerTank, Gameplay currentGame)
        {
            float    centerPosX = (float)playerTank.GetX() + (WIDTH / 2), centerPosY = (float)playerTank.GetYPos() + (HEIGHT / 2);
            Opponent op    = playerTank.GetPlayerNumber();
            Blast    blast = new Blast(100, 4, 4);
            Shell    shell = new Shell(centerPosX, centerPosY, playerTank.GetAim(), playerTank.GetCurrentPower(), 0.01f, blast, op);

            currentGame.AddWeaponEffect(shell);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs a new Shell. The x, y, gravity, explosion and playerfields are stored in private
        /// fields of Shell. Two more field (x velocity and y velocity) are also initialised. This refers
        /// to how much the Shell moves in 1/10 of a frame.
        ///
        /// Author John Santias October 2017
        /// </summary>
        /// <param name="x">The starting x position of the shell</param>
        /// <param name="y">The starting y position of the shell</param>
        /// <param name="angle">The angle for the shell fire at</param>
        /// <param name="power">The power/speed of the shell</param>
        /// <param name="gravity">Gravity for the shell to come back to the ground</param>
        /// <param name="explosion">Type of explosion</param>
        /// <param name="player">Which player is shooting the shell</param>
        public Shell(float x, float y, float angle, float power, float gravity, Blast explosion, Opponent 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;

            xVelocity = (float)Math.Cos(angleRadians) * magnitude;
            yVelocity = (float)Math.Sin(angleRadians) * -magnitude;
        }
Exemplo n.º 3
0
        /// <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);
        }