You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
4.8 KiB
179 lines
4.8 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Cinemachine;
|
|
using DG.Tweening;
|
|
public class Level2Manager : MonoSingleton<Level2Manager>
|
|
{
|
|
|
|
public bool isHasHX;
|
|
public Transform cmBirthPlace;
|
|
public Transform cmPlace;
|
|
[Header("音效")]
|
|
AudioSource audioSource;
|
|
public AudioClip[] audioClips;
|
|
[Header("操作详情")]
|
|
[NonSerialized]
|
|
public List<Operate> allOperate = new List<Operate>();
|
|
public Transform operateLog;
|
|
[Header("动画")]
|
|
public Animator animator;
|
|
[Header("UI")]
|
|
public GameObject textTip;//提示
|
|
public ErrorTip errtip;//错误提示
|
|
public Text yiShiText;
|
|
public GameObject yiShi;//意识页面
|
|
public GameObject huXi;//呼吸页面
|
|
public GameObject question;//答题页面
|
|
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
audioSource = GetComponent<AudioSource>();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
EventManager.Instance.register("HuHuanEnd", Huxi);
|
|
EventManager.Instance.register("guancha", Guancha);
|
|
EventManager.Instance.register("AnswerQuestion",JTTX);
|
|
Init();
|
|
}
|
|
|
|
|
|
|
|
void Init() {
|
|
textTip.SetActive(true);
|
|
isHasHX = UnityEngine.Random.value >= 0.5 ? true : false;
|
|
DialogueController.Instance.StartDialogue(0, YiShi);
|
|
AddOperate(Level1Const.operate1Info);
|
|
AddOperate(Level1Const.operate2Info);
|
|
AddOperate(Level1Const.operate3Info);
|
|
AddOperate(Level2Const.operate1Info);
|
|
StartCoroutine(WaitExecute(InitOperate,0.2f));
|
|
}
|
|
|
|
|
|
public void AddOperate(string text)
|
|
{
|
|
Operate op = Instantiate(Resources.Load<GameObject>("operate"), operateLog).GetComponent<Operate>();
|
|
allOperate.Add(op);
|
|
op.str = text;
|
|
op.color = Level2Const.operateFrontColor;
|
|
}
|
|
|
|
#region 意识判断
|
|
public void YiShi() {
|
|
yiShi.SetActive(true);
|
|
DialogueController.Instance.StartDialogue(1);
|
|
}
|
|
|
|
public void YishiPanDuan(bool inspect)
|
|
{
|
|
if (inspect)
|
|
{
|
|
yiShi.SetActive(false);
|
|
audioSource.clip = audioClips[0];
|
|
audioSource.Play();
|
|
StartCoroutine(WaitExecute(0.4f,()=> { animator.SetTrigger("Huhuan"); }));
|
|
|
|
}
|
|
else
|
|
{
|
|
errtip.InitThis("当前拍打部位错误,请重试");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 呼吸
|
|
/// <summary>
|
|
/// 意识判断结束开始呼吸判断
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
public void Huxi(params object[] data) {
|
|
yiShiText.text = "无意识";
|
|
allOperate[3].Finished();
|
|
AddOperate(Level2Const.operate2Info);
|
|
huXi.SetActive(true);
|
|
DialogueController.Instance.StartDialogue(2);
|
|
}
|
|
|
|
public void HuXiPanDuan(bool inspect) {
|
|
if (inspect)
|
|
{
|
|
huXi.SetActive(false);
|
|
animator.SetTrigger("Tuoyi");
|
|
}
|
|
else
|
|
{
|
|
errtip.InitThis("当前观察部位错误,请重试");
|
|
}
|
|
}
|
|
|
|
void Guancha(params object[] data)
|
|
{
|
|
audioSource.clip = audioClips[1];
|
|
audioSource.Play();
|
|
}
|
|
#endregion
|
|
|
|
#region 开始答题
|
|
void Question() {
|
|
DialogueController.Instance.StartDialogue(3);
|
|
question.SetActive(true);
|
|
allOperate[4].Finished();
|
|
AddOperate(Level2Const.operate3Info);
|
|
}
|
|
#endregion
|
|
|
|
#region 镜头特写
|
|
public void JTTX(params object[] data)
|
|
{
|
|
StartCoroutine(WaitExecute(2.5f,()=>{
|
|
Transform cmtransform = FindObjectOfType<CinemachineVirtualCamera>().transform;
|
|
cmtransform.DOMove(cmPlace.position, 0.5f);
|
|
cmtransform.DORotate(cmPlace.localEulerAngles, 0.5f);
|
|
StartCoroutine(WaitExecute(() => {
|
|
cmtransform.DOMove(cmBirthPlace.position,0.5f);
|
|
cmtransform.DORotate(cmBirthPlace.localEulerAngles,0.5f);
|
|
animator.SetTrigger("TXEnd");
|
|
}, 3.5f));
|
|
StartCoroutine(WaitExecute(PlayAudio, 0.5f));
|
|
}));
|
|
}
|
|
|
|
void PlayAudio() {
|
|
if (isHasHX)
|
|
{
|
|
audioSource.clip = audioClips[3];
|
|
audioSource.Play();
|
|
}
|
|
else {
|
|
audioSource.clip = audioClips[2];
|
|
audioSource.Play();
|
|
}
|
|
StartCoroutine(WaitExecute(Question,3));
|
|
}
|
|
|
|
IEnumerator WaitExecute(Action action, float t)
|
|
{
|
|
yield return new WaitForSeconds(t);
|
|
action();
|
|
}
|
|
#endregion
|
|
|
|
void InitOperate() {
|
|
allOperate[0].Finished();
|
|
allOperate[1].Finished();
|
|
allOperate[2].Finished();
|
|
}
|
|
|
|
IEnumerator WaitExecute(float time,Action action) {
|
|
yield return new WaitForSeconds(time);
|
|
action.Invoke();
|
|
}
|
|
}
|