132 lines
4.1 KiB
C#
132 lines
4.1 KiB
C#
using FSM;
|
|
using UnityEngine;
|
|
using ZXKFramework;
|
|
namespace YiLiao.XinFeiTingZhen
|
|
{
|
|
public class ZhiQiGuanHuXiYin : FsmState<FSMManager>
|
|
{
|
|
bool step1;
|
|
bool step2_kh;
|
|
//成功的标志
|
|
string success = "3";
|
|
string audioName = "28--支气管呼吸音";
|
|
Coroutine cor;
|
|
string PositionValue
|
|
{
|
|
get
|
|
{
|
|
return GameManager.Instance.senSor.GetSensor<TZQ_Sensor>().positionValue.ToString();
|
|
}
|
|
}
|
|
public override void OnStateEnter()
|
|
{
|
|
base.OnStateEnter();
|
|
GameManager.Instance.senSor.SendFunction("#ID:3;SONG:28;%");
|
|
if (fsm.main_gameModel.modeType == ModeType.KaoHe)
|
|
{
|
|
fsm.HideTzq();
|
|
step2_kh = true;
|
|
fsm.ShowTxtImgQuestion("肺部听诊——正常呼吸音——支气管呼吸音", 14, 0, 5, () => {
|
|
fsm.nextState = true;
|
|
});
|
|
}
|
|
if (fsm.main_gameModel.modeType == ModeType.ShiXun)
|
|
{
|
|
fsm.PlayBgm(0);
|
|
fsm.ShowTip(0);
|
|
fsm.Light("支气管听诊器位置1");
|
|
fsm.ShowArrow("将实物听诊器放置于胸骨上窝处进行听诊。", "支气管听诊器位置1", 0, 999);
|
|
Countdown();
|
|
}
|
|
}
|
|
void Countdown()
|
|
{
|
|
fsm.HideTzq();
|
|
step1 = true;
|
|
GameManager.Instance.uiManager.ShowUI<CountdownPanel>();
|
|
GameManager.Instance.uiManager.GetUI<CountdownPanel>().StartCountdown(() => {
|
|
fsm.AddScore(0, 0);
|
|
step1 = false;
|
|
Confirm();
|
|
});
|
|
}
|
|
void Confirm()
|
|
{
|
|
GameManager.Instance.uiManager.GetUI<CountdownPanel>().StopCountdown();
|
|
GameManager.Instance.uiManager.GetUI<ConfirmPanel>().ShowConfirmPanel(() => {
|
|
Countdown();
|
|
}, () => {
|
|
fsm.nextState = true;
|
|
});
|
|
}
|
|
void Success()
|
|
{
|
|
step1 = false;
|
|
fsm.AddScore(0, 2);
|
|
GameManager.Instance.uiManager.GetUI<CountdownPanel>().StopCountdown();
|
|
cor = Game.Instance.IEnumeratorManager.Run(1f, () =>
|
|
{
|
|
GameManager.Instance.uiManager.GetUI<SuccessPanel>().ShowSuccessPanel(() => {
|
|
fsm.nextState = true;
|
|
});
|
|
});
|
|
}
|
|
void False()
|
|
{
|
|
fsm.AddScore(0, 0);
|
|
step1 = false;
|
|
GameManager.Instance.uiManager.GetUI<CountdownPanel>().StopCountdown();
|
|
cor = Game.Instance.IEnumeratorManager.Run(1f, () =>
|
|
{
|
|
Confirm();
|
|
});
|
|
}
|
|
void Audio()
|
|
{
|
|
GameManager.Instance.uiManager.ShowUI<AudioPanel>();
|
|
GameManager.Instance.uiManager.GetUI<AudioPanel>().LoadAudioClip(audioName);
|
|
}
|
|
public override void OnStateStay()
|
|
{
|
|
base.OnStateStay();
|
|
|
|
if (Input.GetKeyDown(KeyCode.L) && step1)
|
|
{
|
|
fsm.ShowTzq(success);
|
|
fsm.HideArrow();
|
|
fsm.Unlight("支气管听诊器位置1");
|
|
Audio();
|
|
Success();
|
|
}
|
|
if (step1)
|
|
{
|
|
fsm.ShowTzq(PositionValue);
|
|
if (PositionValue == success)
|
|
{
|
|
fsm.HideArrow();
|
|
fsm.Unlight("支气管听诊器位置1");
|
|
Audio();
|
|
Success();
|
|
}
|
|
else if (PositionValue!="0" && success != PositionValue)
|
|
{
|
|
False();
|
|
}
|
|
}
|
|
if (step2_kh)
|
|
{
|
|
fsm.ShowTzq(PositionValue);
|
|
Debug.Log(PositionValue);
|
|
}
|
|
}
|
|
public override void OnStateExit()
|
|
{
|
|
base.OnStateExit();
|
|
fsm.HideTzq();
|
|
step2_kh = false;
|
|
Game.Instance.IEnumeratorManager.Stop(cor);
|
|
fsm.nextState = false;
|
|
}
|
|
}
|
|
}
|