Ejemplo n.º 1
0
 public void PlaySoundEffect(SoundEffectEnum effectToPlay, float pitch)
 {
     audioChannels[currentChannel].pitch = pitch;
     audioChannels[currentChannel].clip  = soundEffects[(int)effectToPlay];
     audioChannels[currentChannel].Play();
     NextChannel();
 }
Ejemplo n.º 2
0
 public void PlaySound(SoundEffectEnum sound)
 {
     if (!Settings.Instance.MyAppSettings.GameSettings.IsSoundOn)
         return;
     m_soundEffectInstance = m_sounds[sound];
     m_soundEffectInstance.Volume = Settings.Instance.MyAppSettings.GameSettings.SoundVolume;
     m_soundEffectInstance.Play();
 }
Ejemplo n.º 3
0
    public void PlayParticularSe(SoundEffectEnum _se, float _volume = 1f)
    {
        this.seLoopSet.Add(_se, this.seSources[(int)_se]);

        this.seLoopSet[_se].volume = _volume;
        this.seLoopSet[_se].loop   = true;
        this.seLoopSet[_se].clip   = this.seClips[(int)_se];
        this.seLoopSet[_se].Play();
    }
Ejemplo n.º 4
0
    public void PlaySe(SoundEffectEnum _se, float _volume = 1f)
    {
        int index = this.SearchSeSouresIndex();

        if (index != -1)
        {
            this.seSources[index].volume = _volume;
            this.seSources[index].loop   = false;
            this.seSources[index].PlayOneShot(this.seClips[(int)_se]);
        }
    }
Ejemplo n.º 5
0
 protected override void InitialiseClickSounds()
 {
     hexClickSounds = new SoundEffectEnum[5]
     {
         SoundEffectEnum.ES_01,
         SoundEffectEnum.ES_02,
         SoundEffectEnum.ES_03,
         SoundEffectEnum.ES_04,
         SoundEffectEnum.ES_05
     };
 }
Ejemplo n.º 6
0
    private AudioClip GetSFXClip(SoundEffectEnum _Effect)
    {
        for (int Index = 0; Index < AvaliableSoundEffects.Count; Index++)
        {
            if (AvaliableSoundEffects[Index].SFXEnum == _Effect)
            {
                return(AvaliableSoundEffects[Index].Clip);
            }
        }

        Debug.Log("Sound Clip Does not Exist");
        return(null);
    }
Ejemplo n.º 7
0
    public void PlayOneShot(SoundEffectEnum _Effect)
    {
        AudioSource AS = GetAvaliableSFXSource();

        if (AS == null) //This could add to pending sfx list but CBA
        {
            return;
        }

        AudioClip Clip = GetSFXClip(_Effect);

        AS.PlayOneShot(Clip, MaxSFXVolume);
    }
Ejemplo n.º 8
0
    private string GetSoundEffectFileName(SoundEffectEnum soundEffect)
    {
        switch (soundEffect)
        {
        case SoundEffectEnum.ArthurHurt: return("arthur-hurt-2");

        case SoundEffectEnum.ArthurHurtByFire: return("arthur-burnt-by-fire");

        case SoundEffectEnum.ArthurHelmetClosing: return("helmet-closing");

        case SoundEffectEnum.Cauldron: return("magic-cauldron");

        case SoundEffectEnum.CurseIntro: return("Curse-intro-sound");

        case SoundEffectEnum.Dash: return("dash");

        case SoundEffectEnum.Footsteps: return("footstep");

        case SoundEffectEnum.FrankensteinHurt: return("frankenstein-hurt");

        case SoundEffectEnum.GhostHurt: return("ghost-hurt");

        case SoundEffectEnum.GravestoneMoving: return("gravestone-moving");

        case SoundEffectEnum.HealthPotion: return("gravestone-moving");

        case SoundEffectEnum.Hurt: return("hurt-sound");

        case SoundEffectEnum.Jump: return("jump-sound");

        case SoundEffectEnum.Landing: return("landing-sound");

        case SoundEffectEnum.SmashCauldron: return("smashing-cauldron");

        case SoundEffectEnum.Slash1: return("slash-sound");

        case SoundEffectEnum.Slash2: return("slash-2-sound");

        case SoundEffectEnum.SpiderHurt: return("spider-hurt");

        case SoundEffectEnum.Stab: return("stab");

        case SoundEffectEnum.WitchCackle: return("witch-cackle");

        case SoundEffectEnum.WitchHurt:  return("witch-hurt");
        }

        return("nosound");
    }
Ejemplo n.º 9
0
    public void PlaySoundEffect(SoundEffectEnum soundEffect, float?volume = null)
    {
        AudioClip audioClip = null;

        try
        {
            var file = GetSoundEffectFileName(soundEffect);

            if (!string.IsNullOrWhiteSpace(file))
            {
                audioClip = Resources.Load(file) as AudioClip;
            }
        }
        catch (Exception ex)
        {
            Debug.LogError($"Failed to play sound effect '{soundEffect}' due to error '{ex.Message}'");
        }

        if (audioClip != null) // what if something is currently playing? delay?
        {
            _audioSource.PlayOneShot(audioClip, volume ?? _audioSource.volume);
        }
    }