146 lines
3.4 KiB
C#
146 lines
3.4 KiB
C#
using BitStrap;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TutorialPanel : MonoBehaviour
|
|
{
|
|
public TutorialManager.TutorialsId tutorialId;
|
|
|
|
public TutorialManager.TutorialsId nextTutorial;
|
|
|
|
public TutorialManager.TutorialsId prevTutorial;
|
|
|
|
public GameObject skipInfo;
|
|
|
|
public BTN_TutorialSkip skipButton;
|
|
|
|
public bool isMenuTutorial;
|
|
|
|
public bool blockGuiInput = true;
|
|
|
|
public bool freezeTime = true;
|
|
|
|
public bool wasShown;
|
|
|
|
[ReadOnly]
|
|
public bool canBeSkipped;
|
|
|
|
[ReadOnly]
|
|
public float showTimer;
|
|
|
|
[HideInInspector]
|
|
public Text skipText;
|
|
|
|
[HideInInspector]
|
|
public Color skipTextColor = Color.white;
|
|
|
|
public string voiceOver = string.Empty;
|
|
|
|
[HideInInspector]
|
|
public AudioObject voAudioObject;
|
|
|
|
private void Start()
|
|
{
|
|
skipText = skipInfo.GetComponentInChildren<Text>();
|
|
skipText.color = new Color(skipText.color.r, skipText.color.g, skipText.color.b, 0f);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (base.gameObject.activeSelf && wasShown)
|
|
{
|
|
showTimer -= Time.unscaledDeltaTime;
|
|
if (showTimer < 0f && !canBeSkipped)
|
|
{
|
|
canBeSkipped = true;
|
|
skipText.color = new Color(skipText.color.r, skipText.color.g, skipText.color.b, 0.1f);
|
|
LeanTween.textAlpha(skipText.rectTransform, 1f, 1f).setEaseInOutQuad().setLoopPingPong()
|
|
.setRepeat(-1)
|
|
.setIgnoreTimeScale(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowTutorial()
|
|
{
|
|
if (!TutorialManager.Instance.currentTutorial && (!wasShown || TutorialManager.Instance.showAlways || prevTutorial != TutorialManager.TutorialsId.NONE))
|
|
{
|
|
skipButton.gameObject.SetActive(skipButton.GetComponent<Button>().interactable);
|
|
base.gameObject.SetActive(true);
|
|
wasShown = true;
|
|
canBeSkipped = false;
|
|
AudioController.Play("tutorial_show_01");
|
|
voAudioObject = AudioController.Play(voiceOver);
|
|
if (freezeTime && prevTutorial == TutorialManager.TutorialsId.NONE)
|
|
{
|
|
TutorialManager.Instance.prevTimeScale = Time.timeScale;
|
|
Time.timeScale = 0f;
|
|
}
|
|
if (blockGuiInput && (!VRManager.IsVROn() || isMenuTutorial))
|
|
{
|
|
TutorialManager.Instance.inputBlock.SetActive(true);
|
|
}
|
|
showTimer = TutorialManager.Instance.skipDelay;
|
|
TutorialManager.Instance.UpdateHelpParams(tutorialId, true);
|
|
TutorialManager.Instance.currentTutorial = this;
|
|
VRManager.Instance.FixTutorialPosition();
|
|
}
|
|
}
|
|
|
|
public void HideTutorial()
|
|
{
|
|
if (tutorialId == TutorialManager.TutorialsId.VR_NOT_INITIALIZED)
|
|
{
|
|
wasShown = false;
|
|
Debug.LogError("VR_NOT_INITIALIZED");
|
|
Application.Quit();
|
|
return;
|
|
}
|
|
base.gameObject.SetActive(false);
|
|
TutorialManager.Instance.currentTutorial = null;
|
|
VRManager.Instance.FixTutorialPosition();
|
|
AudioController.Play("tutorial_hide_01");
|
|
if (voAudioObject != null)
|
|
{
|
|
voAudioObject.Stop();
|
|
}
|
|
if (nextTutorial != TutorialManager.TutorialsId.NONE)
|
|
{
|
|
TutorialManager.Instance.ShowTutorial(nextTutorial);
|
|
return;
|
|
}
|
|
if (freezeTime && (!HUDManager.Instance || HUDManager.Instance.currentHudState != HUDManager.HUDState.PAUSE))
|
|
{
|
|
Time.timeScale = TutorialManager.Instance.prevTimeScale;
|
|
}
|
|
TutorialManager.Instance.inputBlock.SetActive(false);
|
|
TutorialManager.Instance.Save();
|
|
}
|
|
|
|
public void HideTutorialForce()
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
|
|
public bool IsVisible()
|
|
{
|
|
return base.gameObject.activeSelf;
|
|
}
|
|
|
|
public void ResetTutorial()
|
|
{
|
|
wasShown = false;
|
|
}
|
|
|
|
public void SkipTutorials()
|
|
{
|
|
TutorialManager.Instance.SetIsActive(false);
|
|
HideTutorial();
|
|
}
|
|
|
|
private void OnClick()
|
|
{
|
|
HideTutorial();
|
|
}
|
|
}
|