77 lines
1.5 KiB
C#
77 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class TimerOnInactiveScript : MonoBehaviour
|
|
{
|
|
[SerializeField] float _ValueTargetTime = 30.0f;
|
|
[SerializeField] private Animator _Animator;
|
|
[SerializeField] GameObject _UIActive;
|
|
[SerializeField] GameObject _UIInactive;
|
|
|
|
private float _TargetTime;
|
|
|
|
private bool _CanMoveFrom;
|
|
|
|
private void Awake()
|
|
{
|
|
_CanMoveFrom = false;
|
|
_TargetTime = _ValueTargetTime;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_TargetTime -= Time.deltaTime;
|
|
if (_TargetTime <= 0.0f)
|
|
{
|
|
//Debug.Log("Òàéìåð Çàêîí÷èëñÿ");
|
|
_CanMoveFrom = true;
|
|
MoveCameraToRound();
|
|
}
|
|
|
|
if (Gamepad.current.wasUpdatedThisFrame)
|
|
{
|
|
//Debug.Log("êíîïêà íàæàòà");
|
|
ResetTimer();
|
|
MoveCameraFromRound();
|
|
}
|
|
}
|
|
|
|
void MoveCameraToRound()
|
|
{
|
|
_UIActive.SetActive(false);
|
|
//Debug.Log("Ïåðåìåñòèëñÿ ê");
|
|
_Animator.Play("MoveCameraToRound");
|
|
|
|
}
|
|
|
|
void MoveCameraFromRound()
|
|
{
|
|
if (_CanMoveFrom)
|
|
{
|
|
_UIInactive.SetActive(false);
|
|
_Animator.Play("MoveCameraFromRound");
|
|
//Debug.Log("Ïåðåìåñòèëñÿ îò");
|
|
ResetTimer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void SetActiveInactive()
|
|
{
|
|
|
|
_UIInactive.SetActive(true);
|
|
}
|
|
|
|
public void SetActiveActive()
|
|
{
|
|
|
|
_UIActive.SetActive(true);
|
|
}
|
|
|
|
void ResetTimer()
|
|
{
|
|
_TargetTime = _ValueTargetTime;
|
|
}
|
|
}
|