-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTasks_GameManager.cs
More file actions
139 lines (124 loc) · 3.34 KB
/
Tasks_GameManager.cs
File metadata and controls
139 lines (124 loc) · 3.34 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
public class Tasks_GameManager : MonoBehaviour
{
//EndText
public float typeSpeed;
public Canvas NarratorBox;
public TextMeshProUGUI NarratorText;
public Button ContinueButton;
private int index;
[TextArea(3, 10)]
public string[] sentences;
//Text
public TextMeshProUGUI GramStatus;
public TextMeshProUGUI FarmStatus;
public TextMeshProUGUI MailStatus;
public TextMeshProUGUI TireStatus;
//Bools
public bool isGrandmaFinished;
public bool isFarmerFinished;
public bool isMailFinished;
public bool isTruckerFinished;
//Game Objects
public GameObject TaskDisplay;
public Button Finish;
public Button Close;
//Pause Menu
public GameObject pauseMenu;
// Start is called before the first frame update
void Start()
{
GramStatus.text = "Incomplete";
FarmStatus.text = "Incomplete";
MailStatus.text = "Incomplete";
TireStatus.text = "Incomplete";
}
IEnumerator Talking()
{
foreach (char letterTwo in sentences[index])
{
NarratorText.text += letterTwo;
yield return new WaitForSeconds(typeSpeed);
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{
pauseMenu.SetActive(true);
Time.timeScale = 0f;
}
//
if (NarratorText.text == sentences[index])
{
ContinueButton.gameObject.SetActive(true);
}
//////
///
//////
if (isGrandmaFinished == true)
{
GramStatus.text = "Cat was Found!";
}
if (isFarmerFinished == true)
{
FarmStatus.text = "All Trees Planted!";
}
if(isMailFinished == true)
{
MailStatus.text = "All Mail Found!";
}
if (isTruckerFinished == true)
{
TireStatus.text = "Tire was Fixed!";
}
if(Input.GetKeyDown(KeyCode.T))
{
TaskDisplay.SetActive(true);
}
///
///
if(isGrandmaFinished == true && isFarmerFinished == true && isMailFinished == true && isTruckerFinished == true)
{
Finish.gameObject.SetActive(true);
Close.gameObject.SetActive(false);
}
}
public void Continue()
{
ContinueButton.gameObject.SetActive(false);
if (index < sentences.Length - 1)
{
index++;
NarratorText.text = "";
StartCoroutine(Talking());
}
else
{
NarratorText.text = "";
NarratorBox.gameObject.SetActive(false);
SceneManager.LoadScene("EndScene");
}
}
public void FinishButton()
{
NarratorBox.gameObject.SetActive(true);
StartCoroutine(Talking());
}
public void Resume()
{
Time.timeScale = 1f;
pauseMenu.SetActive(false);
}
public void Menu()
{
Time.timeScale = 1f;
SceneManager.LoadScene(0);
}
}