Пример #1
0
        public void CheckHit(Projectile p)
        {
            foreach (Water w in Waters)
            {
                if (w.bounds.Contains(Helper.VtoP(p.Position)))
                {
                    if (p.Position.Y > w.bounds.Top && p.Position.Y < w.bounds.Top + 15)
                    {
                        AudioController.PlaySFX("splash", 0.2f, 0f, 0.1f, p.Position);
                        w.Splash(p.Position.X, 50);
                    }

                    p.Active = false;
                }
            }
        }
Пример #2
0
        void ExplodeGrenade(Projectile p, bool hurtsEnemies)
        {
            p.Active = false;
            p.alpha = 0;
            p.Life = 0;

            for (float r = 0; r < 200; r += 20f)
            {
                for (float circ = 0; circ < MathHelper.TwoPi; circ += 0.25f)
                {
                    Vector2 checkPos = p.Position + Helper.AngleToVector(circ, r);

                    Vector2 speed = (p.Position - checkPos);
                    speed.Normalize();

                    if(!hurtsEnemies)
                        GameManager.Hero.CheckHit(checkPos, speed * 2f, ProjectileType.Grenade, true);

                    if(hurtsEnemies)
                        foreach (Enemy e in GameManager.EnemyController.Enemies)
                            e.CheckHit(checkPos, speed);
                 }
            }

            GameManager.ParticleController.AddExplosion(p.Position);
            AudioController.PlaySFX("explode", 0.9f, -0.5f, 0f, p.Position);

            if (hurtsEnemies)
                GameManager.HUD.AddScore(ScorePartType.Grenade);
        }