Beispiel #1
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        layer = coll.gameObject.layer;

        if (layer == ENEMY_WEAPON)
        {
            enemyWeapon = coll.GetComponent <Weapon>();

            if (!enemyWeapon.alreadyCollided && !levelCompleted && !dead)
            {
                if (enemyWeapon.weaponType == Weapon.WeaponType.Hammer ||
                    enemyWeapon.weaponType == Weapon.WeaponType.Dagger ||
                    enemyWeapon.weaponType == Weapon.WeaponType.MagicProjectile)
                {
                    enemyWeapon.alreadyCollided = true;

                    SendMessageUpwards("TakesHit", hit.Args(gameObject, coll));
                }
            }
        }
        else if (layer == ENEMY_COLLIDER)
        {
            enemy = coll.GetComponent <CreatureEntity>();

            if (!enemy.alreadyCollided && !levelCompleted && !dead)
            {
                if (enemy.entityType == CreatureEntity.EntityType.Enemy)
                {
                    enemy.alreadyCollided = true;

                    // player.TouchesEnemy("touch", enemy, coll, hitFrom);
                }
            }
        }
    }