コード例 #1
0
ファイル: GameForm.cs プロジェクト: tdiego95/TankBattle
        private void NewTurn()
        {
            PlayerTank     player         = currentGame.CurrentPlayerTank();
            TankController tankController = player.Player();

            this.Text          = "Tank Battle - Round " + currentGame.CurrentRound() + "of " + currentGame.GetTotalRounds();
            BackColor          = tankController.PlayerColour();
            lblPlayerName.Text = tankController.Identifier();
            SetAimingAngle(player.GetTankAngle());
            SetPower(player.GetTankPower());
            if (currentGame.Wind() > 0)
            {
                lblWindValue.Text = currentGame.Wind() + " E";
            }
            else
            {
                lblWindValue.Text = currentGame.Wind() * -1 + " W";
            }
            cmbWeapon.Items.Clear();
            Tank tank = player.CreateTank();

            String[] lWeaponsAvailable = tank.ListWeapons();
            cmbWeapon.Items.AddRange(lWeaponsAvailable);
            ChangeWeapon(player.GetCurrentWeapon());
            tankController.StartTurn(this, currentGame);
        }
コード例 #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);
        }