Реализовать матч PvP до пяти очков и рабочую панель победы. Исправить возврат подготовленной фишки и оплаты при раннем выходе. Ограничить перемещения фишки бота осмысленными кандидатами.
65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using DG.Tweening;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class BackToMenuController : MonoBehaviour
|
|
{
|
|
[SerializeField, Min(0f)] private float _fadeDuration = 0.5f;
|
|
|
|
private CanvasGroup _canvasGroup;
|
|
private Tween _fadeTween;
|
|
private bool _canExit;
|
|
private bool _isWaitingForPreparedChip;
|
|
|
|
private void Awake()
|
|
{
|
|
_canvasGroup = GetComponent<CanvasGroup>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!_canExit || In.GetAxis(JoystickSide.Both, InteractMode.Discrete).y <= 0)
|
|
return;
|
|
|
|
Hide();
|
|
GameManager.Instance.GotoMenu();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_fadeTween?.Kill();
|
|
_fadeTween = null;
|
|
_canExit = false;
|
|
_isWaitingForPreparedChip = false;
|
|
}
|
|
|
|
public void Show()
|
|
{
|
|
_fadeTween?.Kill();
|
|
_fadeTween = null;
|
|
_canvasGroup.alpha = 1f;
|
|
_canExit = false;
|
|
_isWaitingForPreparedChip = true;
|
|
}
|
|
|
|
public void EnableExit()
|
|
{
|
|
if (!_isWaitingForPreparedChip)
|
|
return;
|
|
|
|
_isWaitingForPreparedChip = false;
|
|
_canExit = true;
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
_canExit = false;
|
|
_isWaitingForPreparedChip = false;
|
|
_fadeTween?.Kill();
|
|
_fadeTween = _canvasGroup
|
|
.DOFade(0f, _fadeDuration)
|
|
.SetUpdate(true);
|
|
_fadeTween.PlayForward();
|
|
}
|
|
}
|