Ejemplo n.º 1
0
        public static void PlayEffect(Gunhouse.SoundInfo effect, bool loop = false)
        {
            if (!enabled)
            {
                Setup();
            }

            if (effect.lastPlayed + frameDelay > Time.frameCount)
            {
                return;
            }

            for (int i = 0; i < MAX_EFFECT_LAYERS; ++i)
            {
                if (loadedEffectHases[i] != effect.file.GetHashCode())
                {
                    continue;
                }
                if (effectLayers[i].isPlaying)
                {
                    continue;
                }
                effectLayers[i].volume = EffectVolume * effect.volume;
                effectLayers[i].loop   = loop;
                effectLayers[i].Play();
                effect.lastPlayed = Time.frameCount;

                return;
            }

            for (int i = 0; i < MAX_EFFECT_LAYERS; ++i)
            {
                if (effectLayers[i].isPlaying)
                {
                    continue;
                }

                loadedEffectHases[i]   = effect.file.GetHashCode();
                effectLayers[i].clip   = GetClip("SoundEffects/" + effect.file);
                effectLayers[i].volume = EffectVolume * effect.volume;
                effectLayers[i].loop   = loop;
                effectLayers[i].Play();
                effect.lastPlayed = Time.frameCount;
                return;
            }
        }
Ejemplo n.º 2
0
        public static void StopEffect(Gunhouse.SoundInfo effect)
        {
            if (!enabled)
            {
                Setup();
            }

            for (int i = 0; i < MAX_EFFECT_LAYERS; ++i)
            {
                if (loadedEffectHases[i] != effect.file.GetHashCode())
                {
                    continue;
                }
                if (!effectLayers[i].isPlaying)
                {
                    continue;
                }

                effectLayers[i].Stop();
                return;
            }
        }