コード例 #1
0
ファイル: Shell.cs プロジェクト: KALVS/CAB201
        public Shell(float x, float y, float angle, float power, float gravity, Shrapnel explosion, Opponent player)
        {
            Sx         = x;
            Sy         = y;
            Splayer    = player;
            Sexplosion = explosion;
            Sgravity   = gravity;
            float angleRadians = (90 - angle) * (float)Math.PI / 180;
            float magnitude    = power / 50;

            SxVelocity = (float)Math.Cos(angleRadians) * magnitude;
            SyVelocity = (float)Math.Sin(angleRadians) * -magnitude;
        }
コード例 #2
0
 /// <summary>
 ///
 /// This constructor initializes a new instance of the ControlledTank class.
 /// It also stores the tankModel by usubg the Opponents GetTank() method, and
 /// GetArmour() for the current durability of the TankModel. In addition, it also
 /// stores the angle, power, current weapons and colour of the tank which is a bitmap.
 ///
 /// Author John Santias and Hoang Nguyen October 2017
 ///
 /// </summary>
 /// <param name="player"> A reference of Opponent stored as player </param>
 /// <param name="tankX"> The x coordinate of the tank </param>
 /// <param name="tankY"> The y coordinate of the tank </param>
 /// <param name="game"> A reference of Gameplay stored as game </param>
 public ControlledTank(Opponent player, int tankX, int tankY, Gameplay game)
 {
     this.player = player;
     this.tankX  = tankX;
     this.tankY  = tankY;
     this.game   = game;
     tankModel   = player.GetTank();
     currentDur  = tankModel.GetArmour();
     angle       = 0;
     power       = 25;
     tankWeapon  = 0;
     colour      = tankModel.CreateBitmap(player.GetColour(), angle);
 }
コード例 #3
0
ファイル: BattleForm.cs プロジェクト: KALVS/CAB201
        protected void NewTurn()
        {
            //<Summary>
            //Alex Holm N9918205
            //</Summary>

            Debug.WriteLine("CurrentTank Get Start");
            current_tank = currentGame.GetCurrentPlayerTank();

            Debug.WriteLine("CurrentTank Get Finalized");

            Debug.WriteLine("CurrentPlayer Get Start");
            current_player = current_tank.GetPlayer();
            Debug.WriteLine("CurrentTank Get Finalized");

            Debug.WriteLine("CurrentForm Title Get Start");
            string Title = ("Tank Battle - Round " + currentGame.CurrentRound() + " of " + currentGame.GetMaxRounds());

            this.Text = Title;
            Debug.WriteLine("CurrentForm Title Get Finalized");

            Debug.WriteLine("Current Player colour to control panel start");
            controlPanel.BackColor = current_player.GetColour();
            Debug.WriteLine("Current player colour to control panel done");
            PlayerLabel.Text = current_player.Identifier();
            AimTurret(current_tank.GetAngle());
            PowerIndicatorLabel.Text = current_tank.GetPower().ToString();
            SetForce(current_tank.GetPower());

            if (currentGame.WindSpeed() > 0)
            {
                Wind.Text = currentGame.WindSpeed().ToString() + " E";
            }
            else
            {
                Wind.Text = Math.Abs(currentGame.WindSpeed()).ToString() + " W";
            }

            weaponComboBox.Items.Clear();
            Chassis current_chassiss = current_tank.GetTank();

            foreach (String weapon in current_chassiss.Weapons())
            {
                weaponComboBox.Items.Add(weapon);
            }
            ChangeWeapon(weaponComboBox.SelectedIndex);
            current_player.BeginTurn(this, currentGame);
            Debug.WriteLine("Newturn");
        }
コード例 #4
0
        /// <summary>
        /// This method constructs a new Shell.
        /// Author Greyden Scott & Sean O'Connell October 2017
        /// Written, edited and tested by both team members
        /// </summary>
        /// <param name="x">The X position of the shell</param>
        /// <param name="y">The y Position of teh shell</param>
        /// <param name="angle">The angle in which the shell is firedy</param>
        /// <param name="power">The power which assists in determining the shells speedy</param>
        /// <param name="gravity">Gravity value affecting the shell</param>
        /// <param name="explosion">The blast effect to displayed</param>
        /// <param name="player">The assocated playery</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;

            float angleRadians = (90 - angle) * (float)Math.PI / 180;
            float magnitude    = power / 50;

            x_velocity = (float)Math.Cos(angleRadians) * magnitude;
            y_velocity = (float)Math.Sin(angleRadians) * -magnitude;

            this.explosion = explosion;

            this.player = player;
        }
コード例 #5
0
ファイル: Chassis.cs プロジェクト: KALVS/CAB201
        public override void WeaponLaunch(int weapon, PlayerTank playerTank, Gameplay currentGame)
        {
            Debug.WriteLine("Chassis WeaponLaunch Start");
            //Alex Holm N9918205
            float x = (playerTank.XPos());
            float y = (playerTank.GetY());

            x += (Chassis.WIDTH) / 2;
            y += (Chassis.HEIGHT) / 2;
            Opponent player    = playerTank.GetPlayer();
            Shrapnel shrap     = new Shrapnel(100, 4, 4);
            Shell    Std_shell = new Shell(x, y, playerTank.GetAngle(), playerTank.GetPower(), 0.01f, shrap, player);

            currentGame.AddEffect(Std_shell);
            Debug.WriteLine("Chassis WeaponLaunch Complete");
        }
コード例 #6
0
ファイル: PlayerTank.cs プロジェクト: KALVS/CAB201
 public PlayerTank(Opponent player, int tankX, int tankY, Gameplay game)
 {
     //Alex Holm N9918205
     TX              = tankX;
     TY              = tankY;
     current_player  = player;
     current_game    = game;
     current_chassis = current_player.GetTank();
     startingArmour  = current_chassis.GetTankHealth();
     angle           = 0;
     power           = 25;
     current_weapon  = GetPlayerWeapon();
     AimTurret(GetAngle());
     armour       = current_chassis.GetTankHealth();
     colour       = current_player.GetColour();
     current_tBMP = current_chassis.CreateTankBitmap(colour, angle);
 }
コード例 #7
0
        /// <summary>
        /// Creates a BattleTank with the passed information
        /// Setting the colour with GetColour()
        /// Durability with GetTankArmour();
        /// TankModel with GetTank();
        /// Author Greyden Scott & Sean O'Connell October 2017
        /// Written, edited and tested by both team members
        /// </summary>
        /// <param name="player">The player associated with the Battle Tanks</param>
        /// <param name="tankX">The X Position</param>
        /// <param name="tankY">The Y position</param>
        /// <param name="game">Current games</param>
        /// <returns>explanation of return value</returns>
        public BattleTank(Opponent player, int tankX, int tankY, Gameplay game)
        {
            this.player = player;
            this.tankX  = tankX;
            this.tankY  = tankY;

            tankModel      = player.GetTank();
            currDurability = tankModel.GetTankArmour();

            angle       = 0;
            power       = 25;
            curr_weapon = 0;

            plColour = player.GetColour();

            tankBmp = tankModel.CreateBMP(plColour, angle);

            this.game = game;
        }
コード例 #8
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);
        }
コード例 #9
0
 /// <summary>
 /// Takes the player number between one and the number of players and assigns the appropriate field in
 /// Gameplay's opponent to the player.
 ///
 /// Author John Santias and Hoang Nguyen September 2017
 /// </summary>
 /// <param name="playerNum">The current player number</param>
 /// <param name="player">A reference of Opponent stored as player</param>
 public void SetPlayer(int playerNum, Opponent player)
 {
     theOppo[playerNum - 1] = player;
 }
コード例 #10
0
 /// <summary>
 /// Creates the opponent in the array noPlayers witht the input value of player
 /// Author Greyden Scott & Sean O'Connell October 2017
 /// Written, edited and tested by both team members
 /// </summary>
 /// <param name="playerNum">Player Number for the player to be created</param>
 /// <param name="player">The assocated player to be stored in the array</param>
 public void CreatePlayer(int playerNum, Opponent player)
 {
     noPlayers[playerNum - 1] = player;
 }