示例#1
0
    public static void PlayMusic(ESound pSound)
    {
        AudioSource source = audioManager.AudioSourceMusic;
        AudioClip   clip   = audioManager.GetSoundClip(pSound);

        TryPlay(source, clip, true, true);
    }
示例#2
0
    public void PlaySound(ESound pKey, float pMaxFrequency = 0, bool pIsLoop = false)
    {
        float lastPlayTime;
        bool  keyExists = lastPlaySoundTime.TryGetValue(pKey, out lastPlayTime);

        if (Time.time - lastPlayTime < pMaxFrequency)
        {
            //Debug.Log($"Cant play sound {pKey}, frequency = {pMaxFrequency}");
            return;
        }
        if (keyExists)
        {
            lastPlaySoundTime[pKey] = Time.time;
        }
        else
        {
            lastPlaySoundTime.Add(pKey, Time.time);
        }

        AudioSource source = InstanceFactory.Instantiate(
            game.AudioSourcePrefab.gameObject).GetComponent <AudioSource>();

        source.gameObject.SetActive(true);
        SoundController.PlaySound(pKey, source, pIsLoop);
    }
    public static void PlaySound(ESound soundId)
    {
        if (_instance == null || soundId == ESound.None)
        {
            return;
        }

        _instance.Play(soundId);
    }
示例#4
0
    public static void PlaySound(ESound pKey, AudioSource pSource, bool pIsLoop = false)
    {
        if (pSource == null)
        {
            pSource = audioManager.AudioSourceNormal;
        }

        AudioClip clip = audioManager.GetSoundClip(pKey);

        TryPlay(pSource, clip, false, pIsLoop);
    }
示例#5
0
 internal void play(ESound eSound, float pitch = 0, float volume = 0.5f)
 {
     if (!playing.IsDisposed)
     {
         if (eSound == ESound.CHOMP && playing.State == SoundState.Playing)
             return;
         playing.Stop();
         playing.Dispose();
     }
     playing = sounds[eSound].CreateInstance();
     playing.Pitch = pitch;
     playing.Volume = volume;
     playing.Play();
 }
示例#6
0
 internal void play(ESound eSound, float pitch = 0, float volume = 0.5f)
 {
     if (!playing.IsDisposed)
     {
         if (eSound == ESound.CHOMP && playing.State == SoundState.Playing)
         {
             return;
         }
         playing.Stop();
         playing.Dispose();
     }
     playing        = sounds[eSound].CreateInstance();
     playing.Pitch  = pitch;
     playing.Volume = volume;
     playing.Play();
 }
示例#7
0
    public AudioClip GetSoundClip(ESound pKey)
    {
        if (!isInited)
        {
            Init();
        }

        AudioClip clip;

        soundClips.TryGetValue(pKey, out clip);
        if (clip == null)
        {
            Debug.LogError($"Sound {pKey} not found");
        }

        return(clip);
    }
示例#8
0
    public void StopSound(ESound sound)
    {
        if (!bPlay)
        {
            return;
        }

        switch (sound)
        {
        case ESound.eCollect:
            break;

        case ESound.eDenial:
            break;

        case ESound.eSpawn:
            break;

        case ESound.eHurt:
            break;

        case ESound.eCoffee:
            StopAudio(coffee_loop);
            break;

        case ESound.eBuild:
            StopAudio(build_loop);
            break;

        case ESound.eUpgradeStarted:
            break;

        case ESound.eUpgradeDone:
            break;

        case ESound.eUpgradeFailed:
            break;

        case ESound.eAgro:
            break;

        default:
            break;
        }
    }
    private void Play(ESound soundId)
    {
        var pd = GameData.GetPlayerData();

        if (!pd.activeSound)
        {
            return;
        }

        _audioSource.volume = pd.soundVolume;

        var clip = _soundSetting.GetSound(soundId);

        if (clip != null)
        {
            _audioSource.PlayOneShot(clip.SoundClip);
        }
    }
示例#10
0
 internal void play(EChannel eChannel, ESound eSound, float pitch = 0, float volume = 0.5f, bool muteOther = true)
 {
     if ((eChannel == EChannel.BGM && !SettingsManager.Instance.Music)
         || (eChannel == EChannel.SFX && !SettingsManager.Instance.Sfx)
         || (muteOther == false && !channels[eChannel].IsDisposed && channels[eChannel].State == SoundState.Playing))// && channels[eChannel].Equals(tmp)))
         return;
     if (!channels[eChannel].IsDisposed)
     {
         channels[eChannel].Stop();
         channels[eChannel].Dispose();
     }
     channels[eChannel] = sounds[eSound].CreateInstance();
     channels[eChannel].Pitch = pitch;
     channels[eChannel].Volume = volume;
     channels[eChannel].IsLooped = (eChannel == EChannel.BGM);
     //channels[eChannel].IsLooped = loop;
     channels[eChannel].Play();
 }
示例#11
0
    public void PlaySound(ESound sound_)
    {
        //Debug.Log("Sound volume:" + s_soundVolume);

        if (sound_ == ESound.SOUND_OK)
        {
            m_asSound.clip = m_acOk;
        }
        else if (sound_ == ESound.SOUND_CANCEL)
        {
            m_asSound.clip = m_acCancel;
        }
        else if (sound_ == ESound.SOUND_SELECT_ITEM)
        {
            m_asSound.clip = m_acSelectItem;
        }
        else if (sound_ == ESound.SOUND_POWER_USED)
        {
            m_asSound.clip = m_acPowerUsed;
        }
        else if (sound_ == ESound.SOUND_STAR_01)
        {
            m_asSound.clip = m_acStar01;
        }
        else if (sound_ == ESound.SOUND_STAR_02)
        {
            m_asSound.clip = m_acStar02;
        }
        else if (sound_ == ESound.SOUND_STAR_03)
        {
            m_asSound.clip = m_acStar03;
        }
        else if (sound_ == ESound.SOUND_ITEM_COLLISION)
        {
            m_asSound.clip = m_itemCollision;
        }

        m_asSound.volume = m_soundVolume;
        m_asSound.Play();
    }
示例#12
0
    /// <summary>
    /// Applies powerup to the player and returns status text
    /// </summary>
    private static string ApplyPowerup(PowerUpConfig pConfig, Player pPlayer)
    {
        ESound sound = ESound.None;

        switch (pConfig.Type)
        {
        case EPowerUp.Health:
            pPlayer.Stats.AddHealth(20);
            sound = ESound.Item_Powerup_Heal;
            break;

        case EPowerUp.Ammo:
            pPlayer.WeaponController.OnPowerUpAmmo();
            sound = ESound.Item_Powerup_Ammo;
            break;

        case EPowerUp.Speed:
            pPlayer.Stats.StatsEffect.ApplyEffect(EPlayerEffect.DoubleSpeed, SPEED_DURATION);                    //, SPEED_VALUE);
            sound = ESound.Item_Powerup_Speed;
            break;

        case EPowerUp.Mystery:
            return(HandleMystery(pPlayer));

        case EPowerUp.Shield:
            pPlayer.Stats.StatsEffect.ApplyEffect(EPlayerEffect.Shield, SHIELD_DURATION);
            sound = ESound.Item_Powerup_Shield;
            break;

        default:
            Debug.LogError($"Powerup {pConfig.Type} not handled!");
            break;
        }
        pPlayer.PlaySound(sound);

        return(pConfig.MapItemInfo.StatusText);
    }
示例#13
0
        public static void PlaySound(ESound ID)
        {
            if (GlobalSetting.IsSoundEffect)
            {
                switch (ID)
                {
                case ESound.SFX_1_UP:
                    if (sfx_1_up != null)
                    {
                        sfx_1_up.Play();
                    }
                    break;

                case ESound.SFX_BREAKBLOCK:
                    if (sfx_breakblock != null)
                    {
                        sfx_breakblock.Play();
                    }
                    break;

                case ESound.SFX_BUMP:
                    if (sfx_bump != null)
                    {
                        sfx_bump.Play();
                    }
                    break;

                case ESound.SFX_COIN:
                    if (sfx_coin != null)
                    {
                        sfx_coin.Play();
                    }
                    break;

                case ESound.SFX_FIREBALL:
                    if (sfx_fireball != null)
                    {
                        sfx_fireball.Play();
                    }
                    break;

                case ESound.SFX_FIREWORK:
                    if (sfx_firework != null)
                    {
                        sfx_firework.Play();
                    }
                    break;

                case ESound.SFX_FLAGPOLE:
                    if (sfx_flagpole != null)
                    {
                        sfx_flagpole.Play();
                    }
                    break;

                case ESound.SFX_GAMEOVER:
                    if (sfx_gameover != null)
                    {
                        sfx_gameover.Play();
                    }
                    break;

                case ESound.SFX_ITEM_APPEAR:
                    if (sfx_item_appear != null)
                    {
                        sfx_item_appear.Play();
                    }
                    break;

                case ESound.SFX_JUMP_BIG:
                    if (sfx_jump_big != null)
                    {
                        sfx_jump_big.Play();
                    }
                    break;

                case ESound.SFX_JUMP_SMALL:
                    if (sfx_jump_small != null)
                    {
                        sfx_jump_small.Play();
                    }
                    break;

                case ESound.SFX_KICK:
                    if (sfx_kick != null)
                    {
                        sfx_kick.Play();
                    }
                    break;

                case ESound.SFX_MARIO_DIE:
                    if (sfx_mario_die != null)
                    {
                        sfx_mario_die.Play();
                    }
                    break;

                case ESound.SFX_MARIO_HURT:
                    if (sfx_mario_hurt != null)
                    {
                        sfx_mario_hurt.Play();
                    }
                    break;

                case ESound.SFX_PAUSE:
                    if (sfx_pause != null)
                    {
                        sfx_pause.Play();
                    }
                    break;

                case ESound.SFX_PIPE:
                    if (sfx_pipe != null)
                    {
                        sfx_pipe.Play();
                    }
                    break;

                case ESound.SFX_POWER_UP:
                    if (sfx_power_up != null)
                    {
                        sfx_power_up.Play();
                    }
                    break;

                case ESound.SFX_STAGE_CLEAR:
                    if (sfx_stage_clear != null)
                    {
                        sfx_stage_clear.Play();
                    }
                    break;

                case ESound.SFX_STOMP:
                    if (sfx_stomp != null)
                    {
                        sfx_stomp.Play();
                    }
                    break;

                case ESound.SFX_VINE:
                    if (sfx_vine != null)
                    {
                        sfx_vine.Play();
                    }
                    break;

                case ESound.SFX_WARNING:
                    if (sfx_warning != null)
                    {
                        sfx_warning.Play();
                    }
                    break;

                case ESound.SFX_WORLD_CLEAR:
                    if (sfx_world_clear != null)
                    {
                        sfx_world_clear.Play();
                    }
                    break;

                default:
                    break;
                }
            }
        }
示例#14
0
    public SoundModel GetSound(ESound soundId)
    {
        var s = Sounds.ToList().Find(g => g.SoundId == soundId);

        return(s);
    }
示例#15
0
        //public void OnMessageBoxAction(IAsyncResult ar)
        //{
        //    int? selectedButton = Guide.EndShowMessageBox(ar);
        //    switch (selectedButton)
        //    {
        //        case 0:
        //            Global.SOUND = true;
        //            SoundManager.GetInstance().PlaySong(ESong.Background);
        //            break;
        //        case 1:
        //            Global.SOUND = false;
        //            MediaPlayer.Resume();
        //            break;
        //        default:
        //            break;
        //    }
        //}
        #endregion

        #region Public methods

        public void PlaySound(ESound id)
        {
            // Check if sound option is OFF
            if (Sound)
            {
                switch (id)
                {
                case ESound.SelectButton:
                    if (SelectButton != null)
                    {
                        SelectButton.Play();
                    }
                    break;

                case ESound.TouchType1:
                    if (TouchType1 != null)
                    {
                        TouchType1.Play();
                    }
                    break;

                case ESound.TouchType2:
                    if (TouchType2 != null)
                    {
                        TouchType2.Play();
                    }
                    break;

                case ESound.TouchType3:
                    if (TouchType3 != null)
                    {
                        TouchType3.Play();
                    }
                    break;

                case ESound.TouchType4:
                    if (TouchType4 != null)
                    {
                        TouchType4.Play();
                    }
                    break;

                case ESound.TouchType5:
                    if (TouchType5 != null)
                    {
                        TouchType5.Play();
                    }
                    break;

                case ESound.TouchType6:
                    if (TouchType6 != null)
                    {
                        TouchType6.Play();
                    }
                    break;

                case ESound.TouchType7:
                    if (TouchType7 != null)
                    {
                        TouchType7.Play();
                    }
                    break;

                case ESound.TouchType8:
                    if (TouchType8 != null)
                    {
                        TouchType8.Play();
                    }
                    break;

                case ESound.Fly:
                    if (Fly != null)
                    {
                        Fly.Play();
                    }
                    break;

                case ESound.CompleteCell:
                    if (CompleteCell != null)
                    {
                        CompleteCell.Play();
                    }
                    break;

                case ESound.FailCell:
                    if (FailCell != null)
                    {
                        FailCell.Play();
                    }
                    break;

                case ESound.LevelComplete:
                    if (LevelComplete != null)
                    {
                        LevelComplete.Play();
                    }
                    break;

                case ESound.ClassicComplete:
                    if (ClassicComplete != null)
                    {
                        ClassicComplete.Play();
                    }
                    break;

                case ESound.TimeUp:
                    if (TimeUp != null)
                    {
                        TimeUp.Play();
                    }
                    break;
                }
            }
        }
示例#16
0
    public void PlaySound(ESound sound)
    {
        if (!bPlay)
        {
            return;
        }

        switch (sound)
        {
        case ESound.eCollect:
            PlayAudio(collect);
            break;

        case ESound.eDenial:
            break;

        case ESound.eSpawn:
            break;

        case ESound.eHurt:
            break;

        case ESound.eCoffee:
            PlayAudio(coffee_loop, true);
            break;

        case ESound.eBuild:
            PlayAudio(build_loop, true);
            break;

        case ESound.eUpgradeStarted:
            break;

        case ESound.eUpgradeDone:
            break;

        case ESound.eUpgradeFailed:
            break;

        case ESound.eAgro:
            PlayAudio(agro[Random.Range(0, 9)]);
            break;

        case ESound.eNewsThrow:
            PlayAudio(news_throw);
            break;

        case ESound.eCitizenDestroy:
            PlayAudio(citizen_destroy[Random.Range(0, 8)]);
            break;

        case ESound.eCitizenNews:
            PlayAudio(citizen_news[Random.Range(0, 16)]);
            break;

        case ESound.eCannotUse:
            PlayAudio(cannot_use);
            break;

        case ESound.eTowerUp:
            PlayAudio(towerUp);
            break;

        case ESound.eTowerDown:
            PlayAudio(towerDown);
            break;

        default:
            break;
        }
    }
 public static void PlaySound(ESound ID)
 {
     if (GlobalSetting.IsSoundEffect)
     {
         switch (ID)
         {
             case ESound.SFX_1_UP:
                 if (sfx_1_up != null)
                     sfx_1_up.Play();
                 break;
             case ESound.SFX_BREAKBLOCK:
                 if (sfx_breakblock != null)
                     sfx_breakblock.Play();
                 break;
             case ESound.SFX_BUMP:
                 if (sfx_bump != null)
                     sfx_bump.Play();
                 break;
             case ESound.SFX_COIN:
                 if (sfx_coin != null)
                     sfx_coin.Play();
                 break;
             case ESound.SFX_FIREBALL:
                 if (sfx_fireball != null)
                     sfx_fireball.Play();
                 break;
             case ESound.SFX_FIREWORK:
                 if (sfx_firework != null)
                     sfx_firework.Play();
                 break;
             case ESound.SFX_FLAGPOLE:
                 if (sfx_flagpole != null)
                     sfx_flagpole.Play();
                 break;
             case ESound.SFX_GAMEOVER:
                 if (sfx_gameover != null)
                     sfx_gameover.Play();
                 break;
             case ESound.SFX_ITEM_APPEAR:
                 if (sfx_item_appear != null)
                     sfx_item_appear.Play();
                 break;
             case ESound.SFX_JUMP_BIG:
                 if (sfx_jump_big != null)
                     sfx_jump_big.Play();
                 break;
             case ESound.SFX_JUMP_SMALL:
                 if (sfx_jump_small != null)
                     sfx_jump_small.Play();
                 break;
             case ESound.SFX_KICK:
                 if (sfx_kick != null)
                     sfx_kick.Play();
                 break;
             case ESound.SFX_MARIO_DIE:
                 if (sfx_mario_die != null)
                     sfx_mario_die.Play();
                 break;
             case ESound.SFX_MARIO_HURT:
                 if (sfx_mario_hurt != null)
                     sfx_mario_hurt.Play();
                 break;
             case ESound.SFX_PAUSE:
                 if (sfx_pause != null)
                     sfx_pause.Play();
                 break;
             case ESound.SFX_PIPE:
                 if (sfx_pipe != null)
                     sfx_pipe.Play();
                 break;
             case ESound.SFX_POWER_UP:
                 if (sfx_power_up != null)
                     sfx_power_up.Play();
                 break;
             case ESound.SFX_STAGE_CLEAR:
                 if (sfx_stage_clear != null)
                     sfx_stage_clear.Play();
                 break;
             case ESound.SFX_STOMP:
                 if (sfx_stomp != null)
                     sfx_stomp.Play();
                 break;
             case ESound.SFX_VINE:
                 if (sfx_vine != null)
                     sfx_vine.Play();
                 break;
             case ESound.SFX_WARNING:
                 if (sfx_warning != null)
                     sfx_warning.Play();
                 break;
             case ESound.SFX_WORLD_CLEAR:
                 if (sfx_world_clear != null)
                     sfx_world_clear.Play();
                 break;
             default:
                 break;
         }
     }
 }
示例#18
0
 private void PlaySound(ESound soundId)
 {
     SoundController.PlaySound(soundId);
 }
示例#19
0
 public static void Do_SFX(ESound eSound)
 {
     audioSoruce.PlayOneShot(map_Sound[eSound]);
     Debug.Log(eSound + "SFX 실행! : " + map_Sound[eSound]);
 }
示例#20
0
 void SoundPlay(ESound snd)
 {
     audio.clip = Sounds[(int)snd];
     audio.Play();
 }