コード例 #1
0
    protected KMAudio.KMAudioRef PlayGameSoundHandlerWithRef(KMSoundOverride.SoundEffect sound, Transform t)
    {
        KMAudio.KMAudioRef kmaudioRef = new KMAudio.KMAudioRef();
        if (audioSource == null)
        {
            return(kmaudioRef);
        }
        var clip = SoundEffects.GetAudioClip(sound);

        if (clip == null)
        {
            return(kmaudioRef);
        }
        try
        {
            audioSource.transform.position = t.position;
        }
        catch
        {
        }
        audioSource.loop = false;
        audioSource.PlayOneShot(clip);
        KMAudio.KMAudioRef kmaudioRef2 = kmaudioRef;
        kmaudioRef2.StopSound = (Action)Delegate.Combine(kmaudioRef2.StopSound, new Action(delegate
        {
            if (audioSource.isPlaying)
            {
                audioSource.Stop();
            }
        }));
        return(kmaudioRef);
    }
コード例 #2
0
 public static void PlaySound(KMSoundOverride.SoundEffect effectOverride, Transform transform)
 {
     if (ModSoundMap.GroupNameMap.TryGetValue(effectOverride, out string effect))
     {
         MasterAudio.PlaySound3DAtTransformAndForget(effect, transform, 1f, null, 0f, null);
     }
 }
コード例 #3
0
 /// <summary>
 /// Play an existing game sound (or its override) at the given transform.
 /// </summary>
 /// <param name="sound"></param>
 /// <param name="transform"></param>
 public void PlayGameSoundAtTransform(KMSoundOverride.SoundEffect sound, Transform transform)
 {
     if (HandlePlayGameSoundAtTransform != null)
     {
         HandlePlayGameSoundAtTransform(sound, transform);
     }
 }
コード例 #4
0
    /// <summary>
    /// Play an existing game sound (or its override) at the given transform.
    /// </summary>
    /// <param name="sound"></param>
    /// <param name="transform"></param>
    /// <returns>A KMAudioRef that can be used to stop sounds early</returns>
    public KMAudioRef PlayGameSoundAtTransformWithRef(KMSoundOverride.SoundEffect sound, Transform transform)
    {
        if (HandlePlayGameSoundAtTransformWithRef != null)
        {
            return(HandlePlayGameSoundAtTransformWithRef(sound, transform));
        }

        return(null);
    }
コード例 #5
0
        public AudioClip GetAudioClip(KMSoundOverride.SoundEffect effect)
        {
            List <AudioClip> clips;

            if (!_soundEffects.TryGetValue(effect, out clips))
            {
                return(null);
            }
            if (clips == null || clips.Count == 0)
            {
                return(null);
            }
            return(clips[UnityEngine.Random.Range(0, clips.Count)]);
        }
コード例 #6
0
    public void TurnLightsOn()
    {
        RenderSettings.ambientIntensity = 1f;
        DynamicGI.UpdateEnvironment();

        foreach (Light l in FindObjectsOfType <Light>())
        {
            if (l.transform.parent == null)
            {
                l.enabled = true;
            }
        }
        PlayGameSoundHandler(_lightsOnEffect, transform);
        _lightsOnEffect = KMSoundOverride.SoundEffect.LightBuzzShort;
    }
コード例 #7
0
 protected void PlayGameSoundHandler(KMSoundOverride.SoundEffect sound, Transform t)
 {
     PlayGameSoundHandlerWithRef(sound, t);
 }