using System.Collections.Generic;
using UnityEngine;
namespace ET
{
[ComponentOf(typeof(Scene))]
public class SoundComponent: Entity, IAwake
{
public static SoundComponent Instance;
///
/// 控制游戏全局音量
///
public float SoundVolume
{
get
{
return _soundVolume;
}
set
{
_soundVolume = Mathf.Clamp(value, 0, 1);
foreach (SoundData clip in m_clips.Values)
{
clip.Volume = _soundVolume * clip.volume;
}
}
}
public float _soundVolume = 0.8f;
//所有音效
public Dictionary m_clips = new Dictionary();
//根据类型分类所有音效
public Dictionary> _allClips = new Dictionary>()
{ { SoundType.Music, new Dictionary() }, { SoundType.Sound, new Dictionary() } };
//catch ab资源
public static Dictionary abSounds = new Dictionary();
//根物体
public Transform root;
///
/// 音乐静音
///
public bool MusicMute
{
get { return _musicMute; }
set
{
_musicMute = value;
foreach (var soundData in _allClips[SoundType.Music].Values)
{
soundData.Mute = _musicMute;
}
PlayerPrefs.SetInt("MusicMute", value ? 1 : 0);
}
}
public bool _musicMute = false;
///
/// 音效静音
///
public bool SoundMute
{
get { return _soundMute; }
set
{
_soundMute = value;
foreach (var soundData in _allClips[SoundType.Sound].Values)
{
soundData.Mute = _soundMute;
}
PlayerPrefs.SetInt("SoundMute", value ? 1 : 0);
}
}
public bool _soundMute = false;
}
}