Beispiel #1
0
        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);
        }
Beispiel #2
0
        private void NewTurn()
        {
            //throw new NotImplementedException();
            //currentGame.GetPlayerTank().GetPlayerById();
            PlayerTank     currentTankPlayer = currentGame.GetPlayerTank();
            TankController currentId         = currentTankPlayer.GetPlayerById();

            // Setting Form Title Caption to Current Round
            this.Text = "Tank Battle - Round " + currentGame.CurrentRound() + " of " + currentGame.GetMaxRounds();

            // Set back color of control panel
            controlPanel.BackColor = currentId.GetTankColour();
            // Set player name to tank name
            label1.Text = currentId.Identifier();
            // Call AimTurret() to set current angle
            AimTurret(currentTankPlayer.GetPlayerAngle());
            // Call SetPower() to set current power
            SetPower(currentTankPlayer.GetTankPower());

            label7.Text = trackBar1.Value.ToString();

            // Updating wind label
            if (currentGame.WindSpeed() < 0)
            {
                label3.Text = currentGame.WindSpeed() + "W";
            }
            else
            {
                label3.Text = currentGame.WindSpeed() + "E";
            }

            // Clearing Combobox
            comboBox1.Items.Clear();

            // Adding to the Combobox
            foreach (string x in currentTankPlayer.CreateTank().WeaponList())
            {
                comboBox1.Items.Add(x);
            }

            // Setting the current weapon to the current player
            SetWeaponIndex(currentTankPlayer.GetCurrentWeapon());

            // Calling BeginTurn()
            currentId.BeginTurn(this, currentGame);

            /*
             * button1.TabStop = false;
             * comboBox1.TabStop = false;
             * numericUpDown1.TabStop = false;
             * trackBar1.TabStop = false;*/

            label7.Text = trackBar1.Value.ToString();

            debounce = 0;
        }
Beispiel #3
0
        public override void FireWeapon(int weapon, PlayerTank playerTank, GameController currentGame)
        {
            // Firing the specified weapon from playerTank
            float xPos = playerTank.GetX();
            float yPos = playerTank.GetYPos();

            xPos += Chassis.WIDTH / 2;
            yPos += Chassis.HEIGHT / 2;

            TankController tankContr = playerTank.GetPlayerById();

            Shrapnel newShrapnel = new Shrapnel(100, 4, 4);

            Projectile newProj = new Projectile(xPos, yPos, playerTank.GetPlayerAngle(), playerTank.GetTankPower(), 0.01f, newShrapnel, tankContr);

            currentGame.AddEffect(newProj);
        }
Beispiel #4
0
        public override void FireWeapon(int weapon, PlayerTank playerTank, Game currentGame)
        {
            int            x          = playerTank.X();
            int            y          = playerTank.Y();
            float          xPos       = (float)x + (Tank.HEIGHT / 2);
            float          yPos       = (float)y + (Tank.WIDTH / 2);
            TankController player     = playerTank.Player();
            Explosion      explosion  = new Explosion(100, 4, 4);
            Projectile     projectile = new Projectile(xPos, yPos, playerTank.GetTankAngle(), playerTank.GetTankPower(), 0.01f, explosion, player);

            currentGame.AddWeaponEffect(projectile);
        }