private Game _game;                     // game


        public ControlledTank(TankController player, int tankX, int tankY, Game game)
        {
            /// <summary>
            ///
            /// This constructor stores player, tankX, tankY and game as private fields of ControlledTank. It then gets the Tank by using the TankController's GetTank() method,
            /// then calls GetArmour() on it and stores this as the ControlledTank's current durability. This will go down as the tank takes damage.
            ///
            /// The constructor also initialises the angle, power and current weapon private variables, which start at 0, 25 and 0 respectively.
            /// Angle should be stored as a private float, while power and current weapon should be stored as private ints.
            ///
            /// Finally, it should also call Tank's CreateBitmap method, passing in the colour (retrieved from TankController's TankColour()) and current angle.
            /// The return value should then be stored as yet another private field.
            ///
            /// </summary>

            _tankX           = tankX;
            _tankY           = tankY;
            _player          = player;
            _type            = GetTank();
            _durability      = _type.GetArmour();
            _deltadurability = _durability;
            _angle           = 0;
            _tankPower       = 25;
            _weapon          = 0;
            _image           = _type.CreateBitmap(_player.TankColour(), _angle);
            _game            = game;
        }
Ejemplo n.º 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);
        }