示例#1
0
 public Tank(Game cg,Team t,string n,int initx, int inity)
 {
     name = n;
     creatorGame = cg;
     myTeam = t;
     x = initx;
     y = inity;
 }
示例#2
0
 //public gameServer myServer;
 public Server(NetworkStream sk,Game g)
 {
     containerGame = g;
     //mySocket = sk;
     serverNetStream = sk; //new NetworkStream(mySocket);
     clientWriter =new StreamWriter(serverNetStream);
     clientReader =new StreamReader(serverNetStream);
     reciveThread =new Thread(new ThreadStart(reciveString));
     reciveThread.Start();
 }
示例#3
0
 public Team(Game c, string tn)
 {
     r = new Random(seed);
     seed = Convert.ToInt32(System.DateTime.Now.Millisecond);
     creator = c;
     teamName = tn;
     tanks[0] = new Tank(creator,this,"tank1",r.Next(800),r.Next(200));//these should have random X,Y s
     tanks[1] = new Tank(creator,this,"tank2",r.Next(800),r.Next(200));
     tanks[2] = new Tank(creator,this,"tank3",r.Next(800),r.Next(200));
     tanks[3] = new Tank(creator,this,"tank4",r.Next(800),r.Next(200));
 }
        public frmGameContainer(Game creator)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
示例#5
0
 public Team(Game c,gameClient g)
 {
     // Network Version Of Team
     r = new Random(seed);
     seed = Convert.ToInt32(System.DateTime.Now.Millisecond);
     creator = c;
     myClient = g;
     teamName = myClient.name;
     tanks[0] = new Tank(creator,this,"tank1",r.Next(800),r.Next(200));//these should have random X,Y s
     tanks[1] = new Tank(creator,this,"tank2",r.Next(800),r.Next(200));
     tanks[2] = new Tank(creator,this,"tank3",r.Next(800),r.Next(200));
     tanks[3] = new Tank(creator,this,"tank4",r.Next(800),r.Next(200));
 }
        public frmWeaponsMenu(Game c)
        {
            creator =c;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            inactiveColor = Color.Blue;
            activeColor = Color.Red;
            this.Invalidate();
        }
示例#7
0
 public void setCreator(Game g)
 {
     // Sets the creator of each tank
     this.creator = g;
     for(int x = tanks.Length-1; x >= 0; x--)
         tanks[x].creatorGame = g;
 }
示例#8
0
        public void ApplyPhysics(Game c)
        {
            creator = c;
            if(isAlive == true)
            {

                //try
                //{
                if(y > 6)
                {

                    if((creator.myGameScreen.backGroundWithTanks.GetPixel(x,y) != creator.myGameScreen.skyColor)&&(creator.myGameScreen.backGround.GetPixel(x,y-5) == creator.myGameScreen.skyColor))
                    {
                        groundColide();
                        stop();
                    }
                    else if((creator.myGameScreen.backGround.GetPixel(x,y) != creator.myGameScreen.skyColor)||(creator.myGameScreen.backGround.GetPixel(x,y-5) != creator.myGameScreen.skyColor))
                    {
                        // this is used if a solid has hit the ground
                        y -= 4;
                        groundColide();
                        stop();

                    }

                    else //(((creator.myGameScreen.backGround.GetPixel(x-5,y) == creator.myGameScreen.skyColor)||(creator.myGameScreen.backGround.GetPixel(x+5,y) == creator.myGameScreen.skyColor)))
                    {
                        yvel += 2;

                    }
                }
                else
                {
                    yvel += 2;
                }

                //if((creator.myGameScreen.backGround.GetPixel(x+xvel,y+yvel) != creator.myGameScreen.skyColor))
                //{

                //}

                //this stops solids going off the edge

                if(x+xvel <= 5)
                {
                    //die();
                    x=1017;
                    //x= 20;
                }
                else if(x+xvel >= 1017)
                {
                    //die();
                    x=5;
                    //x-=20;
                }
                if(y+yvel <= 30||y <=30)
                {
                    //die();
                    //y= 30;
                }
                else if((y+yvel >= 430)||y >= 430 )
                {
                    //y=415;
                    //die();
                    //y = 400;
                    applyDamage(100);
                    groundColide();

                }
             /*
                if(y >0&&x >0)
                {
                    if((creator.myGameScreen.backGround.GetPixel(x+3,y-20) == creator.myGameScreen.skyColor)&&(creator.myGameScreen.backGround.GetPixel(x-3,y-20) == creator.myGameScreen.skyColor))
                    {
                        x+=(xvel/2);
                    }
                    else
                    {
                        stop();
                        groundColide();

                    }
                }
                else
                {
                */
                    x+=(xvel/2);
                //}

                y+=(yvel/2);

            }

            //catch(Exception e)
            //{
                //die(this);
                //creator.nextTurn();

            //}
        }
 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();
 }
示例#10
0
        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");
                }
            }
        }
示例#11
0
 public void endGame(Team winnerName)
 {
     frmEndGame endStatsDisplay = new frmEndGame(winnerName,this);
     endStatsDisplay.Show();
     myGame = null;
 }
        public frmGameScreen(Game c,string l)
        {
            //********     BITMAPS    *************************
            // Instanciate backGround with the image at path l
            backGround                 = new Bitmap(Image.FromFile(l));
            // Instanciate backGroundWithTanks with the same attributes as backGround
            backGroundWithTanks        = new Bitmap(backGround);
            // Instanciate backGroundWithTanks with the same attributes as backGround
            backGroundWithTanksDetails = new Bitmap(backGround);

            //******* GRAPHICS OBJECTS *************************
            // Graphics classes for drawing on different Bitmaps
            g     = Graphics.FromImage(frame);
            b     = Graphics.FromImage(backGround);
            e     = Graphics.FromImage(explotionLayer);
            bgwt  = Graphics.FromImage(backGroundWithTanks);
            bgwtad= Graphics.FromImage(backGroundWithTanksDetails);

            skyColor = backGround.GetPixel(1,1);

            //*******  BRUSH OBJECTS  **************************
            //brushes to draw fire/explotions and to draw sky
            skyBrush =  new SolidBrush(skyColor);
            fireBrush = new SolidBrush(fireColor);

            /* Set the sky color as the color at pixel 1,1 this means the the
             * game adapts to the image.*/

            // creator is the game class this is contained in
            creator = c;
            //********************************************************************************************************
            //                            DRAW OVER HEAD LABELS
            //********************************************************************************************************
            // Create a 2D array of bitmaps for th lables (number of teams) X 4
            overHeadLables = new Bitmap[creator.gameTeams.Length,4];
            //******** ~~ Go Through all teams and tanks *********************************
            for(int loopTeam = creator.gameTeams.Length-1; loopTeam >= 0; loopTeam --){
                for(int loopTank = 3; loopTank >= 0; loopTank--){

                    //create a new Bitmap on the current index
                    this.overHeadLables[loopTeam,loopTank] = new Bitmap(70,50);
                    //set the graphis object lbltxt to reference the current Bitmap
                    lbltxt = Graphics.FromImage(overHeadLables[loopTeam,loopTank]);
                    //This creates a rectangle to draw a string on to
                    lbltxt.FillRectangle(displayBrush,0,0,70,30);
                    //Display team name above each tank
                    lbltxt.DrawString(creator.gameTeams[loopTeam].teamName,myFont,textBrush,2,2);
                    //Display tank name above each tank
                    lbltxt.DrawString(creator.gameTeams[loopTeam].tanks[loopTank].name,myFont,textBrush,2,16);

                    }
            }
            //***********************************************************************************************************

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
        }