Exemplo n.º 1
0
        internal void CalculateEnemyFireHit()
        {
            for (int i = 0; i < EnemyBullets.Count; i++)
            {
                EnemyWeapons e = EnemyBullets[i];

                if (e.X + e.RadiusX > Player.X && e.X < Player.X + Player.Width && e.Y + e.RadiusY > Player.Y &&
                    e.Y < Player.Y + Player.Height)
                {
                    var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 0.5f, 1.0f, e.X, e.Y, 15, 15, 5);
                    var res = spriteController.AddExplosion(animatedExplosion, 10);
                    Explosions.Add(res);
                    int dmg = e.Power;
                     FloatingTexts.Add(new DamageText(Player.X + Player.Width / 2, Player.Y, dmg));
                    if (Player.Shield > 0 && Player.Shield > dmg && Player.ShieldOn)
                    {
                        Player.Shield -= dmg;
                        dmg = 0;
                    }
                    else if (Player.Shield > 0 && Player.ShieldOn)
                    {
                        while (Player.Shield > 0)
                        {
                            Player.Shield--;
                            dmg--;
                        }
                    }
                    if (dmg > 0)
                    {
                        Player.Healt -= dmg;
                    }

                    EnemyBullets.RemoveAt(i);
                    i--;
                }
            }
        }
Exemplo n.º 2
0
 private void AddExplosion(Enemy e)
 {
     SoundController.PlayExplosion();
     var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 1.0f, 0.5f, e.X, e.Y, e.Width, e.Height, e.Speed);
     var res = spriteController.AddExplosion(animatedExplosion, 10);
     Explosions.Add(res);
 }
Exemplo n.º 3
0
        internal void CalculateBulletsHits()
        {
            for (int i = 0; i < bulletController.Bullets.Count; i++)
            {
                bool expl = false;
                PlayerWeapon pw = bulletController.Bullets[i];
                for (int j = 0; j < EnemyList.Count; j++)
                {
                    Enemy e = EnemyList[j];
                    if (pw.X + pw.RadiusX > e.X && pw.X < e.X + e.Width && pw.Y + pw.RadiusY > e.Y &&
                        pw.Y < e.Y + e.Height)
                    {
                        e.Healt = e.Healt - pw.Power;
                        FloatingTexts.Add(new DamageText(e.X + e.Width / 2, e.Y, pw.Power));
                        expl = true;
                        try
                        {
                            bulletController.Bullets.RemoveAt(i);
                            i--;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }

                    if (e.Healt <= 0)
                    {
                        if (e.Boss)
                        {
                            BossMode = false;
                            Level++;
                        }
                        AddLoot(e);
                        AddExplosion(e);

                        Score += e.Points;
                        Kills++;
                        if (!BossMode)
                        {
                            _progresser = true;
                        }

                        EnemyList.RemoveAt(j);
                        j--;
                    }
                    if(expl){
                        var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 0.5f, 1.0f, pw.X, pw.Y, 15, 15, 0);
                        var res = spriteController.AddExplosion(animatedExplosion, 10);
                        Explosions.Add(res);
                    }
                }
            }
        }
Exemplo n.º 4
0
 internal void CalculateBullets()
 {
     bulletController.Calculate();
     foreach (var playerWeapon in bulletController.Bullets)
     {
         if (playerWeapon is Rocket)
         {
             var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 0.5f, 1.0f, playerWeapon.X, playerWeapon.Y, 10, 10, 0);
             var res = spriteController.AddExplosion(animatedExplosion, 20);
             Explosions.Add(res);
         }
     }
 }
Exemplo n.º 5
0
        internal void AddBullet()
        {
            DateTime now = DateTime.Now;
            if ((now - _lastShot).TotalMilliseconds > (int)ShootSpeed)
            {
                if (AmmoCounter[ChoosenWeapon - 1] > 0)
                {
                    if (Ammo == Ammos.Bullet)
                    {
                        SoundController.PlayBulletSound();
                        if (DamageMulti > 3)
                        {
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width -10,
                                                                 Player.Y + (Player.Height / 2) - 20, 5 * DamageMulti));
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width - 5,
                                                                 Player.Y + (Player.Height / 2) - 10, 5 * DamageMulti));
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width - 5,
                                                                 Player.Y + (Player.Height / 2) + 10, 5 * DamageMulti));
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width - 10,
                                                                 Player.Y + (Player.Height / 2) + 20, 5 * DamageMulti));
                        }
                        else if (DamageMulti > 2)
                        {
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width,
                                                                 Player.Y + (Player.Height / 2) - 10, 5 * DamageMulti));
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width,
                                                                 Player.Y + (Player.Height / 2) + 10, 5 * DamageMulti));
                        }
                        else
                        {
                            bulletController.AddShoot(new Bullet(Player.X + Player.Width, Player.Y + (Player.Height / 2),
                                                                 5 * DamageMulti));
                        }
                    }
                    if (Ammo == Ammos.Spreader)
                    {
                        SoundController.PlaySpreaderSound();
                        if (DamageMulti > 4)
                        {
                            bulletController.AddShoot(new Spreader(Player, 4, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 5, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 6, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 7, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 8, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 9, 10 * DamageMulti));
                        }
                        else
                        {
                            bulletController.AddShoot(new Spreader(Player, 1, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 2, 10 * DamageMulti));
                            bulletController.AddShoot(new Spreader(Player, 3, 10 * DamageMulti));
                        }
                    }
                    if (Ammo == Ammos.Rocket)
                    {
                        if (DamageMulti > 5)
                        {
                            bulletController.AddShoot(new Rocket(20*DamageMulti, EnemyList));
                            bulletController.AddShoot(new Rocket(20 * DamageMulti, EnemyList));
                        }
                        else
                        {
                            bulletController.AddShoot(new Rocket(20 * DamageMulti, EnemyList));
                        }
                    }

                    if (Ammo == Ammos.Whirl)
                    {
                        int xx = 0;
            int yy = 0;
            int t = 0;
                        for (int i = 0; i < 60; i++)
                        {
                            if (t == 0)
                            {
                                xx = 5;
                                yy = 0;
                            }
                            if (t == 1)
                            {
                                xx = 3;
                                yy = -2;
                            }
                            if (t == 2)
                            {
                                xx = 2;
                                yy = -3;
                            }
                            if (t == 3)
                            {
                                xx = 0;
                                yy = -5;
                            }
                            if (t == 4)
                            {
                                xx = -2;
                                yy = -3;
                            }
                            if (t == 5)
                            {
                                xx = -3;
                                yy = -2;
                            }
                            if (t == 6)
                            {
                                xx = -5;
                                yy = 0;
                            }
                            if (t == 7)
                            {
                                xx = -3;
                                yy = 2;
                            }
                            if (t == 8)
                            {
                                xx = -2;
                                yy = 3;
                            }
                            if (t == 9)
                            {
                                xx = 0;
                                yy = 5;
                            }
                            if (t == 10)
                            {
                                xx = 2;
                                yy = 3;
                            }
                            if (t == 11)
                            {
                                xx = 3;
                                yy = 2;
                            }

                            bulletController.AddShoot(new Whirl(10*DamageMulti, xx, yy, i));
                            t++;
                            if (t == 12)
                            {
                                t = 0;
                            }

                        }

                    }

                    if (Ammo == Ammos.Laser)
                    {
                        Enemy tmp = FireLaser();

                        if (tmp != null)
                        {
                            bulletController.AddShoot(new Laser(Player.X, Player.Y, Player.Width, Player.Height, tmp.X,
                                                                3 * DamageMulti));
                            tmp.Healt -= 3 * DamageMulti;
                            FloatingTexts.Add(new DamageText(tmp.X + tmp.Width/2, tmp.Y, 3* DamageMulti));
                            var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 0.5f, 1.0f, tmp.X, Player.Y+(Player.Height/2)-7, 15, 15, 0);
                            var res = spriteController.AddExplosion(animatedExplosion, 10);
                            Explosions.Add(res);
                        }
                        else
                        {
                            bulletController.AddShoot(new Laser(Player.X, Player.Y, Player.Width, Player.Height,
                                                                Game1.SWidth, 3 * DamageMulti));
                        }
                    }
                    AmmoCounter[ChoosenWeapon - 1]--;
                    _lastShot = DateTime.Now;
                }
            }
        }
Exemplo n.º 6
0
        public void RemoveEnemyBullets()
        {
            for (int i = 0; i < EnemyBullets.Count; i++)
            {
                if (EnemyBullets[i].X < -20 || EnemyBullets[i].X > Game1.SWidth + 20 || EnemyBullets[i].Y < 0 - 20 ||
                    EnemyBullets[i].Y > Game1.SHeight + 20)
                {
                    EnemyBullets.RemoveAt((i));
                    i--;
                    continue;
                }

                if (EnemyBullets[i] is EBomb)
                {
                    if (((EBomb) EnemyBullets[i]).destruct <= 0)
                    {
                        var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 0.5f, 1.0f, EnemyBullets[i].X-10, EnemyBullets[i].Y-10, 40, 40, 0);
                        var res = spriteController.AddExplosion(animatedExplosion, 10);
                        Explosions.Add(res);
                        EnemyBullets.RemoveAt((i));
                        i--;
                    }
                }
                var laser = EnemyBullets[i] as ELaser;
                if (laser != null)
                {
                    if (laser.Fired)
                    {
                        EnemyBullets.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Exemplo n.º 7
0
 internal AnimatedExplosion AddExplosion(AnimatedExplosion animatedTexture, int s)
 {
     if (s == 0)
     {
         s = 10;
     }
     Texture2D t = null;
     t = SelectExplosionTexture(t);
     animatedTexture.Load(t, s);
     var frames = new int[4] { 4, 4, 4, 4 };
     animatedTexture.defineFrames(4, frames);
     animatedTexture.setRow(1);
     return animatedTexture;
 }