/// <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);
        }
Beispiel #2
0
        private void NewTurn()
        {
            /// <summary>
            ///
            /// This newly-created method is used to update form elements to reflect who the current player is.
            ///
            /// </summary>

            ControlledTank _tank   = currentGame.GetPlayerTank();
            Tank           _type   = _tank.GetTank();
            TankController _player = _tank.GetPlayerById();

            float angle = _tank.GetTankAngle();
            int   power = _tank.GetTankPower();

            Text        = "Round" + currentGame.GetCurrentRound() + "of" + currentGame.GetCurrentRound();
            BackColor   = _player.TankColour();
            Player.Text = _player.Name();
            SetAimingAngle(angle);
            SetPower(power);

            if (currentGame.Wind() >= 0)
            {
                WindSpeed.Text = currentGame.Wind() + "E";
            }
            else
            {
                WindSpeed.Text = currentGame.Wind() + "W";
            }
            WeaponSelect.Items.Clear();

            string[] avaliableWeapons = _type.ListWeapons();

            for (int i = 0; i < avaliableWeapons.Length; i++)
            {
                WeaponSelect.Items.Add(avaliableWeapons[i]);
            }
            SelectWeapon(WeaponSelect.SelectedIndex);
            _player.NewTurn(this, currentGame);
        }