Exemplo n.º 1
0
    public void CheckObjectCollision(List<FutilePlatformerBaseObject> objects)
    {
        foreach (FutilePlatformerBaseObject o in objects)
        {
            if (o is Enemy)
            {
                Enemy e = (Enemy)o;
                if (!hits.Contains(e) && e.isColliding(this))
                {
                    hits.Add(e);
                    e.TakeDamage(GetUnitVectorDirection(CurrentDirection) * 2);
                    Hit h = new Hit();
                    h.SetPosition((this.GetPosition() + e.GetPosition()) / 2f);
                    world.AddForegroundSprite(h);
                }
            }
            if (o is Ninja)
            {
                Ninja n = (Ninja)o;
                if (!n.isRetreating && !hits.Contains(n) && n.isoHeight < 6 && n.isColliding(this))
                {
                    hits.Add(n);
                    n.TakeDamage(GetUnitVectorDirection(CurrentDirection) * 2);
                    Hit h = new Hit();
                    h.SetPosition((this.GetPosition() + n.GetPosition()) / 2f);
                    world.AddForegroundSprite(h);
                }

            }
        }
    }