Beispiel #1
0
 public virtual void Die()
 {
     ExplosionEnnemi exp = new ExplosionEnnemi(Game, 0.1f, Rotation, Position);
     Game.Components.Add(exp);
     RemoveEnemy();
 }
Beispiel #2
0
 public virtual void DieWithSound()
 {
     ExplosionEnnemi exp = new ExplosionEnnemi(Game, 0.1f, Rotation, Position);
     Game.Components.Add(exp);
     SonExplosionEnnemi.Play(0.5f,0f,0f);
 }
Beispiel #3
0
        protected virtual void CheckHit()
        {
            List<GameComponent> l = new List<GameComponent>();
            Projectile p;
            Ennemi e;
            foreach (GameComponent c in Game.Components)
            {
                if (c is Projectile)
                {
                    p = c as Projectile;
                    if (!p.friendly)
                    {
                        if (LaneIndex == p.LaneIndex)
                        {
                            if (Math.Abs(p.Position.Z - Position.Z) <= 0.3)
                            {
                                l.Add(p);
                                remove = true;
                            }
                        }
                    }
                }
                else if (c is Ennemi)
                {
                    e = c as Ennemi;
                    if (friendly && LaneIndex == e.LaneIndex)
                    {
                        if (e is Fuseball)
                        {
                            if (Math.Abs(e.Position.Z - Position.Z) < 0.3f && (e as Fuseball).CanBeHit && !(e as Fuseball).OnTop)
                            {
                                remove = true;
                                l.Add(e);
                            }
                        }
                        else
                        {
                            if (Math.Abs(e.Position.Z - Position.Z) <= 0.3f)
                            {
                                remove = true;
                                l.Add(e);
                            }
                        }
                    }
                }
            }
            Level cL = Data.Player.level_;
            if (cL.Spikes[LaneIndex] > 0)
            {
                if (Position.Z <= cL.vSpikes[LaneIndex].Origin.Z + cL.vSpikes[LaneIndex].delta.Z)
                {
                    cL.Spikes[LaneIndex]--;
                    cL.MakeSpike(LaneIndex);
                    remove = true;
                    (Game as Game1).AddScore(cL.Spikes[LaneIndex] > 0 ? 2 : 1);
                }
            }

            foreach (GameComponent c in l)
            {
                if (c is Ennemi)
                {
                    (c as Ennemi).DieByPlayer();
                }
                if(c is Projectile)
                {
                    Projectile j = c as Projectile;
                    ExplosionEnnemi exp = new ExplosionEnnemi(Game, 0.1f, j.Rotation, j.Position);
                    Game.Components.Add(exp);
                    j.remove = true;
                }
            }
        }