161 lines
4.2 KiB
161 lines
4.2 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Cinemachine;
|
|
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() {
|
|
|
|
Debug.Log(allOperate[2].color);
|
|
yiShi.SetActive(true);
|
|
DialogueController.Instance.StartDialogue(1);
|
|
}
|
|
|
|
public void YishiPanDuan(bool inspect)
|
|
{
|
|
if (inspect)
|
|
{
|
|
yiShi.SetActive(false);
|
|
audioSource.clip = audioClips[0];
|
|
audioSource.Play();
|
|
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)
|
|
{
|
|
Transform cmtransform=FindObjectOfType<CinemachineVirtualCamera>().transform;
|
|
cmtransform.position = cmPlace.position;
|
|
cmtransform.rotation = cmPlace.rotation;
|
|
StartCoroutine(WaitExecute(() => {
|
|
cmtransform.position = cmBirthPlace.position;
|
|
cmtransform.rotation = cmBirthPlace.rotation;
|
|
animator.SetTrigger("TXEnd");
|
|
}, 4));
|
|
StartCoroutine(WaitExecute(Question, 5));
|
|
|
|
}
|
|
|
|
IEnumerator WaitExecute(Action action, float t)
|
|
{
|
|
yield return new WaitForSeconds(t);
|
|
action();
|
|
}
|
|
#endregion
|
|
|
|
void InitOperate() {
|
|
allOperate[0].Finished();
|
|
allOperate[1].Finished();
|
|
allOperate[2].Finished();
|
|
}
|
|
}
|