示例#1
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();
        }
示例#2
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;
        }