chip-gameV3/Assets/Scripts/Menu/MenuController.cs

66 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
public class MenuController : MonoBehaviour
{
[SerializeField] private float _timeToPromo = 180f;
[SerializeField] private float _timeToSettings = 1f;
private HoldTimer _promoTimer;
private HoldTimer _settingsTimer;
private bool _isInit = false;
private bool _isEnabled = false;
private void Update()
{
if ((_isEnabled && _isInit) == false)
return;
if (HandleSettings()) return;
if (HandlePromo()) return;
}
public void Initialize()
{
_promoTimer = new HoldTimer(_timeToPromo);
_settingsTimer = new HoldTimer(_timeToSettings);
_isInit = true;
}
public void Enable()
{
_isEnabled = true;
LightUtility.Idle();
GameManager.instance.ResetGameSession();
}
public void Disable()
{
_isEnabled = false;
_promoTimer.Reset();
_settingsTimer.Reset();
}
private bool HandleSettings()
{
bool settingButtonPressed = In.GetButton(InSignal.secret);
bool gotoSettings = Input.GetKeyDown(KeyCode.F5) || _settingsTimer.Update(settingButtonPressed);
if (gotoSettings)
{
print("ТУТ БУДЕТ ПЕРЕХОД В НАСТРОЙКИ");
return true;
}
return false;
}
private bool HandlePromo()
{
if (_promoTimer.Update(!In.AnyButton()))
{
print("ТУТ БУДЕТ ПЕРЕХОД В ПРОМО");
return true;
}
return false;
}
}