53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
public class CheckLeadersFromMenuState : IState
|
|
{
|
|
Leaderboard lb;
|
|
|
|
float timeToExit = 60f;
|
|
float timeElapsed = 0;
|
|
|
|
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()
|
|
{
|
|
//проверка
|
|
bool exitCombo = In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right);
|
|
if (exitCombo)
|
|
{
|
|
GameManager.instance.stateMachine.ChangeState(new MenuState());
|
|
}
|
|
|
|
bool keepDownButton = In.GetButtonAnyPlayer(PlayerAction.down);
|
|
float accelerationSign = keepDownButton ? 1 : -1f;
|
|
lb.accelerationY = Mathf.Abs(lb.accelerationY) * accelerationSign;
|
|
|
|
timeElapsed += Time.deltaTime;
|
|
if (timeElapsed > timeToExit)
|
|
{
|
|
GameManager.instance.stateMachine.ChangeState(new MenuState());
|
|
}
|
|
|
|
}
|
|
}
|