Beispiel #1
0
        /// <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();
        }
Beispiel #2
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);
        }
Beispiel #3
0
 private void powerTrackBar_Scroll(object sender, EventArgs e)
 {
     currentTank.SetPower(powerTrackBar.Value);
     powerValueLabel.Text = currentTank.GetCurrentPower().ToString();
 }