public frmEndGame(Team winner,frmGameStart f)
        {
            creator = f;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.txtWinner.Text ="the winner is " + winner.teamName;
            this.lblTank1.Text = winner.tanks[0].name;
            this.lblTank2.Text = winner.tanks[1].name;
            this.lblTank3.Text = winner.tanks[2].name;
            this.lblTank4.Text = winner.tanks[3].name;

            this.label1.Text = "remaining health : " + winner.tanks[0].health.ToString();
            this.label2.Text = "remaining health : " + winner.tanks[1].health.ToString();
            this.label3.Text = "remaining health : " + winner.tanks[2].health.ToString();
            this.label4.Text = "remaining health : " + winner.tanks[3].health.ToString();

            this.progressBar1.Value = winner.tanks[0].health;
            this.progressBar2.Value = winner.tanks[1].health;
            this.progressBar3.Value = winner.tanks[2].health;
            this.progressBar4.Value = winner.tanks[3].health;

            //horisontalBarGraph1 = new horisontalBarGraph();
            //horisontalBarGraph1.setByValue(winner.tanks[0].health);
        }
Beispiel #2
0
 public Tank(Game cg,Team t,string n,int initx, int inity)
 {
     name = n;
     creatorGame = cg;
     myTeam = t;
     x = initx;
     y = inity;
 }
Beispiel #3
0
        public Game(frmGameStart s,Team[] t,string l)
        {
            // Start Menu The menu that Spawned this
            startMenu = s;
            // Game Teams The Teams that are playing this game
            gameTeams = t;
            // This initalises the formes neaded to producec the game screen
            weaponsMenu = new   frmWeaponsMenu(this);
            myTimer     = new   frmGameTimer(this);
            // This initalises the mdi container form for the game screen
            inGame      = new   frmGameContainer(this);
            //this initalises game level wich contains details on the level
            myGameScreen= new   frmGameScreen(this,l);
            //this sets the mdiParent the forms composing the game screen
            //to the inGame container form
            weaponsMenu.MdiParent  =      inGame;
            myGameScreen.MdiParent =      inGame;
            myTimer.MdiParent      =      inGame;
            top.MdiParent          =      inGame;
            //this tells the forms to show
            myGameScreen.Show();
            myTimer.Show();
            inGame.Show();
            top.Show();
            // this sets up the displays needed to show details
            for(int teamOn = 0; teamOn <= gameTeams.Length-1; teamOn++)
            {
                inGame.displays[teamOn].setTeamName(gameTeams[teamOn].teamName);
                this.gameTeams[teamOn].setCreator(this);
            }
            //this gives the myGameScreen object focus
            myGameScreen.Activate();
            nextTurn();
            nextTurn();
            //***************** ~~  NETWORKING ATTEMPT  ~~ ************************************************
            /*for(int t = this.gameTeams.Length-1;t >=0 ;t--)
            {
                if(!gameTeams[t].myClient.isLocal)
                    myServers[t] = new gameServer(this,gameTeams[t].myClient.mySocket,t);
            }
            if(myServer == null)
            {
                this.iAmClient = false;
            }
            else
            {
                iAmClient = true;
                this.ServerNetStream = myServer.GetStream();
                this.toServerWriter = new StreamWriter(ServerNetStream);
                this.fromServerReader = new StreamReader(ServerNetStream);

            }*/
            //*********************************************************************************************
            updateDisplay();
        }
 public void startGameAsClient()
 {
     // This is not used and some is hard coded but i have left it for you to see
     gameTeams[0] = new Team(myGame,this.myClients[0]);
     gameTeams[1] = new Team(myGame,this.myClients[1]);
     myGame = new Game(this,gameTeams,this.networkStream,this.Level);
     this.Hide();
 }
        public void startGame()
        {
            if(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width != 1024)
                // If the resulution is wrong tell the user.
                MessageBox.Show("Please Set You Screen Resulution to 1240 X 780");
            else
            {
                // If teams and level are ready do the following
                if((levelReady && teamsReady)||this.debug)
                {
            //********************  DEBUG MODE ONLY  *************************************************
                    if(debug == true)
                    {
                        gameTeams[0] = new Team(myGame,"temp");
                        gameTeams[1] = new Team(myGame,"temp");

                        gameTeams[0].teamName = this.txtTeamName1.Text;
                        gameTeams[0].tanks[0].name = this.txtTeam1Tank1.Text;
                        gameTeams[0].tanks[1].name = this.txtTeam1Tank2.Text;
                        gameTeams[0].tanks[2].name = this.txtTeam1Tank3.Text;
                        gameTeams[0].tanks[3].name = this.txtTeam1Tank4.Text;

                        gameTeams[1].teamName = this.txtTeamName2.Text;
                        gameTeams[1].tanks[0].name = this.txtTeam2Tank1.Text;
                        gameTeams[1].tanks[1].name = this.txtTeam2Tank2.Text;
                        gameTeams[1].tanks[2].name = this.txtTeam2Tank3.Text;
                        gameTeams[1].tanks[3].name = this.txtTeam2Tank4.Text;
                    }
            //*****************************************************************************************
                    else
                    {
                        //create an array of teams with a lenght to match the numbers in lstReadyTeams
                        gameTeams = new Team[lstReadyTeams.Items.Count];

                        for(int i = lstReadyTeams.Items.Count-1 ; i >= 0 ; i-- )
                        {
                            if(myClients[i]!= null)
                            {
                                /* enter each team into game teams that is not null
                                 * I think that it will still work without the IF
                                 * but better safe then sorry */
                                gameTeams[i] = new Team(myGame,this.myClients[i]);
                            }
                        }
                        collectDetailsStuff();
                    }
                    this.Hide();
                    if(!amIClient)
                        myGame = new Game(this,gameTeams,this.Level);
                    //else
                    //myGame = new ClientGame(this,gameTeams);
                }
                else
                {
                    MessageBox.Show("Invalid Details or Level");
                }
            }
        }
 public void endGame(Team winnerName)
 {
     frmEndGame endStatsDisplay = new frmEndGame(winnerName,this);
     endStatsDisplay.Show();
     myGame = null;
 }
Beispiel #7
0
        public void nextTurn()
        {
            /* This calls nextTurn in the current team and increments the
             * the current team, so that it is the next teams turn and a
             * different tank will be contraoled when this team has a go
             * again*/

            //**********************  UNLOAD LAST TURN  *******************************************
            //Reset beemMode so that if the last player was trying to beem
             // You will not be beemed now*/
            myGameScreen.beemModeOn = false;
            // Reset the turn time
            myTimer.time = roundTime;
            /* This method makes the player display screen to reflect the current turn
             * in this instance it is making it display no active player since one one
             * on THIS TEAM has a turn. */
            inGame.displays[currentTeam].setActive(5);
            //This makes the tank not current
            gameTeams[currentTeam].tanks[gameTeams[currentTeam].currentTank].isCurrent = false;
            // Call nextTurn in the current team. this will make the current team go onto its next tank.
            gameTeams[currentTeam].nextTurn();
            // Test to see if the game is over
            isGameOver();
            //***********************  LOAD THIS TURN  **********************************************
            /* This will go onto the next team untill it finds one that is alive. note without the above
             * Line this could go into an infinate loop*/
            do
            {
                // go onto the next team unless it's at the last one in that case go back to the first
                if(currentTeam < gameTeams.Length-1)
                    currentTeam++;
                else
                    currentTeam = 0;
            }
            while(gameTeams[currentTeam].isDead);
            // This sets the current tank on the current team to be active so it can have its go.
            gameTeams[currentTeam].tanks[gameTeams[currentTeam].currentTank].isCurrent = true;
            // This makes the displays reflect the current turn.
            inGame.displays[currentTeam].setActive(gameTeams[currentTeam].currentTank);
            // Start the timer again.
            startTimer();
            // This sets up a currentTeamObject to make it easier to access (i wish i had done this earlier)
            currentTeamObject = gameTeams[currentTeam];
            // Set the current weapon so the image changes when the turn changes
            this.setCurrentWeapon(gameTeams[currentTeam].tanks[gameTeams[currentTeam].currentTank].currentWeapon);
            //**************** END OF TURN CHANGE ********************************************************
        }
Beispiel #8
0
 public void isGameOver()
 {
     /* This tests to see if the game has ended. if it has it
      * calls endGame with the parameter of the winning team
      */
     deadTeamCounter = 0; //this is used to count the number of dead teams
     Team winner = new Team(this,"Error");
     /* Although it does not make much sence initalising the above tank here
      * if it CANNOT be passed to endgame, but it will not compile otherwise
      */
     for(int t = gameTeams.Length -1;t >= 0;t--)
     {
         //this loops through all the teams
         gameTeams[t].checkIfDead();
         if(gameTeams[t].isDead)
         {
             //this test if the current team is dead if so add one to the counter
             deadTeamCounter ++;
         }
         else
         {
             //set winner to the current alive tank
             winner = gameTeams[t];
         }
     }
     // if all but one of the Teams are dead call end game with the winner
     if(deadTeamCounter >= gameTeams.Length - 1)
         endGame(winner);
 }
Beispiel #9
0
        public void endGame(Team winnerName)
        {
            // this is called if somone wins.

            // this closes the varius windows
            myGameScreen.Close();
            myTimer.Close();
            top.Close();
            /* for some reason mdiContainers don't close so you have to
             * make it not an mdiContainer
             */
            inGame.IsMdiContainer = false;
            inGame.Close();
            /* from here the closing process is handed over to startMenu,
             * startMenu contains this object
             */
            startMenu.endGame(winnerName);
        }
Beispiel #10
0
        //******************** ~~ This Contructor is only used for Networks ~~ ************************
        public Game(frmGameStart s,Team[] t,System.Net.Sockets.NetworkStream sns,string l)
        {
            /*//this is for a server or local game;
            //level = l;
            startMenu = s;
            for(int i = t.Length-1;i>=0;i--)
            {
                gameTeams[i] = t[i];
            }

            // This initalises the formes neaded to producec the game screen
            weaponsMenu = new frmWeaponsMenu(this);

            myTimer = new frmGameTimer(this);
            // This initalises the mdi container form for the game screen
            inGame = new frmGameContainer(this);
            //this initalises game level wich contains details on the level
            gameLevel = new Level();
            //this code initalises and populates the gameTeams array
            //which contains team objects
            //gameTeams = new Team[2];
            myGameScreen = new frmGameScreen(this,l);

            //this sets the mdiParent the forms composing the game screen
            //to the inGame container form
            weaponsMenu.MdiParent = inGame;
            myGameScreen.MdiParent = inGame;
            myTimer.MdiParent = inGame;
            //this tells the forms to show
            myGameScreen.Show();
            myTimer.Show();
            inGame.Show();
            for(int teamOn = 0; teamOn <= 1; teamOn++)
            {
                inGame.displays[teamOn].setTeamName(gameTeams[teamOn].teamName);
                this.gameTeams[teamOn].setCreator(this);
            }
            //this gives the myGameScreen object focus
            //myViewer.Show();
            top.MdiParent = inGame;
            top.Show();
            myGameScreen.Activate();
            nextTurn();
            nextTurn();
            */
            /*for(int t = this.gameTeams.Length-1;t >=0 ;t--)
            {
                if(!gameTeams[t].myClient.isLocal)
                    myServers[t] = new gameServer(this,gameTeams[t].myClient.mySocket,t);
            }
            */
            /*if(myServer == null)
            {
                this.iAmClient = false;
            }
            else
            {
                iAmClient = true;
                this.ServerNetStream = myServer.GetStream();
                this.toServerWriter = new StreamWriter(ServerNetStream);
                this.fromServerReader = new StreamReader(ServerNetStream);

            }
            */
            updateDisplay();
            //initViewControls();
            myServer = new Server(sns,this);
            startMenu = s;
            gameTeams = t;
            //gameTeams[1] = gameTeam2;
            // This initalises the formes neaded to producec the game screen
            weaponsMenu = new frmWeaponsMenu(this);
            myTimer = new frmGameTimer(this);
            // This initalises the mdi container form for the game screen
            inGame = new frmGameContainer(this);
            //this initalises game level wich contains details on the level
            //gameLevel = new Level();
            //this code initalises and populates the gameTeams array
            //which contains team objects
            //gameTeams = new Team[2];
            myGameScreen = new frmGameScreen(this,l);
            //this sets the mdiParent the forms composing the game screen
            //to the inGame container form
            weaponsMenu.MdiParent = inGame;
            myGameScreen.MdiParent = inGame;
            myTimer.MdiParent = inGame;
            //this tells the forms to show
            inGame.Show();
            myGameScreen.Show();
            myTimer.Show();
            inGame.Show();
            for(int teamOn = 0; teamOn <= 1; teamOn++)
            {
                inGame.displays[teamOn].setTeamName(gameTeams[teamOn].teamName);
                this.gameTeams[teamOn].setCreator(this);
            }
            //this gives the myGameScreen object focus
            //myViewer.Show();
            top.MdiParent = inGame;
            top.Show();
            myGameScreen.Activate();
            nextTurn();
            nextTurn();
            //myThreadStart = new ThreadStart(this.serverComm);
            //System.IAsyncResult m = null;
            //m = myThreadStart.BeginInvoke(new AsyncCallback(caller),null);
            this.gameTeams = t;
            iAmClient = true;
        }