2025-09-25 17:30:19 +08:00

90 lines
2.9 KiB
C#

using FSM;
using Unity.VisualScripting.FullSerializer;
using UnityEngine;
using ZXKFramework;
namespace DongWuYiXue.DaoNiaoShu
{
public class ChaGuanState : FsmState<FSMManager>
{
bool isChaGuan = false;
float chaGuanValue = 0;
Coroutine cor;
AVProValue avProValue;
public override void OnStateEnter()
{
base.OnStateEnter();
this.Log("½øÈë²å¹Ü״̬");
avProValue = GameManager.Instance.transform.FindFirst<AVProValue>("²åÈëÊÓÆµ");
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;
}
}
}