Beispiel #1
0
    void OnTriggerStay(Collider other)
    {
        // Debug.Log(string.Format("Entity {0} touched other: {1}", this.collider.name, other.name));

        BaseCollision collision = other.GetComponent <BaseCollision>();

        // tell this entity that someone else touched it
        if (collision is EntityCollision)
        {
            EntityCollision entityCollision = (EntityCollision)collision;
            entity.TouchedByEntity(entityCollision.entity);
        }
        // tell this entity that some one else's weapon touched it
        else if (collision is WeaponCollision)
        {
            WeaponCollision weaponCollision = (WeaponCollision)collision;
            entity.TouchedByWeapon(weaponCollision.weapon);
        }
        else if (collision is WallCollision)
        {
            entity.TouchedByWall(other);
        }
        else if (collision is PotCollision)
        {
            PotCollision potCollision = (PotCollision)collision;
            entity.TouchedByPot(potCollision.pot);
        }
    }
Beispiel #2
0
    void OnTriggerStay(Collider other)
    {
        // tell the this weapon's owner that another weapon touched it.
        BaseCollision collision = other.GetComponent <BaseCollision>();

        if (collision is WeaponCollision)
        {
            WeaponCollision weaponCollision = (WeaponCollision)collision;
            weapon.owner.WeaponTouchedByWeapon(weaponCollision.weapon);
        }

        // tell the this weapon's owner that someone touched it.
        else if (collision is EntityCollision)
        {
            EntityCollision entityCollision = (EntityCollision)collision;
            weapon.owner.WeaponTouchedByEntity(entityCollision.entity);
        }

        else if (collision is PotCollision)
        {
            PotCollision potCollision = (PotCollision)collision;
            weapon.owner.WeaponTouchedByPot(potCollision.pot);
        }
    }