UIController.cs
3.84 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
140
141
142
143
144
145
146
147
148
149
150
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIController : MonoBehaviour {
public Canvas gameOverUI;
public Canvas gameStartUI;
public Text TimerText;
public Text MissionCubeText;
public Text HighScoreText;
public RawImage GameClearImage;
public Text InformText;
public float timer { get; set; }
private bool playing;
// Use this for initialization
private static UIController instance;
public static UIController Instance
{
get
{
if (instance == null)
{
instance = GameObject.FindObjectOfType<UIController>();
}
return instance;
}
}
private void Awake()
{
playing = true;
gameOverUI = GameObject.Find("GameOverUI").GetComponent<Canvas>();
gameStartUI = GameObject.Find("GameStartUI").GetComponent<Canvas>();
TimerText = GameObject.Find("Timer Text").GetComponent<Text>();
MissionCubeText = GameObject.Find("MissionCubeText").GetComponent<Text>();
HighScoreText = GameObject.Find("HighScoreText").GetComponent<Text>();
GameClearImage = GameObject.Find("ClearImage").GetComponent<RawImage>();
InformText = GameObject.Find("InformText").GetComponent<Text>();
if (gameOverUI)
{
Debug.Log(gameOverUI.name);
}
else
{
Debug.Log("똥!");
}
if (gameStartUI)
{
Debug.Log(gameStartUI.name);
}
else
{
Debug.Log("똥!");
}
if (TimerText)
{
Debug.Log(TimerText.name);
}
else
{
Debug.Log("똥!");
}
}
/* Easter egg
decim아니;;;나도 아직 안봄..ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ아 이거 하고있었음?
ㄴㄴ 하고있지는 않았는데.. 같이 보자 ㅠㅠ알겠엉
언재ㅔ오ㅓ
나 전교수님 상담!! 밥 어떡할거?나 점심 약소있음ㅇㅋㅇㅋ 점심먹고 보자
*/
void Start ()
{
timer = 0;
gameOverUI.gameObject.SetActive(false);
GameClearImage.gameObject.SetActive(false);
gameStartUI.gameObject.SetActive(true);
//ScoreManager.Instance.SaveScore(22);
}
// Update is called once per frame
void Update () {
UpdateTimerUI();
}
public void GameOverUI()
{
GameClearImage.gameObject.SetActive(false);
gameOverUI.gameObject.SetActive(true);
}
public void GameStartUI()
{
gameStartUI.gameObject.SetActive(true);
}
public void GameClearUI()
{
GameClearImage.gameObject.SetActive(true);
}
public void GameClearUIOff()
{
GameClearImage.gameObject.SetActive(false);
}
public void UpdateTimerUI()
{
if (ScaleUpGameManager.Instance.onGame)
{
timer += Time.deltaTime;
string result = string.Format("{0: #.##} sec", timer);
TimerText.text = result;
}
else
{
timer = 0;
string result = string.Format("{0: #.##} sec", timer);
TimerText.text = result;
}
}
public void UpdateHighScoreText()
{
string result = string.Format("{0: #.##} sec", ScoreManager.Instance.GetHighScore());
HighScoreText.text = result;
}
public void MissionCubeUI(int cubeCnt)
{
MissionCubeText.text = cubeCnt + " / 3";
}
public void GameStartUIClicked()
{
InformText.gameObject.SetActive(false);
gameStartUI.gameObject.SetActive(false);
}
public void GameOverUIClicked()
{
gameOverUI.gameObject.SetActive(false);
gameStartUI.gameObject.SetActive(true);
}
}