133 lines
2.8 KiB
C#
133 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SoundSystem : MonoBehaviour
|
|
{
|
|
[SerializeField] private AudioSource _audioSource;
|
|
[SerializeField] private AudioSource _eventSource;
|
|
[SerializeField] private AudioClip mainSound;//主界面音效
|
|
[SerializeField] private AudioClip packSound;//合成界面音效
|
|
[SerializeField] private AudioClip tourSound;//旅行界面音效
|
|
[SerializeField] private AudioClip synthesisSound;//合成音效
|
|
[SerializeField] private AudioClip placeSound;//放置音效
|
|
[SerializeField] private AudioClip winSound;
|
|
[SerializeField] private AudioClip loseSound;
|
|
[SerializeField] private AudioClip eventSound;
|
|
public bool audioBo = true;
|
|
public bool eventBo = true;
|
|
|
|
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 PackAudio()
|
|
{
|
|
_audioSource.clip = packSound;
|
|
if (!audioBo)
|
|
{
|
|
return;
|
|
}
|
|
_audioSource.Play();
|
|
_audioSource.loop = true;
|
|
}
|
|
|
|
public void tourAudio()
|
|
{
|
|
_audioSource.clip = tourSound;
|
|
if (!audioBo)
|
|
{
|
|
return;
|
|
}
|
|
_audioSource.Play();
|
|
_audioSource.loop = true;
|
|
}
|
|
|
|
public void WinAudio()
|
|
{
|
|
_audioSource.clip = winSound;
|
|
if (!audioBo)
|
|
{
|
|
return;
|
|
}
|
|
_audioSource.Play();
|
|
_audioSource.loop = false;
|
|
}
|
|
|
|
public void LoseAudio()
|
|
{
|
|
_audioSource.clip = loseSound;
|
|
if (!audioBo)
|
|
{
|
|
return;
|
|
}
|
|
_audioSource.Play();
|
|
_audioSource.loop = false;
|
|
}
|
|
|
|
public void SynthesisAudio()
|
|
{
|
|
if (!eventBo)
|
|
{
|
|
return;
|
|
}
|
|
_eventSource.clip = synthesisSound;
|
|
_eventSource.Play();
|
|
_eventSource.loop = false;
|
|
}
|
|
|
|
public void PlaceAudio()
|
|
{
|
|
if (!eventBo)
|
|
{
|
|
return;
|
|
}
|
|
_eventSource.clip = placeSound;
|
|
_eventSource.Play();
|
|
_eventSource.loop = false;
|
|
}
|
|
|
|
public void EventAudio()
|
|
{
|
|
if (!eventBo)
|
|
{
|
|
return;
|
|
}
|
|
_eventSource.clip = eventSound;
|
|
_eventSource.Play();
|
|
_eventSource.loop = false;
|
|
}
|
|
}
|