Exemple #1
0
 public void Events(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Left)
     {
         soldier.MoveLeft();
     }
     else if (e.KeyCode == Keys.Right)
     {
         soldier.MoveRight();
     }
     else if (e.KeyCode == Keys.Up)
     {
         soldier.MoveUp();
     }
     else if (e.KeyCode == Keys.Down)
     {
         soldier.MoveDown();
     }
     else if (e.KeyCode == Keys.J)
     {
         new System.Threading.Thread(() =>
         {
             Jets jets = new Jets(g, myjet, this);
             jets.moveEm(ant, soldier);
         }).Start();
     }
     else if (e.KeyCode == Keys.S)
     {
         Glock glock = new Glock(es, panel, myexplosion, this, g, soldier.Four_X, soldier.Four_Y + 50, ant, soldier, mybullet);
         System.Collections.Generic.List <GlockBullies> bulless = glock.Sheut();
         glock.exe(glock.randomizeShiets(bulless));
     }
 }
Exemple #2
0
    private void drawRandomSpace()
    {
        SolidBrush brush = new SolidBrush(Color.Black);
        Rectangle  rect  = new Rectangle(0, 0, 1280, 750);

        g.FillRectangle(brush, rect);

        SolidBrush whiteBrush = new SolidBrush(Color.White);
        Pen        pen        = new Pen(whiteBrush);

        for (int i = 0; i < 70; i++)
        {
            int x = r.Next(1280);
            int y = r.Next(750);

            g.DrawEllipse(pen, x, y, 1, 1);
        }

        if (oneup)
        {
            oney -= 10;
            g.DrawImage(submarineLeftUp, onex, oney, 80, 300);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, onex / 20, oney / 20, bulletOne, ship);
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (oney < 1)
            {
                oneup = false;
            }
        }
        else
        {
            oney += 10;
            g.DrawImage(submarineLeftDown, onex, oney, 80, 300);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, onex / 20, oney / 20, bulletOne, ship);
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (oney > 803)
            {
                oneup = true;
            }
        }

        if (threeup)
        {
            threey -= 10;
            g.DrawImage(submarineRightUp, threex, threey, 80, 300);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, threex / 20, threey / 20, bulletThree, ship);
                gl.opp();
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (threey < 1)
            {
                threeup = false;
            }
        }
        else
        {
            threey += 10;
            g.DrawImage(submarineRightDown, threex, threey, 80, 300);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, threex / 20, threey / 20, bulletThree, ship);
                gl.opp();
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (threey > 803)
            {
                threeup = true;
            }
        }

        if (twoleft)
        {
            twox -= 10;
            g.DrawImage(submarineTopLeft, twox, twoy, 300, 80);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, twox / 20, twoy / 20, bulletTwo, ship);
                gl.ver();
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (twox < 1)
            {
                twoleft = false;
            }
        }
        else
        {
            twox += 10;
            g.DrawImage(submarineTopRight, twox, twoy, 300, 80);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, twox / 20, twoy / 20, bulletTwo, ship);
                gl.ver();
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (twox > 1280)
            {
                twoleft = true;
            }
        }

        if (fourleft)
        {
            fourx -= 10;
            if (fourx < 0)
            {
                fourx += 10;
            }
            g.DrawImage(submarineBottomLeft, fourx, foury, 300, 80);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, fourx / 20, foury / 20, bulletFour, ship);
                gl.ver();
                gl.opp();
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
            if (fourx < 1)
            {
                fourleft = false;
            }
        }
        else
        {
            fourx += 10;
            if (fourx > 1280)
            {
                fourleft = true;
            }
            if (fourx > 1280)
            {
                fourx -= 10;
            }
            g.DrawImage(submarineBottomRight, fourx, foury, 300, 80);
            int v = r.Next((35 - level) * 15 - level / 2);
            if (v == 1 || v == 2 || v == 3 || v == 4 || v == 5 || v == 6 || v == 7 || v == 8)
            {
                Glock gl = new Glock(explosion, g, fourx / 20, foury / 20, bulletFour, ship);
                gl.ver();
                gl.opp();
                gl.exe(gl.randomizeShiets(gl.Sheut()));
                B.AddRange(gl.B);
            }
        }

        for (int k = 0; k < B.Count; k++)
        {
            if (B[k].dead != true)
            {
                try
                {
                    g.DrawImage(B[k].myBullet, B[k].whereami.X * 20, B[k].whereami.Y * 20, B[k].myBullet.Width / 2, B[k].myBullet.Height / 2);
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                B.Remove(B[k]);
            }
        }

        if (ship.direction.Equals("up"))
        {
            ship.y -= 1;
            Image gg = shipup.GetNextFrame();
            g.DrawImage(gg, ship.x * 20, ship.y * 20, 40, 40);
        }
        if (ship.direction.Equals("down"))
        {
            ship.y += 1;
            Image gg = shipdown.GetNextFrame();
            g.DrawImage(gg, ship.x * 20, ship.y * 20, 40, 40);
        }
        if (ship.direction.Equals("left"))
        {
            ship.x -= 1;
            Image gg = shipleft.GetNextFrame();
            g.DrawImage(gg, ship.x * 20, ship.y * 20, 40, 40);
        }
        if (ship.direction.Equals("right"))
        {
            ship.x += 1;
            Image gg = shipright.GetNextFrame();
            g.DrawImage(gg, ship.x * 20, ship.y * 20, 40, 40);
        }

        for (int i = 0; i < monsters.Count; i++)
        {
            if (i < monsters.Count)
            {
                int x  = r.Next(2) - r.Next(2);
                int y  = r.Next(2) - r.Next(2);
                int v  = r.Next(20);
                int v2 = r.Next(7);
                if (level % 2 == 0)
                {
                    if (v == 4)
                    {
                        monsters[i].follow = !monsters[i].follow;
                    }
                    else if (v2 == 4)
                    {
                        monsters[i].follow = !monsters[i].follow;
                    }

                    if (monsters[i].follow)
                    {
                        monsters[i].move = !monsters[i].move;
                        if (ship.x < monsters[i].x && monsters[i].move)
                        {
                            monsters[i].x--;
                        }
                        if (ship.y < monsters[i].y && monsters[i].move)
                        {
                            monsters[i].y--;
                        }

                        if (ship.x > monsters[i].x && monsters[i].move)
                        {
                            monsters[i].x++;
                        }
                        if (ship.y > monsters[i].y && monsters[i].move)
                        {
                            monsters[i].y++;
                        }
                    }
                }
                if (!monsters[i].follow)
                {
                    monsters[i].move = !monsters[i].move;
                    if (monsters[i].move)
                    {
                        monsters[i].x += x;
                        monsters[i].y += y;
                    }
                }
                if (ship.x == monsters[i].x && ship.y == monsters[i].y)
                {
                    ship.life -= 100;
                    explode();
                }
                try
                {
                    Image m = null;
                    if (monsters[i].follow)
                    {
                        m = monsterFollow;
                    }
                    else
                    {
                        m = monster;
                    }
                    g.DrawImage(m, monsters[i].x * 20, monsters[i].y * 20, 35, 35);
                }
                catch (Exception ex)
                {
                }
            }
        }

        for (int i = 0; i < caps.Count; i++)
        {
            if (i < caps.Count)
            {
                try
                {
                    g.DrawImage(energy, caps[i].x * 20, caps[i].y * 20, 40, 40);
                    if (ship.x == caps[i].x && ship.y == caps[i].y)
                    {
                        ship.life += 20;
                        g.DrawImage(explosion, ship.x * 20, ship.y * 20, 68, 68);
                        //threadPlayDing.Start();
                        explode();
                        eliminateCapsule(caps[i]);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
    }