/
UIPopupSupervisor.cs
258 lines (249 loc) · 9.24 KB
/
UIPopupSupervisor.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public enum UI_POPUP_TYPE
{
Inventory = 0,
CraftItem,
Shop,
//
GameMenu,
GameMessage,
LoadMapGameMessage,
//
ItemData,
PurchaseItem,
SellItem,
CharInfo,
// network.
WaitingConnect,
PromptServerIP
}
/// <summary>
/// InGame Scene에서 UIPopup 창을 관리하는 클래스.
/// </summary>
public class UIPopupSupervisor : MonoBehaviour {
// in-game UI popups.
public static bool bInvenOpen { get; private set; } = false;
public static bool bGameMenuOpen { get; private set; } = false;
public static bool bGameMessageOpen { get; private set; } = false;
public static bool bLoadGameMessageOpen { get; private set; } = false;
public static bool bItemDataOpen { get; private set; } = false;
public static bool bCraftItemOpen { get; private set; } = false;
public static bool bShopOpen { get; private set; } = false;
public static bool bPurchaseItemOpen { get; private set; } = false;
public static bool bSellItemOpen { get; private set; } = false;
// network UI popups.
public static bool bWaitingConnectOpen { get; private set; } = false;
public static bool bPromptServerIPOpen { get; private set; } = false;
public static int CurrentPopupCount { get; private set; } = 0;
//
private static bool _bAllPopupClose = false;
public static bool bInGameAllPopupClose
{
get
{
if ((bInvenOpen == false) &&
(bGameMenuOpen == false) &&
(bGameMessageOpen == false) &&
(bItemDataOpen == false) &&
(bCraftItemOpen == false) &&
(bShopOpen == false) &&
(bPurchaseItemOpen == false) &&
(bSellItemOpen == false) &&
(bWaitingConnectOpen == false) &&
(bPromptServerIPOpen == false) &&
(bLoadGameMessageOpen == false))
{
_bAllPopupClose = true;
return _bAllPopupClose;
}
else
return _bAllPopupClose;
}
}
public static void OpenPopupUI(UI_POPUP_TYPE popuptype)
{
bool bOpenPopup = false;
switch (popuptype)
{
case UI_POPUP_TYPE.CraftItem:
if (bCraftItemOpen == false)
{
SceneManager.LoadSceneAsync("popup_craftItem", LoadSceneMode.Additive);
bCraftItemOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.Inventory:
if (bInvenOpen == false)
{
SceneManager.LoadSceneAsync("popup_inventory", LoadSceneMode.Additive);
bInvenOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.Shop:
if (bShopOpen == false)
{
SceneManager.LoadSceneAsync("popup_shop", LoadSceneMode.Additive);
bShopOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.GameMenu:
if (bGameMenuOpen == false)
{
SceneManager.LoadSceneAsync("popup_menu", LoadSceneMode.Additive);
bGameMenuOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.GameMessage:
if (bGameMessageOpen == false)
{
SceneManager.LoadSceneAsync("popup_message", LoadSceneMode.Additive);
bGameMessageOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.LoadMapGameMessage:
if (bLoadGameMessageOpen == false)
{
SceneManager.LoadSceneAsync("popup_map_load_message", LoadSceneMode.Additive);
bLoadGameMessageOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.ItemData:
if (bItemDataOpen == false)
{
SceneManager.LoadSceneAsync("popup_ItemData", LoadSceneMode.Additive);
bItemDataOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.PurchaseItem:
if (bPurchaseItemOpen == false)
{
SceneManager.LoadSceneAsync("popup_purChaseItem", LoadSceneMode.Additive);
bPurchaseItemOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.SellItem:
if (bSellItemOpen == false)
{
SceneManager.LoadSceneAsync("popup_sellItem", LoadSceneMode.Additive);
bSellItemOpen = true;
_bAllPopupClose = false;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.CharInfo:
SceneManager.LoadSceneAsync("popup_chInfo", LoadSceneMode.Additive);
bOpenPopup = true;
break;
// Network UI Popups.
case UI_POPUP_TYPE.WaitingConnect:
if(bWaitingConnectOpen == false)
{
SceneManager.LoadSceneAsync("popup_waitingConnect", LoadSceneMode.Additive);
bWaitingConnectOpen = true;
bOpenPopup = true;
}
break;
case UI_POPUP_TYPE.PromptServerIP:
if (bPromptServerIPOpen == false)
{
SceneManager.LoadSceneAsync("popup_prompt_server_ip", LoadSceneMode.Additive);
bPromptServerIPOpen = true;
bOpenPopup = true;
}
break;
}
if (bOpenPopup == true)
{
Cursor.lockState = CursorLockMode.Confined;
CurrentPopupCount++;
}
}
public static void ClosePopupUI(UI_POPUP_TYPE popuptype)
{
bool bClosePopup = false;
switch (popuptype)
{
case UI_POPUP_TYPE.CraftItem:
SceneManager.UnloadSceneAsync("popup_craftItem");
bCraftItemOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.Inventory:
SceneManager.UnloadSceneAsync("popup_inventory");
bInvenOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.Shop:
SceneManager.UnloadSceneAsync("popup_shop");
bShopOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.GameMenu:
SceneManager.UnloadSceneAsync("popup_menu");
bGameMenuOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.GameMessage:
SceneManager.UnloadSceneAsync("popup_message");
bGameMessageOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.LoadMapGameMessage:
SceneManager.UnloadSceneAsync("popup_map_load_message");
bLoadGameMessageOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.ItemData:
SceneManager.UnloadSceneAsync("popup_ItemData");
bItemDataOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.PurchaseItem:
SceneManager.UnloadSceneAsync("popup_purChaseItem");
bPurchaseItemOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.SellItem:
SceneManager.UnloadSceneAsync("popup_sellItem");
bSellItemOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.CharInfo:
SceneManager.UnloadSceneAsync("popup_chInfo");
bClosePopup = true;
break;
// Network UI Popups.
case UI_POPUP_TYPE.WaitingConnect:
SceneManager.UnloadSceneAsync("popup_waitingConnect");
bWaitingConnectOpen = false;
bClosePopup = true;
break;
case UI_POPUP_TYPE.PromptServerIP:
SceneManager.UnloadSceneAsync("popup_prompt_server_ip");
bPromptServerIPOpen = false;
bClosePopup = true;
break;
}
//
if (bClosePopup == true) CurrentPopupCount--;
if(bInGameAllPopupClose == true) Cursor.lockState = CursorLockMode.Locked;
}
}