94 lines
2.4 KiB
C#
Executable File
94 lines
2.4 KiB
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class TutorialManager : MonoBehaviour
|
|
{
|
|
public static bool justRegistered;
|
|
public static bool showing =false;
|
|
public static Camera UICamera => instance.UI_Camera;
|
|
public Camera UI_Camera;
|
|
public static TutorialManager instance;
|
|
public TutorialScreen[] firstTutorial;
|
|
public TutorialScreen[] minigameTutorial;
|
|
public TutorialScreen[] minigameFailed;
|
|
public bool isMinigame = false;
|
|
public GameObject[] itemsToDisableWhileInTuto;
|
|
// public Button btn_skip;
|
|
void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
void Start(){
|
|
// btn_skip.onClick.AddListener(OnSkip);
|
|
|
|
// justRegistered= true; //for testing purpose
|
|
|
|
|
|
// if(isMinigame){
|
|
// StartSequence(minigameTutorial);
|
|
// }else if(justRegistered){
|
|
// StartSequence(firstTutorial);
|
|
// justRegistered =false;
|
|
// }
|
|
}
|
|
|
|
|
|
async void StartSequence(TutorialScreen[] list){
|
|
skipped=false;
|
|
showing=true;
|
|
// btn_skip.gameObject.SetActive(true);
|
|
foreach(GameObject item in itemsToDisableWhileInTuto){
|
|
item.SetActive(false);
|
|
}
|
|
foreach(TutorialScreen screen in list){
|
|
screen.Hide();
|
|
}
|
|
for(int i=0; i < list.Length; i++){
|
|
nextClicked = false;
|
|
await Task.Delay(list[i].delayBeforeAppear);
|
|
list[i].Show();
|
|
|
|
while(!nextClicked && !skipped){
|
|
await Task.Delay(500);
|
|
}
|
|
list[i].Hide();
|
|
|
|
if(skipped){
|
|
break;
|
|
}
|
|
}
|
|
foreach(GameObject item in itemsToDisableWhileInTuto){
|
|
item.SetActive(true);
|
|
}
|
|
showing=false;
|
|
// btn_skip.gameObject.SetActive(false);
|
|
}
|
|
bool nextClicked= false;
|
|
bool skipped = false;
|
|
|
|
public static void NextClicked(){
|
|
instance.nextClicked = true;
|
|
}
|
|
|
|
void OnSkip(){
|
|
skipped=true;
|
|
}
|
|
|
|
public void MinigameFailed(){
|
|
StartSequence(minigameFailed);
|
|
}
|
|
|
|
public void Restart(){
|
|
Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
|
|
}
|
|
public void LoadScene(string name){
|
|
// SceneManager.LoadScene(name);
|
|
LoadingScreen.instance.LoadLevel(name);
|
|
}
|
|
}
|