예제 #1
0
        private void NewTurn()
        {
            // find the next player and their tank
            currentTank   = currentGame.GetPlayerTank();
            currentPlayer = currentTank.GetPlayerNumber();
            //set the title of a form to current round of total rounds
            this.Text = string.Format("Tank battle - Round {0} of {1}", currentGame.CurrentRound(), currentGame.GetNumRounds());
            // set backcolor of controlpanel to currentplayers colour
            controlPanel.BackColor = currentPlayer.PlayerColour();
            // show the current player's name
            currentPlayerLabel.Text = currentPlayer.Name();
            // set angle to current gameplaytank's angle
            this.Aim(currentTank.GetTankAngle());
            //show current tank's power
            this.SetTankPower(currentTank.GetPower());
            //show current windspeed
            //postive values should state its a eastly wind while negative values come from windly west
            if (currentGame.GetWind() >= 0)
            {
                windspeedLabel.Text = string.Format("{0} E", currentGame.GetWind());
            }
            else
            {
                windspeedLabel.Text = string.Format("{0} W", (currentGame.GetWind() * -1)); // times by a negative number to shows a flat value for wind
            }
            //clear weapon choices in weaponSelect
            weaponSelect.Items.Clear();
            // find all weapons available to current tank
            foreach (string weapon in currentTank.GetTank().ListWeapons())
            {
                // add each weapon to selection choice of weaponSelect
                weaponSelect.Items.Add(weapon);
            }
            //set the current weapon to be used of current tank
            SetWeapon(currentTank.GetWeapon());

            if (currentPlayer is PlayerController)
            {
                // give controls for firing a weapon
                currentPlayer.BeginTurn(this, currentGame);
            }
            else if (currentPlayer is AIOpponent)
            {
                //run the firing command on currentplayer
                currentPlayer.BeginTurn(this, currentGame);
            }
        }
예제 #2
0
 /// <summary>
 ///  creates a new tank for a player
 /// </summary>
 /// <param name="player">The owner of new tank</param>
 /// <param name="tankX">Starting X coordinate of new tank</param>
 /// <param name="tankY">Starting Y coordinate of new tank</param>
 /// <param name="game">The current battle</param>
 public GameplayTank(GenericPlayer player, int tankX, int tankY, Battle game)
 {
     //sets up the default values of tank via passed information in constructor
     tanksPlayer = player;
     tankPosX    = tankX;
     tankPosY    = tankY;
     tankInGame  = game;
     //find the tank model via player
     tanksModel = tanksPlayer.GetTank();
     //gets the health of said model
     tankDurbility = tanksModel.GetTankHealth();
     //set the default values for angle , power and weapon
     currentAngle  = 0f;
     currentPower  = 25;
     currentWeapon = 0;
     //draw tank on feild of battle and save bitmap to class
     tankBmp = tanksModel.CreateTankBMP(tanksPlayer.PlayerColour(), currentAngle);
 }
예제 #3
0
 /// <summary>
 ///  sets the current aiming angle
 /// </summary>
 /// <param name="angle">new aiming angle</param>
 public void Aim(float angle)
 {
     currentAngle = angle;
     tanksModel.DisplayTank(currentAngle);
     tankBmp = tanksModel.CreateTankBMP(tanksPlayer.PlayerColour(), currentAngle);
 }