public void SetBgmMute(bool mute) { if (_bgmTweener != null) { _bgmTweener.Kill(); _bgmTweener = null; } if (BgmPlayer) { if (mute) { _bgmTweener = BgmPlayer.DOFade(0f, FadeTime).SetEase(Ease.Linear); } else { var volume = Mathf.Clamp01(PrefsUtil.GetFloat(PrefsKeys.BgmVolumeKey, 1)); _bgmTweener = BgmPlayer.DOFade(volume, FadeTime).SetEase(Ease.Linear); } } }
/// <summary> /// 播放背景音乐。 /// </summary> public void PlayBgm() { if (BgmPlayer) { if (BgmPlayer.isPlaying) { BgmPlayer.Stop(); } var volume = Mathf.Clamp01(PrefsUtil.GetFloat(PrefsKeys.BgmVolumeKey, 1)); BgmPlayer.volume = volume; BgmPlayer.loop = true; BgmPlayer.mute = false; if (Bgm) { BgmPlayer.clip = Bgm; BgmPlayer.Play(); } } }
private void Initialize() { #region 播放器 if (BgmPlayer) { var bgmEnable = PrefsUtil.GetBool(PrefsKeys.BgmEnable, true); if (bgmEnable) { PlayBgm(); } else { StopBgm(); } var bgmVolume = Mathf.Clamp01(PrefsUtil.GetFloat(PrefsKeys.BgmVolumeKey, 1)); BgmPlayer.volume = bgmVolume; } if (EffectPlayer) { var effectEnable = PrefsUtil.GetBool(PrefsKeys.EffectEnable, true); EffectPlayer.mute = !effectEnable; var effectVolume = Mathf.Clamp01(PrefsUtil.GetFloat(PrefsKeys.EffectVolumeKey, 1)); EffectPlayer.volume = effectVolume; } #endregion #region 初始化女声 _femaleASounds.Clear(); if (Female2) { _femaleASounds.Add(PokerNumType.P2, Female2); } if (Female3) { _femaleASounds.Add(PokerNumType.P3, Female3); } if (Female4) { _femaleASounds.Add(PokerNumType.P4, Female4); } if (Female5) { _femaleASounds.Add(PokerNumType.P5, Female5); } if (Female6) { _femaleASounds.Add(PokerNumType.P6, Female6); } if (Female7) { _femaleASounds.Add(PokerNumType.P7, Female7); } if (Female8) { _femaleASounds.Add(PokerNumType.P8, Female8); } if (Female9) { _femaleASounds.Add(PokerNumType.P9, Female9); } if (Female10) { _femaleASounds.Add(PokerNumType.P10, Female10); } if (FemaleJ) { _femaleASounds.Add(PokerNumType.PJ, FemaleJ); } if (FemaleQ) { _femaleASounds.Add(PokerNumType.PQ, FemaleQ); } if (FemaleK) { _femaleASounds.Add(PokerNumType.PK, FemaleK); } if (FemaleA) { _femaleASounds.Add(PokerNumType.PA, FemaleA); } if (FemaleWX) { _femaleASounds.Add(PokerNumType.PX, FemaleWX); } if (FemaleWD) { _femaleASounds.Add(PokerNumType.PD, FemaleWD); } _femalePatternSounds.Clear(); if (FemaleBuChu) { _femalePatternSounds.Add(PatternType.BUCHU, FemaleBuChu); } if (FemaleDuiZi) { _femalePatternSounds.Add(PatternType.AA, FemaleDuiZi); } if (FemaleSanDaiEr) { _femalePatternSounds.Add(PatternType.AAAXX, FemaleSanDaiEr); } if (FemaleSanLianDui) { _femalePatternSounds.Add(PatternType.AABBCC, FemaleSanLianDui); } if (FemaleSanZhang) { _femalePatternSounds.Add(PatternType.AAA, FemaleSanZhang); } if (FemaleShunZi) { _femalePatternSounds.Add(PatternType.ABCDE, FemaleShunZi); } if (FemaleFeiJi) { _femalePatternSounds.Add(PatternType.AAABBB, FemaleFeiJi); } if (FemaleZhaDan) { _femalePatternSounds.Add(PatternType.XXXX, FemaleZhaDan); } if (FemaleTongHuaShun) { _femalePatternSounds.Add(PatternType.SuperABCDE, FemaleTongHuaShun); } if (FemaleWangZha) { _femalePatternSounds.Add(PatternType.XXDD, FemaleWangZha); } #endregion #region 初始化男声 _maleASounds.Clear(); if (Male2) { _maleASounds.Add(PokerNumType.P2, Male2); } if (Male3) { _maleASounds.Add(PokerNumType.P3, Male3); } if (Male4) { _maleASounds.Add(PokerNumType.P4, Male4); } if (Male5) { _maleASounds.Add(PokerNumType.P5, Male5); } if (Male6) { _maleASounds.Add(PokerNumType.P6, Male6); } if (Male7) { _maleASounds.Add(PokerNumType.P7, Male7); } if (Male8) { _maleASounds.Add(PokerNumType.P8, Male8); } if (Male9) { _maleASounds.Add(PokerNumType.P9, Male9); } if (Male10) { _maleASounds.Add(PokerNumType.P10, Male10); } if (MaleJ) { _maleASounds.Add(PokerNumType.PJ, MaleJ); } if (MaleQ) { _maleASounds.Add(PokerNumType.PQ, MaleQ); } if (MaleK) { _maleASounds.Add(PokerNumType.PK, MaleK); } if (MaleA) { _maleASounds.Add(PokerNumType.PA, MaleA); } if (MaleWX) { _maleASounds.Add(PokerNumType.PX, MaleWX); } if (MaleWD) { _maleASounds.Add(PokerNumType.PD, MaleWD); } _malePatternSounds.Clear(); if (MaleBuChu) { _malePatternSounds.Add(PatternType.BUCHU, MaleBuChu); } if (MaleDuiZi) { _malePatternSounds.Add(PatternType.AA, MaleDuiZi); } if (MaleSanDaiEr) { _malePatternSounds.Add(PatternType.AAAXX, MaleSanDaiEr); } if (MaleSanLianDui) { _malePatternSounds.Add(PatternType.AABBCC, MaleSanLianDui); } if (MaleSanZhang) { _malePatternSounds.Add(PatternType.AAA, MaleSanZhang); } if (MaleShunZi) { _malePatternSounds.Add(PatternType.ABCDE, MaleShunZi); } if (MaleFeiJi) { _malePatternSounds.Add(PatternType.AAABBB, MaleFeiJi); } if (MaleZhaDan) { _malePatternSounds.Add(PatternType.XXXX, MaleZhaDan); } if (MaleTongHuaShun) { _malePatternSounds.Add(PatternType.SuperABCDE, MaleTongHuaShun); } if (MaleWangZha) { _malePatternSounds.Add(PatternType.XXDD, MaleWangZha); } #endregion #region 特殊牌型音效 _specPatternSounds.Clear(); if (Airplane) { _specPatternSounds.Add(PatternType.AAABBB, Airplane); } if (HuoJian) { _specPatternSounds.Add(PatternType.XXDD, HuoJian); } if (TongHuaShun) { _specPatternSounds.Add(PatternType.SuperABCDE, TongHuaShun); } #endregion }