Пример #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("Hit a thing! " + other);
        if (hitSplat == null)
        {
            hitSplat = GameObject.Find("HitSplat");
            Debug.Log(this + " - needs HitSplat.");
        }

        AbstractEnemyControl enemy = other.GetComponent <AbstractEnemyControl> ();

        if (enemy)
        {
            // Hit an enemy! Do death!
            enemy.damage(damage, type, knockback);
            GameObject splat = Instantiate(hitSplat) as GameObject;
            splat.transform.parent   = enemy.transform;
            splat.transform.position = enemy.transform.position;
            splat.transform.Translate(0, 1, -1);
        }
        else
        {
            AbstractBossControl boss = other.GetComponent <AbstractBossControl> ();
            if (boss)
            {
                // Hit a boss! Do death!
                boss.damage(damage, type, knockback);
                GameObject splat = Instantiate(hitSplat) as GameObject;
                splat.transform.parent   = boss.transform;
                splat.transform.position = boss.transform.position;
                splat.transform.Translate(0, 1, -1);
            }
        }
    }
Пример #2
0
 public override void OnTriggerEnter2D(Collider2D collider)
 {
     if (state == MermaidState.fly)
     {
         Debug.Log("What Did I Hit? " + collider.tag);
         AbstractClass ac = collider.GetComponent <AbstractClass> ();
         if (ac != null)
         {
             AbstractEnemyControl ec = collider.GetComponent <AbstractEnemyControl> ();
             if (ec != null)
             {
                 // Give pain and bounce.
                 ec.damage(damage, AbstractDamageCollider.DamageType.heavy, knockback);
                 //state = MermaidState.explode;
                 //explode ();
             }
         }
     }
 }