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-17 20:53:46 -07:00
|
|
|
private bool _showCountDown;
|
2024-04-11 01:55:35 -07:00
|
|
|
|
2024-04-22 02:10:49 -07:00
|
|
|
private PassByAnimation passByAnim;
|
|
|
|
|
2024-04-11 01:55:35 -07:00
|
|
|
public override void Enter()
|
|
|
|
{
|
2024-04-22 02:10:49 -07:00
|
|
|
passByAnim = PassByAnimation.Instance;
|
|
|
|
passByAnim.Play(true);
|
|
|
|
// LoadSceneManager.Instance.LoadSceneWithTransition(Runner.SceneFlowConfig.EndGageScene.ScenePath);
|
2024-04-19 03:46:17 -07:00
|
|
|
_readyTimer = 5;
|
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
|
|
|
{
|
2024-04-15 04:10:00 -07:00
|
|
|
switch (_warned)
|
|
|
|
{
|
2024-04-17 20:53:46 -07:00
|
|
|
case false when !UdpSocket.Instance.DataReceived.PassBy:
|
|
|
|
Runner.SetState<IdleState>();
|
|
|
|
break;
|
2024-04-16 01:47:19 -07:00
|
|
|
case false when !UdpSocket.Instance.DataReceived.Engage:
|
2024-04-15 04:10:00 -07:00
|
|
|
_warned = true;
|
2024-04-22 02:10:49 -07:00
|
|
|
passByAnim.Play(false);
|
|
|
|
// PopupManager.Instance.Show("Come Back", 5).OnComplete(OnWaringComplete);
|
2024-04-17 20:53:46 -07:00
|
|
|
break;
|
2024-04-16 01:47:19 -07:00
|
|
|
case true when UdpSocket.Instance.DataReceived.Engage:
|
2024-04-15 04:10:00 -07:00
|
|
|
_warned = false;
|
2024-04-22 02:10:49 -07:00
|
|
|
passByAnim.Play(true);
|
|
|
|
// PopupManager.Instance.Hide();
|
2024-04-17 20:53:46 -07:00
|
|
|
break;
|
2024-04-15 04:10:00 -07:00
|
|
|
}
|
2024-04-17 20:53:46 -07:00
|
|
|
|
2024-04-19 03:46:17 -07:00
|
|
|
switch (_showCountDown)
|
|
|
|
{
|
|
|
|
case false when UdpSocket.Instance.DataReceived.Ready:
|
|
|
|
_showCountDown = true;
|
|
|
|
Runner.Ready(true);
|
|
|
|
break;
|
|
|
|
case true when !UdpSocket.Instance.DataReceived.Ready:
|
|
|
|
_showCountDown = false;
|
|
|
|
Runner.Ready(false);
|
|
|
|
break;
|
|
|
|
}
|
2024-04-17 20:53:46 -07:00
|
|
|
|
2024-04-19 03:46:17 -07:00
|
|
|
if (!UdpSocket.Instance.DataReceived.Ready) _readyTimer = 5;
|
|
|
|
_readyTimer -= Time.deltaTime;
|
|
|
|
if (_readyTimer <= 0)
|
|
|
|
{
|
|
|
|
_readyTimer = 0;
|
|
|
|
Runner.SetState<PlayGameState>();
|
|
|
|
}
|
|
|
|
Runner.ReadyCountDown(_readyTimer);
|
2024-04-11 03:21:13 -07:00
|
|
|
}
|
2024-04-19 03:46:17 -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
|
|
|
}
|
2024-04-17 20:53:46 -07:00
|
|
|
|
2024-04-22 02:10:49 -07:00
|
|
|
// private void OnWaringComplete()
|
|
|
|
// {
|
|
|
|
// if (!UdpSocket.Instance.DataReceived.PassBy)
|
|
|
|
// {
|
|
|
|
// Runner.SetState<IdleState>();
|
|
|
|
// return;
|
|
|
|
// }
|
2024-04-17 20:53:46 -07:00
|
|
|
|
2024-04-22 02:10:49 -07:00
|
|
|
// if (!UdpSocket.Instance.DataReceived.OnVision)
|
|
|
|
// {
|
|
|
|
// Runner.SetState<PassByState>();
|
|
|
|
// return;
|
|
|
|
// }
|
2024-04-17 20:53:46 -07:00
|
|
|
|
2024-04-22 02:10:49 -07:00
|
|
|
// Runner.SetState<ViewedState>();
|
|
|
|
// }
|
2024-04-11 01:55:35 -07:00
|
|
|
}
|
|
|
|
}
|