Exemplo n.º 1
0
 public Zombies()
 {
     x = 0;
     y = 0;
     height = 10;
     width = 10;
     vX = 0;
     vY = 0;
     alive = false;
     gun = new Weapons();
 }
Exemplo n.º 2
0
        public Form1()
        {
            bluePen = new Pen(Color.Blue);
            redPen = new Pen(Color.Red);
            pics = new Pics();
            numBunkers = 3;
            numBunks = numBunkers;
            grPen = new Pen(Color.Green);
            rallyPoint = new Point();
            TNR = new Font("Times New Roman", 12);
            InitializeComponent();
            numBuildings = 30;
            buildings = new Zombies[numBuildings];
            level = 1;
            blPen = new Pen(Color.Black, 2);
            borderX = (int)(pictureBox1.Width * 1.7);
            borderY = (int)(pictureBox1.Width * 1.7);
            numTanks = 3;
            //tanks = new Zombies[numTanks];

            text = this.pictureBox1.CreateGraphics();
            g = this.pictureBox1.CreateGraphics();
            blue = new SolidBrush(Color.Blue);
            white = new SolidBrush(Color.White);
            black = new SolidBrush(Color.Black);
            red = new SolidBrush(Color.Red);
            green = new SolidBrush(Color.Green);
            //timer1.Start();
            chX = pictureBox1.Width / 2;
            chY = pictureBox1.Height / 2;
            screenX = 0;
            screenY = 0;
            zoom = 1.0;
            numZombies = 10;
            numAllies = 10;
            bunkers = new Zombies[numBunkers];

            Zeds = new Zombies[numZombies];
            allies = new Zombies[numAllies];
            guns = new Weapons[80];
            cannons = new Weapons();
            bomb = new Weapons();

            for (int i = 0; i < guns.Length; i++)
            {
                guns[i] = new Weapons();
            }
            rand = new Random();
            createBuildings();
            createZombies(numZombies);
            //createTanks();
            createBunkers();
            numTargets = numZombies;
            numFriendlies = numAllies;
            //g.TranslateTransform(Width / 2, Height / 2);
            bomb.timeFired = 0;
            cannons.timeFired = 0;
            visual.X = pictureBox1.Width;
            visual.Y = pictureBox1.Height;

            mortars = new Weapons[numBunkers];
            createMortars();
            g.TranslateTransform((float)-0.3*borderX, (float)-0.3*borderY);

            zoom *= 0.7;
            g.TranslateTransform(400, 200);
            g.ScaleTransform((float)0.7, (float)0.7);
        }
Exemplo n.º 3
0
        private void drawCrossHairs(int x, int y)
        {
            x -= 20;
            y -= 20;
            text.FillRectangle(black, (float)(((x+25))), (float)((y)), (float)(1), (float)(50.0));
            text.FillRectangle(black, (float)((x)), (float)(((y+25))), (float)(50), (float)(1));
            text.DrawEllipse(blPen, x+5, y+5, 40, 40);

            Weapons w = new Weapons();
            w.x = x;
            w.y = y;

            transformToPlane(w, 0, 0);

            //w.x = (int)(w.x / zoom);
            //w.y = (int)(w.y / zoom);

            //g.FillRectangle(red, (float)(((w.x + 9))), (float)((w.y)), (float)(2.0), (float)(20.0));
            //g.FillRectangle(red, (float)((w.x)), (float)(((w.y + 9))), (float)(20), (float)(2));
            g.FillEllipse(red, (float)w.x, (float)w.y, 20, 20);
            //g.FillRectangle(black, (float)(((x + 9) - screenX)), (float)((y - screenY)), (float)(2.0), (float)(20.0));
            //g.FillRectangle(black, (float)((x - screenX)), (float)(((y + 9) - screenY)), 20, 2);
        }
Exemplo n.º 4
0
 private void createMortars()
 {
     for (int i = 0; i < numBunkers; i++)
     {
         mortars[i] = new Weapons();
         mortars[i].vX = 0;
         mortars[i].vY = 0;
         mortars[i].x = (int)bunkers[i].x;
         mortars[i].y = (int)bunkers[i].y;
         mortars[i].fired = false;
     }
 }
Exemplo n.º 5
0
 private void checkMortars(Weapons[] sh, Zombies[] tgt, bool enemy)
 {
     for (int i = 0; i < sh.Length; i++)
     {
         Rectangle shooter = new Rectangle(sh[i].x, sh[i].y, 60, 60);
         for (int j = 0; j < tgt.Length; j++)
         {
             if (tgt[j].alive)
             {
                 Rectangle target = new Rectangle((int)tgt[j].x, (int)tgt[j].y, (int)tgt[j].width, (int)tgt[j].height);
                 if (shooter.IntersectsWith(target))
                 {
                     //sh[i].gun.fired = false;
                     tgt[j].alive = false;
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
        private void transformToPlane(Weapons W, int offSetX, int offSetY)
        {
            Point[] p = new Point[1];

            int n = (int)Math.Floor(angle/4) + 1;
            p[0] = new Point((int)((pictureBox1.Width / 2) - (offSetX)), (int)((pictureBox1.Height / 2) - (offSetY)));

            g.TransformPoints(System.Drawing.Drawing2D.CoordinateSpace.World, System.Drawing.Drawing2D.CoordinateSpace.Device, p);

            W.x = p[0].X;
            W.y = p[0].Y;
        }
Exemplo n.º 7
0
 private bool strayRounds(Weapons sh)
 {
     Rectangle shooter = new Rectangle((int)sh.x, (int)sh.y, (int)3, (int)3);
     for (int i = 0; i < numBuildings; i++)
     {
         if (buildings[i].alive)
         {
             Rectangle target = new Rectangle((int)buildings[i].x, (int)buildings[i].y, (int)buildings[i].width, (int)buildings[i].height);
             if (shooter.IntersectsWith(target))
             {
                 sh.fired = false;
                 return true;
             }
         }
     }
     return false;
 }