57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
public class CheckLeadersFromMenuState : IState
|
|
{
|
|
Leaderboard lb;
|
|
|
|
float timeToExit = 20f;
|
|
float timeElapsed = 0;
|
|
bool ready = false;
|
|
public void enter()
|
|
{
|
|
//ComWrapper.InputRecieved += ResetTimer;
|
|
lb = GameManager.instance.leaderboard;
|
|
|
|
//вкл
|
|
lb.gameObject.SetActive(true);
|
|
lb.Initialize();
|
|
SoundManager.instance.playSwitch();
|
|
timeElapsed = 0;
|
|
}
|
|
|
|
//void ResetTimer(string s) => timeElapsed = 0;
|
|
|
|
public void exit()
|
|
{
|
|
//ComWrapper.InputRecieved-=ResetTimer;
|
|
lb.ClearRowsText();
|
|
lb.gameObject.SetActive(false);
|
|
SoundManager.instance.playSwitch();
|
|
}
|
|
|
|
public void update()
|
|
{
|
|
if (!ready)
|
|
{
|
|
ready = !In.AnyButton();
|
|
return;
|
|
}
|
|
//проверка
|
|
//bool exitCombo = !In.GetButtonAnyPlayer(PlayerAction.down) && In.AnyButton();
|
|
|
|
|
|
//if (keepDownButton) ResetTimer("");
|
|
bool keepDownButton = In.GetButtonAnyPlayer(PlayerAction.down);
|
|
float accelerationSign = keepDownButton ? 1 : -1f;
|
|
lb.accelerationY = Mathf.Abs(lb.accelerationY) * accelerationSign;
|
|
|
|
bool exitCombo = In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right);
|
|
timeElapsed += Time.deltaTime;
|
|
if (timeElapsed > timeToExit || exitCombo)
|
|
{
|
|
GameManager.instance.stateMachine.ChangeState(new MenuState());
|
|
}
|
|
|
|
}
|
|
}
|