示例#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);
        }
示例#2
0
        public override void FireWeapon(int weapon, BattleTank playerTank, Game currentGame)
        {
            int           x          = playerTank.GetX();
            int           y          = playerTank.YPos();
            float         xPos       = (float)x + (TankModel.HEIGHT / 2);
            float         yPos       = (float)y + (TankModel.WIDTH / 2);
            GenericPlayer player     = playerTank.GetPlayerById();
            Boom          explosion  = new Boom(100, 4, 4);
            Bullet        projectile = new Bullet(xPos, yPos, playerTank.GetPlayerAngle(), playerTank.GetPower(), 0.01f, explosion, player);

            currentGame.AddEffect(projectile);
        }