97 lines
2.8 KiB
C#
97 lines
2.8 KiB
C#
using FSM;
|
||
using LitJson;
|
||
using UnityEngine;
|
||
using ZXKFramework;
|
||
namespace DongWuYiXue.DaoNiaoShu
|
||
{
|
||
public class LianJieJiNiaoDaiState : FsmState<FSMManager>
|
||
{
|
||
bool isLianJie = false;
|
||
Coroutine cor;
|
||
|
||
bool link;
|
||
|
||
public override void OnStateEnter()
|
||
{
|
||
base.OnStateEnter();
|
||
this.Log("½øÈëÁ¬½Ó¼¯Äò´ü״̬");
|
||
fsm.Show("Á¬½Ó¼¯Äò´ü");
|
||
isLianJie = false;
|
||
link = false;
|
||
fsm.ShowTip(0);
|
||
fsm.PlayBgm(0);
|
||
fsm.ShowCamera("Á¬½Ó¼¯Äò´ü1_Camera");
|
||
|
||
GameManager.Instance.webSockerCameraSender.modelName = "QDN";
|
||
GameManager.Instance.webSockerCameraSender.OnMessageReceived.AddListener(Test);
|
||
GameManager.Instance.videoUI.SetActive(true);
|
||
|
||
cor = Game.Instance.IEnumeratorManager.Run(2.0f, () =>
|
||
{
|
||
isLianJie = true;
|
||
//if (fsm.main_gameModel.modeType == ModeType.ShiXun)
|
||
//{
|
||
// fsm.AddScore(2, 0);
|
||
//}
|
||
//if (fsm.main_gameModel.modeType == ModeType.KaoHe)
|
||
//{
|
||
// fsm.AddScore(2, 0);
|
||
//}
|
||
});
|
||
}
|
||
|
||
public void Test(string str)
|
||
{
|
||
//Debug.LogError(str);
|
||
JsonData responseBody = JsonMapper.ToObject(str);
|
||
if (responseBody["classes_detected"].Count > 0)
|
||
{
|
||
if (responseBody["classes_detected"][0].ToString() == "link-false")
|
||
{
|
||
link = false;
|
||
}
|
||
if (responseBody["classes_detected"][0].ToString() == "link-true")
|
||
{
|
||
link = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
public override void OnStateStay()
|
||
{
|
||
base.OnStateStay();
|
||
if (isLianJie && Input.GetKeyDown(KeyCode.L))
|
||
{
|
||
isLianJie = false;
|
||
fsm.ShowCamera("Á¬½Ó¼¯Äò´ü2_Camera");
|
||
fsm.PlayClip("Á¬½Ó¼¯Äò´ü_TimeLine", () =>
|
||
{
|
||
fsm.nextState = true;
|
||
});
|
||
}
|
||
if (isLianJie && link)
|
||
{
|
||
isLianJie = false;
|
||
fsm.ShowCamera("Á¬½Ó¼¯Äò´ü2_Camera");
|
||
fsm.PlayClip("Á¬½Ó¼¯Äò´ü_TimeLine", () =>
|
||
{
|
||
fsm.nextState = true;
|
||
});
|
||
}
|
||
}
|
||
public override void OnStateExit()
|
||
{
|
||
base.OnStateExit();
|
||
GameManager.Instance.videoUI.SetActive(false);
|
||
if (null != cor)
|
||
{
|
||
Game.Instance.IEnumeratorManager.Stop(cor);
|
||
cor = null;
|
||
}
|
||
isLianJie = false;
|
||
link = false;
|
||
fsm.nextState = false;
|
||
}
|
||
}
|
||
}
|