82 lines
2.0 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 System;
using UnityEngine;
public class Menu : MonoBehaviour, IControlable
{
public MenuAnimator menuAnimator;
public MenuPanelManager menuPanelManager;
[SerializeField] private float _timeToPromo = 180f;
[SerializeField] private float _timeToSettings = 1f;
[SerializeField] private MenuPromoTransit _menuPromoTransit;
private HoldTimer _promoTimer;
private HoldTimer _settingsTimer;
public bool ControlsEnabled { get; set; }
private void Update()
{
if (ControlsEnabled == false)
return;
//переход настройки
if (_settingsTimer.Update(In.GetButton(InSignal.secret)))
{
print("ТУТ БУДЕТ ПЕРЕХОД В НАСТРОЙКИ");
return;
}
//переход промо
if (_promoTimer.Update(!In.AnyButton()))
{
_menuPromoTransit.GotoPromo();
return;
}
}
public void Initialize()
{
menuAnimator.Initialize();
menuPanelManager.Initialize();
_promoTimer = new HoldTimer(_timeToPromo);
_settingsTimer = new HoldTimer(_timeToSettings);
ControlsEnabled = true;
}
public void UpdateControls()
{
int direction_horizontal = In.GetAxis(Axis.Horizontal, JoystickSide.Both);
menuPanelManager.SwitchPanel(direction_horizontal);
bool action = In.GetButtonDownAnyPlayer(PlayerAction.action);
if (action)
menuPanelManager.InteractCurrent();
}
public void Open(Action callback)
{
Enable();
menuAnimator.Open(callback);
}
public void Close(Action callback)
{
Disable();
menuAnimator.Close(callback);
}
private void Enable()
{
ControlsEnabled = true;
LightUtility.Idle();
}
private void Disable()
{
ControlsEnabled = false;
_promoTimer.Reset();
_settingsTimer.Reset();
}
}