91 lines
2.7 KiB
C#
91 lines
2.7 KiB
C#
using Exoa.TutorialEngine;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class DemoScript : MonoBehaviour
|
|
{
|
|
|
|
public Button playBtn;
|
|
public Button action1Btn;
|
|
public Button action2Btn;
|
|
public Button startTutorialBtn;
|
|
public string startTutorialFile = "1.1";
|
|
public string playTutorialFile = "1.2";
|
|
public bool clickAnywhereToGONext = true;
|
|
|
|
private void OnDestroy()
|
|
{
|
|
TutorialEvents.OnTutorialComplete -= OnFirstTutorialCompleted;
|
|
TutorialEvents.OnTutorialComplete -= OnSecondTutorialCompleted;
|
|
}
|
|
void Start()
|
|
{
|
|
if (startTutorialBtn != null) startTutorialBtn.onClick.AddListener(OnClickStartTutorial);
|
|
if (playBtn != null) playBtn.gameObject.SetActive(false);
|
|
if (action1Btn != null) action1Btn.gameObject.SetActive(false);
|
|
if (action2Btn != null) action2Btn.gameObject.SetActive(false);
|
|
|
|
}
|
|
/// <summary>
|
|
/// Starting first tutorial
|
|
/// </summary>
|
|
void OnClickStartTutorial()
|
|
{
|
|
TutorialController.IsSkippable = false;
|
|
TutorialLoader.instance.Load(startTutorialFile);
|
|
TutorialEvents.OnTutorialComplete += OnFirstTutorialCompleted;
|
|
|
|
if (startTutorialBtn != null) startTutorialBtn.gameObject.SetActive(false);
|
|
if (playBtn != null) playBtn.gameObject.SetActive(true);
|
|
if (action1Btn != null) action1Btn.gameObject.SetActive(true);
|
|
if (action2Btn != null) action2Btn.gameObject.SetActive(true);
|
|
}
|
|
|
|
|
|
private void OnFirstTutorialCompleted()
|
|
{
|
|
TutorialEvents.OnTutorialComplete -= OnFirstTutorialCompleted;
|
|
if (startTutorialBtn != null) startTutorialBtn.gameObject.SetActive(true);
|
|
if (playBtn != null) playBtn.gameObject.SetActive(true);
|
|
if (playBtn != null) playBtn.onClick.AddListener(OnClickPlay);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Second tutorial
|
|
/// </summary>
|
|
void OnClickPlay()
|
|
{
|
|
TutorialController.IsSkippable = true;
|
|
TutorialLoader.instance.Load(playTutorialFile, true);
|
|
TutorialEvents.OnTutorialComplete += OnSecondTutorialCompleted;
|
|
|
|
if (playBtn != null) playBtn.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
private void OnSecondTutorialCompleted()
|
|
{
|
|
TutorialEvents.OnTutorialComplete -= OnSecondTutorialCompleted;
|
|
if (startTutorialBtn != null) startTutorialBtn.gameObject.SetActive(true);
|
|
if (playBtn != null)
|
|
{
|
|
playBtn.gameObject.SetActive(true);
|
|
playBtn.onClick.RemoveAllListeners();
|
|
}
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (clickAnywhereToGONext &&
|
|
TutorialController.IsTutorialActive &&
|
|
Input.GetMouseButtonDown(0))
|
|
{
|
|
TutorialController.instance.Next();
|
|
}
|
|
}
|
|
}
|