62 lines
1.4 KiB
C#
62 lines
1.4 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Events;
|
||
|
using UnityEngine.InputSystem;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class VisorUIModule : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField]
|
||
|
private CanvasGroup _mainPanel;
|
||
|
[SerializeField]
|
||
|
private CanvasGroup _tutorPanel;
|
||
|
[SerializeField]
|
||
|
private Image _progressBarImage;
|
||
|
|
||
|
public InputActionReference LeftTrigger;
|
||
|
public InputActionReference RightTrigger;
|
||
|
|
||
|
private float _visibleValue = 0;
|
||
|
|
||
|
private bool _visorActivated = false;
|
||
|
|
||
|
public UnityEvent OnVisorActivated = new UnityEvent();
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
if (_visorActivated)
|
||
|
return;
|
||
|
|
||
|
if (RightTrigger.action.inProgress && LeftTrigger.action.inProgress)
|
||
|
{
|
||
|
_visibleValue = Mathf.Clamp01(_visibleValue + Time.deltaTime);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_visibleValue = Mathf.Clamp01(_visibleValue - Time.deltaTime);
|
||
|
}
|
||
|
|
||
|
UpdateVisorValue();
|
||
|
}
|
||
|
|
||
|
private void UpdateVisorValue()
|
||
|
{
|
||
|
_mainPanel.alpha = _visibleValue;
|
||
|
_tutorPanel.alpha = 1 - _visibleValue;
|
||
|
_progressBarImage.fillAmount = _visibleValue;
|
||
|
|
||
|
if (_visibleValue == 1)
|
||
|
{
|
||
|
ActivateVisor();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ActivateVisor()
|
||
|
{
|
||
|
_visorActivated = true;
|
||
|
OnVisorActivated?.Invoke();
|
||
|
}
|
||
|
}
|