Exemplo n.º 1
0
        private void NewTurn()
        {
            BattleTank    player         = currentGame.CurrentPlayerTank();
            GenericPlayer tankController = player.GetPlayerById();

            this.Text          = "Tank Battle - Round " + currentGame.GetCurrentRound() + "of " + currentGame.GetRounds();
            BackColor          = tankController.GetTankColour();
            lblPlayerName.Text = tankController.Identifier();
            Aim(player.GetPlayerAngle());
            SetTankPower(player.GetPower());
            if (currentGame.WindSpeed() > 0)
            {
                lblWindValue.Text = currentGame.WindSpeed() + " E";
            }
            else
            {
                lblWindValue.Text = currentGame.WindSpeed() * -1 + " W";
            }
            scrollWeapon.Items.Clear();
            TankModel tank = player.CreateTank();

            String[] lWeaponsAvailable = tank.ListWeapons();
            scrollWeapon.Items.AddRange(lWeaponsAvailable);
            SetWeaponIndex(player.GetCurrentWeapon());
            tankController.BeginTurn(this, currentGame);
        }
Exemplo n.º 2
0
        public BattleTank(GenericPlayer player, int tankX, int tankY, Game game)
        {
            //setting up the values we recieve to the variables in this class
            this.tPlayer = player;
            this.xCoord  = tankX;
            this.yCoord  = tankY;
            this.tGame   = game;
            this.tPower  = 25;
            this.tAngle  = 0;
            this.tWeapon = 0;

            //creating a tank, getting color, setting angle and getting armour
            //seems like the order of things is very important
            //was failing tests coz of the null excpetion, took me couple of hours
            //to understand that it needs to be re-ordered.
            this.tTank   = tPlayer.CreateTank();
            this.tankBMP = tTank.CreateBMP(tPlayer.GetTankColour(), this.tAngle);
            this.health  = tTank.GetArmour();
        }