Exemplo n.º 1
0
        private void enemy_CreateBulletCurtain(Enemy e, int scale)
        {
            Point  xy = e.getShootPlace();
            int    velocity = 5, i = 0;
            double interval = 100 / (scale - 1);
            double start = -1 * (scale - 1) / 2 * interval;
            double vX = 0, vY = 0;
            double normal = 0;

            //label7.Text = interval.ToString();
            for (i = 0; i < scale; i++)
            {
                EnemyBullet eb = new EnemyBullet(xy.X + 20, xy.Y + 10);

                normal = Normalizer(start, 100);

                vX  = start / normal;
                vY  = 100 / normal;
                vX *= velocity;
                vY *= velocity;
                eb.SetV(vX, vY);
                start += interval;
                if (enemyBullet.LastIndexOf(null) != -1)
                {
                    enemyBullet.Insert(enemyBullet.LastIndexOf(null), eb);
                }
                else
                {
                    enemyBullet.Add(eb);
                }

                //this.panel1.Controls.Add(eb.img);
            }
        }
Exemplo n.º 2
0
        void Fire()
        {
            if (player.IsAlive)
            {
                fireCount++;
                if (fireCount == 180)
                {
                    fireCount = 0;

                    var dir = player.Position - Position;

                    var bullet = new EnemyBullet(dir)
                    {
                        Position = Position
                    };

                    Layer.AddObject(bullet);
                }
            }
        }
Exemplo n.º 3
0
        private void enemy_CreateBullet(Enemy e)
        {
            if (e.canShoot() && e.Shootmode != "None")
            {
                String mode = e.getShootMode();
                Point  xy   = e.getShootPlace();
                switch (mode)
                {
                case "Line":
                    EnemyBullet ebLine = new EnemyBullet(xy.X, xy.Y);
                    if (enemyBullet.LastIndexOf(null) != -1)
                    {
                        enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebLine);
                    }
                    else
                    {
                        enemyBullet.Add(ebLine);
                    }
                    //this.panel1.Controls.Add(ebLine.img);
                    break;

                case "Ray":
                    EnemyBullet ebRay   = new EnemyBullet(xy.X, xy.Y);
                    Vector2D    bulletV = e.getVelocity(player.lx, player.ly);
                    ebRay.SetV(bulletV.x, bulletV.y);
                    ebRay.setImage(STARBOX[Randomizer.Next(0, 5)]);
                    if (enemyBullet.LastIndexOf(null) != -1)
                    {
                        enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRay);
                    }
                    else
                    {
                        enemyBullet.Add(ebRay);
                    }
                    //this.panel1.Controls.Add(ebRay.img);
                    break;

                case "Circle":
                    EnemyBullet ebCircle = new EnemyBullet(xy.X, xy.Y);
                    ebCircle.setMoveMode("Circle");
                    ebCircle.setXY(e.lx, e.ly);
                    ebCircle.setImage("BlueBigCircle");
                    if (enemyBullet.LastIndexOf(null) != -1)
                    {
                        enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebCircle);
                    }
                    else
                    {
                        enemyBullet.Add(ebCircle);
                    }
                    //this.panel1.Controls.Add(ebCircle.img);
                    break;

                case "Cos":
                    EnemyBullet ebCosine = new EnemyBullet(xy.X, xy.Y);
                    ebCosine.setMoveMode("Cos");
                    ebCosine.useGreenRay();
                    if (enemyBullet.LastIndexOf(null) != -1)
                    {
                        enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebCosine);
                    }
                    else
                    {
                        enemyBullet.Add(ebCosine);
                    }
                    //this.panel1.Controls.Add(ebCosine.img);
                    break;

                case "Split-3":
                    enemy_CreateBulletCurtain(e, 5);
                    break;

                case "Split-5":
                    enemy_CreateBulletCurtain(e, 5);
                    break;

                case "Berserk":
                    EnemyBullet ebBerserk = new EnemyBullet(xy.X, xy.Y);
                    Vector2D    bulletBV  = e.getVelocity(player.lx, player.ly);
                    ebBerserk.setImage(BIGSIZE[Randomizer.Next(0, 3)]);
                    ebBerserk.SetV(bulletBV.x, bulletBV.y);
                    if (enemyBullet.LastIndexOf(null) != -1)
                    {
                        enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebBerserk);
                    }
                    else
                    {
                        enemyBullet.Add(ebBerserk);
                    }
                    //this.panel1.Controls.Add(ebBerserk.img);
                    break;

                case "Round":
                    double rx = 0, ry = 0;
                    while (rx < Math.PI * 2)
                    {
                        rx += Math.PI / 10;
                        ry += Math.PI / 10;
                        EnemyBullet ebRound = new EnemyBullet(xy.X + 6, xy.Y + 20);
                        ebRound.setImage("SkySignleCircle");
                        ebRound.SetV(Math.Sin(rx) * 3, Math.Cos(ry) * 3);
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRound);
                        }
                        else
                        {
                            enemyBullet.Add(ebRound);
                        }
                    }
                    break;

                case "Boss-Round":
                    flag = (flag == 0.314) ? 0 : 0.314;
                    double rlx = flag, rly = flag;
                    while (rlx < Math.PI * 2)
                    {
                        rlx += Math.PI / 15;
                        rly += Math.PI / 15;
                        EnemyBullet ebRound = new EnemyBullet(xy.X + 6, xy.Y + 20);
                        ebRound.setImage("SkyBigCircle");
                        ebRound.SetV(Math.Sin(rlx) * 3, Math.Cos(rly) * 3);
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRound);
                        }
                        else
                        {
                            enemyBullet.Add(ebRound);
                        }
                    }

                    break;

                case "Boss-Cross":
                    int iCross = 0;
                    for (iCross = 0; iCross < 5; iCross++)
                    {
                        EnemyBullet ebCross;
                        int         choice = Randomizer.Next(0, 2);
                        if (choice == 0)
                        {
                            ebCross = new EnemyBullet(Randomizer.Next(0, 620), Randomizer.Next(600, 700));
                            ebCross.SetV(0, -2.5);
                        }
                        else
                        {
                            ebCross = new EnemyBullet(Randomizer.Next(0, 620), Randomizer.Next(-100, 0));
                            ebCross.SetV(0, 2.5);
                        }
                        ebCross.setImage(HEARTBOX[Randomizer.Next(0, 3)]);

                        if (ebCross.vy > 0)
                        {
                            ebCross.img.Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        }

                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebCross);
                        }
                        else
                        {
                            enemyBullet.Add(ebCross);
                        }
                    }
                    break;

                case "Boss-Rec":
                    EnemyBullet ebRec;
                    int         RecYRange = 120, RecXRange = 120;
                    int         Reci;
                    for (Reci = 30; Reci < this.Width; Reci += RecXRange)
                    {
                        ebRec = new EnemyBullet(Reci, -10);
                        ebRec.SetV(0, 1);
                        ebRec.setImage("SkySignleCircle");
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRec);
                        }
                        else
                        {
                            enemyBullet.Add(ebRec);
                        }
                    }

                    for (Reci = 75; Reci < this.Width; Reci += RecXRange)
                    {
                        ebRec = new EnemyBullet(Reci, 625);
                        ebRec.SetV(0, -1);
                        ebRec.setImage("BlueSignleCircle");
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRec);
                        }
                        else
                        {
                            enemyBullet.Add(ebRec);
                        }
                    }

                    for (Reci = 75; Reci < this.Height; Reci += RecYRange)
                    {
                        ebRec = new EnemyBullet(0, Reci);
                        ebRec.SetV(1, 0);
                        ebRec.setImage("GreenSignleCircle");
                        RecFlipY = false;
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRec);
                        }
                        else
                        {
                            enemyBullet.Add(ebRec);
                        }
                    }

                    for (Reci = 30; Reci < this.Height; Reci += RecYRange)
                    {
                        ebRec = new EnemyBullet(600, Reci);
                        ebRec.SetV(-1, 0);
                        ebRec.setImage("PurpleSignleCircle");
                        RecFlipY = false;
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRec);
                        }
                        else
                        {
                            enemyBullet.Add(ebRec);
                        }
                    }

                    if (Randomizer.Next(0, 38) > 20)
                    {
                        ebRec = new EnemyBullet(xy.X, xy.Y);
                        Vector2D bulletRECV = e.getVelocity(player.lx, player.ly);
                        ebRec.SetV(bulletRECV.x, bulletRECV.y);
                        ebRec.setImage("SkyRoundCircle");
                        if (enemyBullet.LastIndexOf(null) != -1)
                        {
                            enemyBullet.Insert(enemyBullet.LastIndexOf(null), ebRec);
                        }
                        else
                        {
                            enemyBullet.Add(ebRec);
                        }
                    }
                    break;
                }
            }
        }