smart-interactive-display/Assets/GadGame/Scripts/State/MainFlowState/EngageState.cs

56 lines
1.6 KiB
C#
Raw Normal View History

2024-04-11 01:55:35 -07:00
using GadGame.Manager;
using GadGame.Network;
using UnityEngine;
2024-04-15 04:10:00 -07:00
namespace GadGame.State.MainFlowState
2024-04-11 01:55:35 -07:00
{
public class EngageState : State<MainFlow>
{
2024-04-15 04:10:00 -07:00
private float _readyTimer;
private bool _warned;
2024-04-11 01:55:35 -07:00
public override void Enter()
{
LoadSceneManager.Instance.LoadSceneWithTransition(Runner.SceneFlowConfig.EndGageScene.ScenePath);
2024-04-15 04:10:00 -07:00
_readyTimer = 0;
2024-04-11 01:55:35 -07:00
}
2024-04-15 04:10:00 -07:00
public override void Update(float time)
2024-04-11 01:55:35 -07:00
{
2024-04-15 04:10:00 -07:00
if (time >= 2)
2024-04-11 03:21:13 -07:00
{
if (!UdpSocket.Instance.DataReceived.PassBy)
2024-04-15 04:10:00 -07:00
{
Runner.SetState<IdleState>();
return;
}
switch (_warned)
{
case false when !UdpSocket.Instance.DataReceived.Engage:
2024-04-15 04:10:00 -07:00
_warned = true;
PopupManager.Instance.Show("Come Back", 5, () =>
{
Runner.SetState<ViewedState>();
});
return;
case true when UdpSocket.Instance.DataReceived.Engage:
2024-04-15 04:10:00 -07:00
_warned = false;
PopupManager.Instance.Hide();
return;
}
2024-04-11 03:21:13 -07:00
}
if (!UdpSocket.Instance.DataReceived.Ready) _readyTimer = 0;
2024-04-15 04:10:00 -07:00
_readyTimer += Time.deltaTime;
2024-04-16 03:27:54 -07:00
if (_readyTimer >= 3)
2024-04-11 03:21:13 -07:00
{
2024-04-15 04:10:00 -07:00
Runner.SetState<PlayGameState>();
2024-04-11 03:21:13 -07:00
}
2024-04-11 01:55:35 -07:00
}
public override void Exit()
{
2024-04-15 04:10:00 -07:00
_warned = false;
2024-04-11 01:55:35 -07:00
}
}
}