/
TransitionScreen.cs
368 lines (316 loc) · 13.2 KB
/
TransitionScreen.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
using UnityEngine;
namespace Plugin.Squancher.AdventureMod
{
public class BattleStartMenu : MonoBehaviour
{
public static bool _open;
public Rect windowRect;
private float intendedWindowWidth = 180f;
private BattleStartMenu()
{
}
public static void OpenWindow()
{
_open = true;
}
public static void CloseWindow()
{
_open = false;
}
public bool IsOpen()
{
return _open;
}
public void RenderWindow(int windowID)
{
Rect location = new Rect(0f, 0f, this.windowRect.width, this.windowRect.height);
if (location.Contains(Event.current.mousePosition))
{
GUIManager.getInstance().mouseInGUI = true;
}
Rect location6 = new Rect((float)(Screen.width / 2 - 270), 32f, 580f, 180f);
GUIManager.getInstance().DrawWindow(location6, "Fight Initiated!", false);
GUIManager.getInstance().DrawTextCenteredBlack(new Rect(location6.xMin + 8f, location6.yMin + 30f, location6.width - 16f, 110f), "Left click to place a unit.");
GUIManager.getInstance().DrawTextCenteredBlack(new Rect(location6.xMin + 8f, location6.yMin + 60f, location6.width - 16f, 110f), "E/Q to rotate unit.");
GUIManager.getInstance().DrawTextCenteredBlack(new Rect(location6.xMin + 8f, location6.yMin + 90f, location6.width - 16f, 110f), "TAB to replace unit.");
if (BattleManager.UnitsToPlace == 0)
{
if (GUIManager.getInstance().DrawButton(new Rect(Screen.width / 2 - 100, location6.yMin + 130f, 200f, 34f), "Ready"))
{
CloseWindow();
BattleManager.isPlacingUnits = false;
BattleManager.isPlacingUnits2 = false;
BattleManager.isPlaced = true;
GUIManager.getInstance().inGame = true;
BattleManager.GetEnemyTarget();
BattleManager.GetEnemyRemaining();
BattleManager.RemoveDesignations();
/************
* BattleGui here! when initiated take the inGame back in all functions
* Make an (inbattle !inGame) comparison.
************/
}
}
}
public void OnGUI()
{
if (GUIManager.getInstance().inGame)
{
return;
}
if (TransitionScreen.IsOpen())
{
return;
}
if (!IsOpen())
{
return;
}
Rect rect = new Rect(0f, 0f, Screen.width, Screen.height);
Rect windowRect = GUI.Window(193, rect, new GUI.WindowFunction(this.RenderWindow), string.Empty, GUIManager.getInstance().hiddenButtonStyle);
GUI.FocusWindow(193);
}
public void Update()
{
}
}
public class BattleOverMenu : MonoBehaviour
{
public static bool _open;
public static string invasion;
public Rect windowRect;
private float intendedWindowWidth = 200f;
private BattleOverMenu()
{
}
public void Start()
{
}
public static void OpenWindow()
{
_open = true;
}
public static void CloseWindow()
{
_open = false;
}
public bool IsOpen()
{
return _open;
}
public void RenderWindow(int windowID)
{
Rect location = new Rect(0f, 0f, this.windowRect.width, this.windowRect.height);
if (location.Contains(Event.current.mousePosition))
{
GUIManager.getInstance().mouseInGUI = true;
}
AManager<TimeManager>.getInstance().pause();
location = new Rect((Screen.width / 2 - 240f), Screen.height / 2 - 90f, 480f, 200f);
GUIManager.getInstance().DrawWindow(location, "Battle Summary", false);
GUIManager.getInstance().DrawTextCenteredBlack(new Rect(location.xMin + 8f, location.yMin + 30f, location.width - 16f, 110f), "You found!");
int num, num2;
Resource rawMats = Resource.FromID(GUIManager.getInstance().rawMatsSortType[0]);
Resource pMats = Resource.FromID(GUIManager.getInstance().indexesProcessedMats[0]);
Rect location2 = new Rect(location.x + 120f, location.y + 58f, 24f, 24f);
GUI.DrawTexture(new Rect(location2.x, location2.y, 24f, 24f), rawMats.icon);
GUIManager.getInstance().DrawTextCenteredWhite(new Rect(location2.x + 25f, location2.y, 50f, 24f), BattleManager.foodAmount + "");
Rect location3 = new Rect(location2.x, location2.y + 24f, 24f, 24f);
GUI.DrawTexture(new Rect(location3.x, location3.y, 24f, 24f), pMats.icon);
GUIManager.getInstance().DrawTextCenteredWhite(new Rect(location3.x + 25f, location3.y, 50f, 24f), BattleManager.coinAmount + "");
Resource resource = Resource.FromID(GUIManager.getInstance().rawMatsSortType[0]);
if (GUIManager.getInstance().DrawButton(new Rect(Screen.width/2 - 71f, location.y + 162f, 142f, 32f), "Ok"))
{
if (BattleManager.isToTown == false)
{
BattleManager.isBattleOver = false;
BattleManager.isToTown = true;
AManager<TimeManager>.getInstance().pause();
if (!TransitionScreen.IsOpen())
{
CloseWindow();
TransitionScreen.OpenWindow();
AdventureMap.OpenWindow();
BattleManager.time = 0;
}
}
}
num = 120; num2 = 82;
num2 += 24;
for (int i = 0; i < BattleManager.rewards.Count; i++)
{
int type = BattleManager.rewards.Find(x => x.id == i).type;
int itemID = BattleManager.rewards.Find(x => x.id == i).itemid;
int amount = BattleManager.rewards.Find(x => x.id == i).amount;
if (i == 1)
{
num = 200;
num2 = 58;
}
if (i == 4)
{
num = 280;
num2 = 58;
}
if (type == 0)
{
resource = Resource.FromID(GUIManager.getInstance().weaponsSortType[itemID]);
}
if (type == 1)
{
resource = Resource.FromID(GUIManager.getInstance().armorSortType[itemID]);
}
if (type == 2)
{
resource = Resource.FromID(GUIManager.getInstance().indexesProcessedMats[itemID]);
}
if (type == 3)
{
resource = Resource.FromID(GUIManager.getInstance().rawMatsSortType[itemID]);
}
location2 = new Rect(location.x + num, location.y + num2, 24f, 24f);
GUI.DrawTexture(new Rect(location2.x, location2.y, 24f, 24f), resource.icon);
GUIManager.getInstance().DrawTextCenteredWhite(new Rect(location2.x + 25f, location2.y, 50f, 24f), "" + amount);
num2 += 24;
}
//Note: implement by invasion type or unit type loot list....
/*if (invasion == "wolf")
{
//EnemyCount
Resource animalRawMats = Resource.FromID(GUIManager.getInstance().rawMatsSortType[9]);
GUI.DrawTexture(new Rect(Screen.width / 2 - 36f, Screen.height / 2 + 55f, 24f, 24f), animalRawMats.icon);
animalRawMats = Resource.FromID(GUIManager.getInstance().rawMatsSortType[10]);
GUI.DrawTexture(new Rect(Screen.width / 2 - 12f, Screen.height / 2 + 55f, 24f, 24f), animalRawMats.icon);
animalRawMats = Resource.FromID(GUIManager.getInstance().rawMatsSortType[11]);
GUI.DrawTexture(new Rect(Screen.width / 2 + 36f, Screen.height / 2 + 55f, 24f, 24f), animalRawMats.icon);
}
else if (invasion == "spider")
{
//EnemyCount
Resource animalRawMats = Resource.FromID(GUIManager.getInstance().rawMatsSortType[7]);
GUI.DrawTexture(new Rect(Screen.width / 2 - 12, Screen.height / 2 + 55f, 24f, 24f), animalRawMats.icon);
}
else
{
if (bounty1 > 0.8f)
{
Resource weapons = Resource.FromID(GUIManager.getInstance().weaponsSortType[reward1]);
GUI.DrawTexture(new Rect(Screen.width / 2 + 16f, Screen.height / 2 + 88f, 25f, 25f), weapons.icon);
GUIManager.getInstance().DrawTextCenteredWhite(new Rect(Screen.width / 2 + 16f, Screen.height / 2 + 88f, 50f, 24f), "100");
}
if (BattleManager.bounty2 > 0.8f)
{
Resource armor = Resource.FromID(GUIManager.getInstance().armorSortType[reward2]);
GUI.DrawTexture(new Rect(Screen.width / 2 + 49f, Screen.height / 2 + 88f, 25f, 25f), armor.icon);
}
}*/
}
public void OnGUI()
{
if (!GUIManager.getInstance().inGame)
{
return;
}
if (!IsOpen())
{
return;
}
Rect rect = new Rect(0f, 0f, Screen.width, Screen.height);
Rect windowRect = GUI.Window(194, rect, new GUI.WindowFunction(this.RenderWindow), string.Empty, GUIManager.getInstance().hiddenButtonStyle);
GUI.FocusWindow(194);
}
public void Update()
{
}
}
public class TransitionScreen : MonoBehaviour
{
public static bool bOpen;
GUIManager guiMgr;
private ControlPlayer controller;
public Rect windowRect;
private float intendedWindowWidth = Screen.width;
//private Vector2 horizontalScrollPosition;
public Rect windowViewRect;
public static float countdown;
private TransitionScreen()
{
}
public void Start()
{
guiMgr = AManager<GUIManager>.getInstance();
windowRect = new Rect(0f, 0f, Screen.width, Screen.height);
windowViewRect = new Rect(0f, 0f, Screen.width, Screen.height);
this.controller = GUIManager.getInstance().controllerObj.GetComponent<ControlPlayer>();
countdown = 0f;
}
public static void OpenWindow()
{
countdown = 0;
bOpen = true;
GUIManager.getInstance().inGame = false;
}
public static void CloseWindow()
{
bOpen = false;
}
public static bool IsOpen()
{
return bOpen;
}
public void RenderWindow(int windowID)
{
if (BattleManager.isInTown)
{
GUIManager.getInstance().DrawTextCenteredWhite(new Rect(Screen.width / 2 - 110f, 100f, 220f, 30f), "Traveling to mission.");
}
if (BattleManager.isToTown)
{
GUIManager.getInstance().DrawTextCenteredWhite(new Rect(Screen.width / 2 - 110, 100f, 220f, 30f), "Traveling back home.");
}
}
public void OnGUI()
{
if (GUIManager.getInstance().inGame)
{
return;
}
if (!IsOpen())
{
return;
}
if (BattleManager.isInTown)
{
countdown++;
if (countdown >= 30f)
{
BattleManager.SendPartyOnQuest();
AdventureMap.CloseWindow();
CloseWindow();
countdown = 0;
return;
}
}
if (BattleManager.isToTown)
{
countdown++;
if (countdown >= 30f)
{
CloseWindow();
AdventureMap.CloseWindow();
BattleManager.SendPartyBackHome();
countdown = 0;
return;
}
}
this.windowRect.width = Mathf.Min(this.intendedWindowWidth, (float)(Screen.width - 4));
this.windowRect = GUI.Window(191, this.windowRect, new GUI.WindowFunction(this.RenderWindow), string.Empty, GUIManager.getInstance().hiddenButtonStyle);
GUI.FocusWindow(191);
this.windowRect.x = Mathf.Clamp(this.windowRect.x, 2f, (float)Screen.width - this.windowRect.width - 2f);
this.windowRect.y = Mathf.Clamp(this.windowRect.y, 40f, (float)Screen.height - this.windowRect.height - 2f);
}
public void Update()
{
}
}
}