예제 #1
0
        /// <summary>
        /// Newly-created method used to update form elemtns to reflect who the current player is. It involves
        /// a number of things like changing the colours, angles, power, round number etc.
        ///
        /// Author John Santias and Hoang Nguyen October 2017
        /// </summary>
        private void NewTurn()
        {
            currentControlledTank = currentGame.GetCurrentGameplayTank();
            currentOpponent       = currentControlledTank.GetPlayerNumber();
            Text = "Tank Battle - Round " + currentGame.GetRound() + " of " + currentGame.GetTotalRounds();
            controlPanel.BackColor = currentOpponent.GetColour();
            playerLabel.Text       = currentOpponent.Name();
            currentControlledTank.SetAimingAngle(angleSet);
            currentControlledTank.SetPower(powerSet);
            windSpeed = currentGame.GetWindSpeed();

            if (windSpeed > 0)
            {
                windStatusLabel.Text = windSpeed + " E";
            }
            else if (windSpeed < 0)
            {
                windStatusLabel.Text = -windSpeed + " W";
            }
            weaponComboBox.Items.Clear();
            currentTankModel = currentControlledTank.GetTank();
            string[] weapons = currentTankModel.WeaponList();

            for (int i = 0; i < weapons.Length; i++)
            {
                weaponComboBox.Items.Add(weapons[i]);
            }

            weaponSet = currentControlledTank.GetWeaponIndex();
            SetWeaponIndex(weaponSet);
            currentOpponent.BeginTurn(this, currentGame);
        }
예제 #2
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);
        }