164 lines
3.2 KiB
C#
164 lines
3.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using ZXK.UTility;
|
|
|
|
/// <summary>
|
|
/// 挂载模式物体上的配音管理器
|
|
/// </summary>
|
|
public class SpeakManager: MonoBehaviour
|
|
{
|
|
[Header("设备组装声音组")]
|
|
public List<AudioClip> ZuZhuang;
|
|
[Header("设备接线声音组")]
|
|
public List<AudioClip> JieXian;
|
|
[Header("考核模式_接线声音组")]
|
|
public List<AudioClip> Exam_JieXian;
|
|
[Header("充气声音组")]
|
|
public List<AudioClip> ChongQi;
|
|
[Header("程序下载声音组")]
|
|
public List<AudioClip> ChengXuXiaZai;
|
|
[Header("设备运行声音组")]
|
|
public List<AudioClip> YunXing;
|
|
|
|
public AudioSource audioSource;
|
|
|
|
[SerializeField,Header("当前模块音乐")]
|
|
private List<AudioClip> currentAudioClip;
|
|
|
|
public List<AudioClip> CurrentAudioClip { get => currentAudioClip; set => currentAudioClip = value; }
|
|
|
|
|
|
|
|
|
|
public void SetVolum(float Volue) {
|
|
|
|
|
|
transform.GetComponent<AudioSource>().volume = Volue;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更换音配组
|
|
/// </summary>
|
|
/// <param name="ModelString"></param>
|
|
|
|
public void ChangeModelAudio(string ModelString) {
|
|
|
|
switch (ModelString)
|
|
{
|
|
case "设备组装":
|
|
currentAudioClip = ZuZhuang;
|
|
break;
|
|
case "设备接线":
|
|
currentAudioClip = JieXian;
|
|
break;
|
|
case "程序调试":
|
|
currentAudioClip = ChengXuXiaZai;
|
|
break;
|
|
case "气泵充气":
|
|
currentAudioClip = ChongQi;
|
|
break;
|
|
case "设备运行":
|
|
currentAudioClip = YunXing;
|
|
break;
|
|
case "设备接线_考核":
|
|
currentAudioClip = Exam_JieXian;
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
public int CurrentIndex=0;
|
|
|
|
/// <summary>
|
|
/// 初始化播放器
|
|
/// </summary>
|
|
public void Init() {
|
|
|
|
|
|
|
|
|
|
audioSource.Stop();
|
|
|
|
CurrentIndex = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public void SetCurrentAudioClip() {
|
|
|
|
|
|
audioSource.clip = currentAudioClip[CurrentIndex];
|
|
}
|
|
|
|
/// <summary>
|
|
/// 播放音频
|
|
/// </summary>
|
|
public void PlayAudioCilp() {
|
|
|
|
if (CurrentIndex< currentAudioClip.Count)
|
|
{
|
|
//设置音频
|
|
audioSource.clip = currentAudioClip[CurrentIndex];
|
|
audioSource.Play();
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("最后一个,结束音频索引");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 播放固定索引号的音频
|
|
/// </summary>
|
|
/// <param name="index"></param>
|
|
public void PlayFixedAudioCilp(int index)
|
|
{
|
|
|
|
if (index < currentAudioClip.Count)
|
|
{
|
|
Debug.Log("设置音频播放,传入的索引是?"+index);
|
|
//设置音频
|
|
audioSource.clip = currentAudioClip[index];
|
|
audioSource.Play();
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("最后一个,结束音频索引");
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加音频索引
|
|
/// </summary>
|
|
public void AddAudioCilp()
|
|
{
|
|
|
|
|
|
CurrentIndex++;
|
|
|
|
Debug.Log("音频索引增加");
|
|
}
|
|
|
|
|
|
//结束播放音频,置空
|
|
public void ReSetAudioCilp()
|
|
{
|
|
|
|
|
|
|
|
|
|
audioSource.Stop();
|
|
// audioSource.clip = null;
|
|
// currentAudioClip = null;
|
|
}
|
|
|
|
}
|