49 lines
1.0 KiB
C#
49 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class RulesState : IState
|
|
{
|
|
private RulesController rules;
|
|
|
|
private float timeout = 60f;
|
|
private float restTime;
|
|
|
|
public void enter()
|
|
{
|
|
rules = GameManager.instance.rulesController;
|
|
rules.Open();
|
|
restTime = timeout;
|
|
|
|
}
|
|
public void exit() => rules.Close();
|
|
|
|
public void update()
|
|
{
|
|
int direction = 0;
|
|
if (In.GetButtonDownAnyPlayer(PlayerAction.left)) direction -= 1;
|
|
if (In.GetButtonDownAnyPlayer(PlayerAction.right)) direction += 1;
|
|
|
|
|
|
if (direction != 0)
|
|
{
|
|
rules.SwitchPage(direction);
|
|
restTime = timeout;
|
|
SoundManager.instance.playSwitch();
|
|
}
|
|
|
|
|
|
if (In.GetButtonDownAnyPlayer(PlayerAction.down) || restTime <= 0)
|
|
{
|
|
rules.Close();
|
|
GameManager.instance.stateMachine.ChangeState(new MenuState());
|
|
}
|
|
|
|
restTime -= Time.deltaTime;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|