using FSM; using Unity.VisualScripting.FullSerializer; using UnityEngine; using ZXKFramework; namespace DongWuYiXue.DaoNiaoShu { public class ChaGuanState : FsmState { bool isChaGuan = false; float chaGuanValue = 0; Coroutine cor; AVProValue avProValue; public override void OnStateEnter() { base.OnStateEnter(); this.Log("进入插管状态"); avProValue = GameManager.Instance.transform.FindFirst("插入视频"); chaGuanValue = 0; fsm.ShowCamera("插管1_Camera"); fsm.ShowTip(0); fsm.PlayBgm(0); fsm.ShowArrow(new Vector2(50f, -327f), 6); cor = Game.Instance.IEnumeratorManager.Run(3.0f, () => { isChaGuan = true; avProValue.gameObject.SetActive(true); }); } public override void OnStateStay() { base.OnStateStay(); if (isChaGuan) { chaGuanValue += .0005f; fsm.PlayClip("插管_TimeLine", null, chaGuanValue); avProValue.PlayValue = chaGuanValue; avProValue.PlayVideoAsValue(); } if (isChaGuan && Input.GetKeyDown(KeyCode.L)) { chaGuanValue = 1.0f; fsm.PlayClip("插管_TimeLine", null, chaGuanValue); avProValue.PlayValue = chaGuanValue; avProValue.PlayVideoAsValue(); } if (chaGuanValue >= 1.0f && isChaGuan) { isChaGuan = false; avProValue.gameObject.SetActive(false); if (fsm.main_gameModel.modeType == ModeType.ShiXun) { fsm.AddScore(10, 0); } if (fsm.main_gameModel.modeType == ModeType.KaoHe) { fsm.AddScore(10, 0); } fsm.ShowCamera("插管2_Camera"); fsm.PlayClip("插管后排尿_TimeLine", () => { if (fsm.main_gameModel.modeType == ModeType.ShiXun) { fsm.nextState = true; } if (fsm.main_gameModel.modeType == ModeType.KaoHe) { fsm.ShowTxtQuestion("插入导尿管》插管》步骤2",3, 5, 3, () => { fsm.nextState = true; }); } }); } } public override void OnStateExit() { base.OnStateExit(); if (null != cor) { Game.Instance.IEnumeratorManager.Stop(cor); cor = null; } isChaGuan = false; avProValue.gameObject.SetActive(false); fsm.nextState = false; } } }