/
Tutorial.cs
96 lines (83 loc) · 2.28 KB
/
Tutorial.cs
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Tutorial : MonoBehaviour {
private GameController gameController;
private WaveSystem waveSystem;
private int tutorialCount;
//checks the progression of the tutorial
public Text tutorialText;
//displays the tutorial text, quick guide for the player
private float timer;
//amount of time
void Start () {
timer = 3;
waveSystem = GetComponent<WaveSystem> ();
gameController = GetComponent<GameController> ();
tutorialText.text = "";
tutorialCount = 0;
StartCoroutine (TutorialWait ());
}
void Update () {
//start of the tutorial
if (tutorialCount == 1) {
tutorialText.text = "Press Any Key";
if (Input.anyKeyDown) {
// adds one to the tutorial counter
gameController.spawn = true;
gameController.showUI = true;
StartCoroutine (TutorialWait ());
tutorialCount++;
}
}
//movement tutorial
if (tutorialCount == 3) {
tutorialText.text = "Press WASD to Move";
if (Input.GetKeyDown (KeyCode.W)) {
// adds one to the tutorial counter
StartCoroutine (TutorialWait ());
tutorialCount++;
}
if (Input.GetKeyDown (KeyCode.S)) {
// adds one to the tutorial counter
StartCoroutine (TutorialWait ());
tutorialCount++;
}
if (Input.GetKeyDown (KeyCode.A)) {
// adds one to the tutorial counter
StartCoroutine (TutorialWait ());
tutorialCount++;
}
if (Input.GetKeyDown (KeyCode.D)) {
// adds one to the tutorial counter
StartCoroutine (TutorialWait ());
tutorialCount++;
}
}
//shooting tutorial
if (tutorialCount == 5) {
tutorialText.text = "Press 'Spacebar' to Shoot!";
if (Input.GetKey (KeyCode.Space)) {
// adds one to the tutorial counter
StartCoroutine (TutorialWait ());
tutorialCount++;
}
}
if (tutorialCount == 7) {
waveSystem.display = true;
waveSystem.startWaves = true;
waveSystem.waves++;
tutorialCount++;
}
if (tutorialCount >= 8) {
StopAllCoroutines ();
}
}
IEnumerator TutorialWait ()
{ //waits for certain amount of time
tutorialText.text = "";
yield return new WaitForSeconds (timer);
// adds one to the tutorial counter
tutorialCount ++;
}
}