Beispiel #1
0
    void OnParticleCollision(GameObject other)
    {
        if (!OnParticleCollisionActivated)
        {
            return;
        }

        AudioSubscription sub = FindSubscriptionForEvent(AudioSourceStandardEvent.OnParticleCollision);

        if (sub == null)
        {
            return;
        }

        if (sub.filterLayers && (sub.layerMask & 1 << other.layer) != 0)
        {
            return;
        }
        if (sub.filterTags && !sub.tags.Contains(other.tag))
        {
            return;
        }
        if (sub.filterNames && !sub.names.Contains(other.name))
        {
            return;
        }

        PlaySoundInternal(AudioSourceStandardEvent.OnParticleCollision);
    }
Beispiel #2
0
    void OnTriggerExit(Collider other)
    {
        if (!OnTriggerExitActivated)
        {
            return;
        }

        AudioSubscription sub = FindSubscriptionForEvent(AudioSourceStandardEvent.OnTriggerExit);

        if (sub == null)
        {
            return;
        }

        if (sub.filterLayers && (sub.layerMask & 1 << other.gameObject.layer) != 0)
        {
            return;
        }
        if (sub.filterTags && !sub.tags.Contains(other.gameObject.tag))
        {
            return;
        }
        if (sub.filterNames && !sub.names.Contains(other.gameObject.name))
        {
            return;
        }

        PlaySoundInternal(AudioSourceStandardEvent.OnTriggerExit);
    }
Beispiel #3
0
    /// <summary>
    /// Calls the correct play handler by standard event.
    /// </summary>
    void PlaySoundInternal(AudioSourceStandardEvent evt)
    {
        AudioSubscription sub = FindSubscriptionForEvent(evt);

        if (sub == null)
        {
            return;
        }

        switch (sub.actionType)
        {
        case AudioSourceAction.Play:
            PlayHandler();
            break;

        case AudioSourceAction.PlayLoop:
            PlayLoopHandler();
            break;

        case AudioSourceAction.PlayCapped:
            PlayCappedHandler(sub.cappedName);
            break;

        case AudioSourceAction.Stop:
            StopHandler();
            break;

        case AudioSourceAction.None:
        default:
            return;
        }
    }
Beispiel #4
0
    void OnCollisionEnter(Collision collision)
    {
        if (!OnCollisionEnterActivated)
        {
            return;
        }

        AudioSubscription sub = FindSubscriptionForEvent(AudioSourceStandardEvent.OnCollisionEnter);

        if (sub == null)
        {
            return;
        }

        if (sub.filterLayers && (sub.layerMask & 1 << collision.gameObject.layer) != 0)
        {
            return;
        }
        if (sub.filterTags && !sub.tags.Contains(collision.gameObject.tag))
        {
            return;
        }
        if (sub.filterNames && !sub.names.Contains(collision.gameObject.name))
        {
            return;
        }

        PlaySoundInternal(AudioSourceStandardEvent.OnCollisionEnter);
    }
    private bool IsAlreadyBound(string eventName, int index)
    {
        if (eventName == nullEvent)
        {
            return(false);
        }

        AudioSubscription boundSubscription = script.audioSubscriptions.Find(delegate(AudioSubscription obj) {
            return((script.audioSubscriptions.IndexOf(obj) != index) && (obj.isStandardEvent ? (Enum.IsDefined(typeof(AudioSourceStandardEvent), obj.methodName) && obj.methodName == eventName) : obj.methodName == eventName));
        });

        if (boundSubscription == null)
        {
            return(false);
        }
        return(true);
    }