using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class SoundSystem : MonoBehaviour { public static SoundSystem ins; [SerializeField] private AudioSource _audioSource; [SerializeField] private AudioSource _eventSource; [SerializeField] private AudioClip mainSound;//主界面音效 [SerializeField] private AudioClip attacking;//战斗过程音效 [SerializeField] private AudioClip openSound;//开店音效 [SerializeField] private AudioClip closeSound;//关店音效 [SerializeField] private AudioClip levelUp;//升级音效 [SerializeField] private AudioClip attack1;//剑攻击 [SerializeField] private AudioClip attack2;//弓箭攻击音效 [SerializeField] private AudioClip attack3;//轻甲攻击音效 [SerializeField] private AudioClip attack4;//重甲攻击音效 [SerializeField] private AudioClip attack5;//长柄攻击音效 [SerializeField] private AudioClip attack6;//飞镖攻击音效 [SerializeField] private AudioClip forge;//锻造成功 [SerializeField] private AudioClip forgingClick;//锻造成功 [SerializeField] private AudioClip eventClip;//点击通用音效 [SerializeField] private AudioClip winClip;//胜利音效 [SerializeField] private AudioClip loseClip;//胜利音效 public bool audioBo = true; public bool eventBo = true; public void Init() { ins = this; } /// /// 停止音乐 /// public void StopAudioSource() { audioBo = !audioBo; if (audioBo) { _audioSource.Play(); } else { _audioSource.Stop(); } } /// /// 停止音效 /// public void EventAudioSource() { eventBo = !eventBo; if (!eventBo) { _eventSource.Stop(); } } /// /// 主界面音效 /// public void MainAudio() { if (_audioSource.clip==mainSound) { return; } _audioSource.clip = mainSound; if (!audioBo) { return; } _audioSource.Play(); _audioSource.loop = true; } /// /// 开店音效 /// public void OpenAudio() { _eventSource.clip = openSound; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } /// /// 关店音效 /// public void CloseAudio() { _eventSource.clip = closeSound; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } /// /// 等级提升音效 /// public void LevelAudio() { _eventSource.clip = levelUp; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void Attack1Audio() { _eventSource.clip = attack1; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void Attack2Audio() { _eventSource.clip = attack2; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void Attack3Audio() { _eventSource.clip = attack3; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void Attack4Audio() { _eventSource.clip = attack4; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void Attack5Audio() { _eventSource.clip = attack5; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void Attack6Audio() { _eventSource.clip = attack6; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void ForgeAudio() { _eventSource.clip = forge; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void ForgingClickAudio() { _eventSource.clip = forgingClick; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void ButtonEventAudio() { _eventSource.clip = eventClip; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void AttackAudio() { _audioSource.clip = attacking; if (!audioBo) { return; } _audioSource.Play(); _audioSource.loop = true; } public void WinEventAudio() { _eventSource.clip = winClip; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } public void LoseEventAudio() { _eventSource.clip = loseClip; if (!audioBo) { return; } _eventSource.Play(); _eventSource.loop = false; } }