Beispiel #1
0
 public override bool Hit()
 {
     if (hitPoints > 0)
     {
         hitPoints--;
         damaged = true;
         if (hitPoints > 0)
         {
             Game.PlaySound(Sound.EnemyDamage);
         }
     }
     if (hitPoints == 0)
     {
         isDead = true;
         foreach (Funnel funnel in funnels)
         {
             /*
              * int startAngle = Game.Random.Next(90);
              * for (int i = 0; i < 8; i++)
              * {
              *  int angle = startAngle + i * 45 + Game.Random.Next(-45, 46);
              *  double x = funnel.X + 16 * Utility.Cos(angle);
              *  double y = funnel.Y - 16 * Utility.Sin(angle);
              *  double speed = 0.5 + 1.5 * Game.Random.NextDouble();
              *  Effect debris = new Debris(Game, x, y, 255, 128, 0, speed, angle);
              *  Game.AddEffect(debris);
              * }
              */
             Effect effect = new BigExplosionEffect(Game, funnel.X, funnel.Y, Game.Random.Next(360), 255, 224, 192);
             Game.AddEffect(effect);
         }
         {
             int startAngle = Game.Random.Next(90);
             for (int i = 0; i < 8; i++)
             {
                 int    angle  = startAngle + i * 45 + Game.Random.Next(-45, 46);
                 double x      = X + 16 * Utility.Cos(angle);
                 double y      = Y - 16 * Utility.Sin(angle);
                 double speed  = 0.5 + 1.5 * Game.Random.NextDouble();
                 Effect debris = new Debris(Game, x, y, 0, 0, 255, speed, angle);
                 Game.AddEffect(debris);
             }
             Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 192, 192, 255);
             Game.AddEffect(effect);
             Game.PlaySound(Sound.Explosion);
         }
         hitPoints--;
     }
     return(true);
 }
Beispiel #2
0
        public override void Update()
        {
            double x     = X - 16 * Utility.Cos(Angle);
            double y     = Y + 16 * Utility.Sin(Angle);
            Effect smoke = new Smoke(Game, x, y, Game.Random.Next(360));

            Game.AddEffect(smoke);

            if (ticks < LIFE_TICKS)
            {
                int deg = Utility.NormalizeDeg(Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X) - Angle);
                if (deg == -180)
                {
                    Angle += Game.Random.Next(2) == 0 ? 1 : -1;
                }
                else if (Math.Abs(deg) < 6)
                {
                    Angle = Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X);
                }
                else
                {
                    if (deg < 0)
                    {
                        Angle -= 6;
                    }
                    else if (deg > 0)
                    {
                        Angle += 6;
                    }
                }
            }

            vx += Utility.Cos(Angle);
            vy -= Utility.Sin(Angle);

            if (vx * vx + vy * vy > MAX_SPEED * MAX_SPEED)
            {
                double rad = Math.Atan2(vy, vx);
                vx = MAX_SPEED * Math.Cos(rad);
                vy = MAX_SPEED * Math.Sin(rad);
            }

            X += vx;
            Y += vy;

            ticks++;
        }
Beispiel #3
0
        public override bool Hit()
        {
            isDead = true;
            int startAngle = Game.Random.Next(90);

            for (int i = 0; i < 8; i++)
            {
                int    angle  = startAngle + i * 45 + Game.Random.Next(-45, 46);
                double x      = X + 16 * Utility.Cos(angle);
                double y      = Y - 16 * Utility.Sin(angle);
                double speed  = 0.5 + 1.5 * Game.Random.NextDouble();
                Effect debris = new Debris(Game, x, y, 255, 0, 0, speed, angle);
                Game.AddEffect(debris);
            }
            Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 192, 192);

            Game.AddEffect(effect);
            Game.PlaySound(Sound.Explosion);
            return(true);
        }
Beispiel #4
0
 public override bool Hit()
 {
     if (hitPoints > 0)
     {
         hitPoints--;
         damaged = true;
         if (hitPoints > 0)
         {
             Game.PlaySound(Sound.EnemyDamage);
         }
     }
     if (hitPoints == 0)
     {
         Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255);
         Game.AddEffect(effect);
         Game.PlaySound(Sound.Explosion);
         // ˆê‰ž
         hitPoints--;
     }
     return(true);
 }
Beispiel #5
0
        public override void Update()
        {
            damaged = false;

            if (isDying)
            {
                if (dyingCount < 30)
                {
                    if (dyingCount % 2 == 0)
                    {
                        Effect effect = new SmallExplosionEffect(Game, X + Game.Random.Next(-64, 64 + 1), Y + Game.Random.Next(-32, 32 + - +1), Game.Random.Next(0, 360));
                        Game.AddEffect(effect);
                        if (dyingCount % 4 == 0)
                        {
                            Game.PlaySound(Sound.Explosion);
                        }
                    }
                    dyingCount++;
                    if (dyingCount == 30)
                    {
                        int startAngle = Game.Random.Next(90);
                        for (int i = 0; i < 20; i++)
                        {
                            int    angle  = startAngle + i * 18 + Game.Random.Next(-18, 19);
                            double x      = X + 64 * Utility.Cos(angle);
                            double y      = Y - 32 * Utility.Sin(angle);
                            double speed  = 0.5 + 1.5 * Game.Random.NextDouble();
                            Effect debris = new Debris(Game, x, y, 80, 80, 80, speed, angle);
                            Game.AddEffect(debris);
                        }
                        for (int i = -1; i <= 1; i++)
                        {
                            Effect effect = new BigExplosionEffect(Game, X - i * 48, Y, Game.Random.Next(0, 360), 255, 255, 255);
                            Game.AddEffect(effect);
                        }
                        Game.PlaySound(Sound.Explosion);
                    }
                }
                return;
            }

            if (moveCount > 0)
            {
                moveCount--;
                if (attackMode == 0)
                {
                    if (!(Math.Abs(X - targetX) < 32 && Math.Abs(Y - targetY) < 32))
                    {
                        Effect smoke1 = new Smoke(Game, X - 24, Y - 24, Game.Random.Next(0, 360));
                        Effect smoke2 = new Smoke(Game, X + 24, Y - 24, Game.Random.Next(0, 360));
                        Game.AddEffect(smoke1);
                        Game.AddEffect(smoke2);
                    }
                }
                if (!Game.Player.IsDead)
                {
                    if (attackMode == 1)
                    {
                        if (moveCount == 4)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                        else if (moveCount == 8)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                    }
                    else if (attackMode == 2)
                    {
                        if (moveCount == 4)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                        else if (moveCount == 8)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                    }
                    else if (attackMode == 3)
                    {
                        if (moveCount == 12)
                        {
                            Bullet missile = new Missile(Game, X, Y + 16 - 32 * Utility.Sin(255), 270);
                            Game.AddEnemyBullet(missile);
                            Game.PlaySound(Sound.MissileFire);
                        }
                    }
                }
            }
            else
            {
                if (attackMode > 0)
                {
                    attackMode = Game.Random.Next(0, 4);
                }
                else
                {
                    attackMode = Game.Random.Next(1, 4);
                }
                targetX = (int)Math.Round(Game.Player.X) + Game.Random.Next(-32, 32 + 1);
                if (attackMode == 0)
                {
                    targetY = Game.FieldHeight - 32;
                }
                else
                {
                    targetY = Game.FieldHeight / 4 + Game.Random.Next(-32, 64 + 1);
                }

                /*
                 * if (hitPoints > 48)
                 * {
                 *  moveCount = Game.Random.Next(30, 60);
                 * }
                 * else if (hitPoints > 24)
                 * {
                 *  moveCount = Game.Random.Next(25, 50);
                 * }
                 * else
                 * {
                 *  moveCount = Game.Random.Next(20, 40);
                 * }
                 */
                moveCount = Game.Random.Next(20, 30);
                if (targetX < 80)
                {
                    targetX = 80;
                }
                else if (targetX > Game.FieldWidth - 80)
                {
                    targetX = Game.FieldWidth - 80;
                }
            }
            x2 = targetX * 0.125 + x2 * 0.875;
            y2 = targetY * 0.125 + y2 * 0.875;
            X  = x2 * 0.125 + X * 0.875;
            Y  = y2 * 0.125 + Y * 0.875;
        }
Beispiel #6
0
 public override void Hit()
 {
     isDead = true;
     Game.AddEffect(new SmallExplosionEffect(Game, X, Y, Game.Random.Next(360)));
 }
Beispiel #7
0
        public override void Update()
        {
            damaged = false;

            if (isDying)
            {
                if (dyingCount < 60)
                {
                    if (dyingCount % 2 == 0)
                    {
                        Effect effect = new SmallExplosionEffect(Game, X + Game.Random.Next(-32, 32 + 1), Y + Game.Random.Next(-32, 32 + - +1), Game.Random.Next(0, 360));
                        Game.AddEffect(effect);
                        if (dyingCount % 4 == 0)
                        {
                            Game.PlaySound(Sound.Explosion);
                        }
                    }
                    dyingCount++;
                    if (dyingCount == 60)
                    {
                        Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(0, 360), 255, 255, 255);
                        Game.AddEffect(effect);
                        Game.PlaySound(Sound.Explosion);
                    }
                }
                return;
            }

            if (moveCount > 0)
            {
                moveCount--;
            }
            else
            {
                targetX   = Game.FieldWidth / 2 + Game.Random.Next(-64, 64 + 1);
                targetY   = Game.FieldHeight / 4 - Game.Random.Next(0, 64 + 1);
                moveCount = Game.Random.Next(30, 60);
            }

            spawnEnemyType = (192 - hitPoints) / 32;
            if (!Game.Player.IsDead && !isDying && Game.Ticks >= 60)
            {
                switch (spawnEnemyType)
                {
                case 0:
                    if (Game.Ticks % 8 == 0)
                    {
                        Effect effect = new GreenEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64));
                        Game.AddEffect(effect);
                    }
                    break;

                case 1:
                    if (Game.Ticks % 8 == 0)
                    {
                        Effect effect = new BlueEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64));
                        Game.AddEffect(effect);
                    }
                    break;

                case 2:
                    if (Game.Ticks % 8 == 0)
                    {
                        Effect effect = new RedEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64));
                        Game.AddEffect(effect);
                    }
                    break;

                case 3:
                    if (Game.Ticks % 16 == 0)
                    {
                        Effect effect = new OrangeEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64));
                        Game.AddEffect(effect);
                    }
                    break;

                case 4:
                    if (Game.Ticks % 16 == 0)
                    {
                        Effect effect = new MissileEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64));
                        Game.AddEffect(effect);
                    }
                    break;

                case 5:
                    if (Game.Ticks % 16 == 0)
                    {
                        Effect effect = new KurageSpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64));
                        Game.AddEffect(effect);
                    }
                    break;
                }
            }
            else
            {
                hitPoints = 192;
            }

            x2 = targetX * 0.125 + x2 * 0.875;
            y2 = targetY * 0.125 + y2 * 0.875;
            X  = x2 * 0.125 + X * 0.875;
            Y  = y2 * 0.125 + Y * 0.875;

            animation = (animation + 1) % 8;
        }
Beispiel #8
0
        public override void Update()
        {
            damaged = false;

            if (isDying)
            {
                if (dyingCount < POS_BUF_LEN_SUM)
                {
                    if (dyingCount % POS_BUF_LEN == 0)
                    {
                        bodies[dyingCount / POS_BUF_LEN].Destroy();
                    }
                    dyingCount++;
                }
                if (dyingCount == POS_BUF_LEN_SUM)
                {
                    int startAngle = Game.Random.Next(90);
                    for (int i = 0; i < 12; i++)
                    {
                        int    angle  = startAngle + i * 30 + Game.Random.Next(-30, 31);
                        double x      = X + 32 * Utility.Cos(angle);
                        double y      = Y - 32 * Utility.Sin(angle);
                        double speed  = 0.5 + 1.5 * Game.Random.NextDouble();
                        Effect debris = new Debris(Game, x, y, 128, 128, 128, speed, angle);
                        Game.AddEffect(debris);
                    }
                    Effect effect1 = new BigExplosionEffect(Game, X + 16, Y, Game.Random.Next(360), 255, 255, 255);
                    Effect effect2 = new BigExplosionEffect(Game, X, Y - 16, Game.Random.Next(360), 255, 255, 255);
                    Effect effect3 = new BigExplosionEffect(Game, X - 16, Y, Game.Random.Next(360), 255, 255, 255);
                    Effect effect4 = new BigExplosionEffect(Game, X, Y + 16, Game.Random.Next(360), 255, 255, 255);
                    Game.AddEffect(effect1);
                    Game.AddEffect(effect2);
                    Game.AddEffect(effect3);
                    Game.AddEffect(effect4);
                    Game.PlaySound(Sound.Explosion);
                }
                return;
            }

            px = X;
            py = Y;
            for (int i = 0; i < POS_BUF_LEN_SUM - 1; i++)
            {
                posBufX[i]  = posBufX[i + 1];
                posBufY[i]  = posBufY[i + 1];
                angleBuf[i] = angleBuf[i + 1];
            }
            posBufX[POS_BUF_LEN_SUM - 1]  = X;
            posBufY[POS_BUF_LEN_SUM - 1]  = Y;
            angleBuf[POS_BUF_LEN_SUM - 1] = this.angle;

            if (Game.Ticks % 30 == 0)
            {
                if (Game.Random.Next(0, 8) != 0)
                {
                    targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1);
                    targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 192 + 1);
                }
                else
                {
                    targetX = (int)Math.Round(Game.Player.X);
                    targetY = (int)Math.Round(Game.Player.Y);
                }
            }
            if (Math.Abs(targetX - X) < 32 && Math.Abs(targetY - Y) < 32)
            {
                targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1);
                targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 192 + 1);
            }

            if (X < targetX)
            {
                vx += 1;
            }
            else if (targetX < X)
            {
                vx -= 1;
            }
            if (Math.Abs(vx) > MAX_SPEED)
            {
                vx = Math.Sign(vx) * MAX_SPEED;
            }
            if (Y < targetY)
            {
                vy += 1;
            }
            else if (targetY < Y)
            {
                vy -= 1;
            }
            if (Math.Abs(vy) > MAX_SPEED)
            {
                vy = Math.Sign(vy) * MAX_SPEED;
            }
            X += vx;
            Y += vy;

            for (int i = 0; i < NUM_BODIES; i++)
            {
                int index = POS_BUF_LEN * i;
                bodies[i].X     = posBufX[index];
                bodies[i].Y     = posBufY[index];
                bodies[i].Angle = angleBuf[index];
            }

            {
                int deg = Utility.NormalizeDeg(Utility.Atan2(py - Y, X - px) - angle);
                if (deg == -180)
                {
                    angle += Game.Random.Next(2) == 0 ? 1 : -1;
                }
                else if (Math.Abs(deg) < 16)
                {
                    angle = Utility.Atan2(py - Y, X - px);
                }
                else
                {
                    if (deg < 0)
                    {
                        angle -= 16;
                    }
                    else if (deg > 0)
                    {
                        angle += 16;
                    }
                }
            }

            if (attackCount > 0)
            {
                attackCount--;
                if (!Game.Player.IsDead)
                {
                    if (attackCount / 2 < NUM_BODIES)
                    {
                        if (attackCount % 2 == 0)
                        {
                            SnakeBody body   = bodies[attackCount / 2];
                            int       a      = Utility.Atan2(body.Y - Game.Player.Y, Game.Player.X - body.X) + Game.Random.Next(-45, 45 + 1);
                            Bullet    bullet = new SnakeBullet(Game, body.X, body.Y, Game.Random.Next(4, 8 + 1), a);
                            Game.AddEnemyBullet(bullet);
                        }
                    }
                }
            }
            else
            {
                attackCount = Game.Random.Next(60, 90);
            }
        }