forked from PanukomKo/StadiaTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorialController.cs
More file actions
81 lines (65 loc) · 1.98 KB
/
Copy pathTutorialController.cs
File metadata and controls
81 lines (65 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TutorialController : MonoBehaviour {
public GameObject tutorialPanel;
public GameObject monsterPrefab;
public GameObject hand;
public GameObject indicatorBig;
public GameObject indicatorLine;
public GameObject indicatorEnd;
private Animator animator;
bool tutorialEnd = true;
public delegate void TutorialAction();
public static event TutorialAction OnTutorialEnd;
void Start()
{
animator = tutorialPanel.GetComponent<Animator>();
}
void OnEnable()
{
GameMasterController.OnPlay += startTutorial;
SwipeController.OnSwipe += finishTutorial;
}
void OnDisable()
{
GameMasterController.OnPlay -= startTutorial;
SwipeController.OnSwipe -= finishTutorial;
}
public void startTutorial()
{
GameObject tutorialMonster = Instantiate(monsterPrefab, new Vector3(-1.13f, 0, 0), transform.rotation, tutorialPanel.transform);
tutorialMonster.GetComponent<Monster>().setStop(true);
animator.enabled = true;
hand.SetActive(false);
indicatorBig.SetActive(false);
indicatorLine.SetActive(false);
indicatorEnd.SetActive(false);
tutorialPanel.SetActive(true);
StartCoroutine(startTutorialAnimation());
}
public void finishTutorial(int direction)
{
if (!tutorialEnd)
{
if (direction == 0)
{
StartCoroutine(stopTutorialAnimation());
tutorialEnd = true;
}
}
}
IEnumerator startTutorialAnimation()
{
tutorialEnd = false;
yield return new WaitForSeconds(0.2f);
animator.SetTrigger("Tutorial");
}
IEnumerator stopTutorialAnimation()
{
animator.enabled = false;
yield return new WaitForSeconds(0.5f);
tutorialPanel.SetActive(false);
OnTutorialEnd();
}
}