-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtageUguiMainGame.cs
609 lines (546 loc) · 16.1 KB
/
UtageUguiMainGame.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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Utage;
//游戏剧情主界面
[AddComponentMenu("Utage/TemplateUI/MainGame")]
public class UtageUguiMainGame : UguiView
{
private bool _active;
private Camera[] _captureCameras;
private BootType bootType;
public GameObject buttons;
public Toggle checkAuto;
public Toggle checkSkip;
public UtageUguiConfig config;
[SerializeField]
private AdvEngine engine;
public UtageUguiGallery gallery;
private bool isInit;
[SerializeField]
private Utage.LetterBoxCamera letterBoxCamera;
private AdvSaveData loadData;
public UtageUguiSaveLoad saveLoad;
private string scenarioLabel;
public UtageUguiTitle title;
private void Awake()
{
this.Engine.Page.OnEndText.AddListener(new UnityAction<AdvPage>(this, (IntPtr) this.<Awake>m__0));
//初始化时将菜单取消激活
this.buttons.SetActive(false);
}
//截取游戏画面
private Texture2D CaptureScreen()
{
Rect rect = this.LetterBoxCamera.CachedCamera.get_rect();
int num = Mathf.CeilToInt(rect.get_x() * Screen.get_width());
int num2 = Mathf.CeilToInt(rect.get_y() * Screen.get_height());
int num3 = Mathf.FloorToInt(rect.get_width() * Screen.get_width());
int num4 = Mathf.FloorToInt(rect.get_height() * Screen.get_height());
return UtageToolKit.CaptureScreenFromLetterBoxCameras(this.CaptureCameras, new Rect((float) num, (float) num2, (float) num3, (float) num4));
}
//到保存点时调用,自动截图并保存至AutoSave
private void CaptureScreenOnSavePoint(AdvPage page)
{
if ((this.Engine.SaveManager.Type == AdvSaveManager.SaveType.SavePoint) && page.IsSavePoint)
{
Debug.Log("Capture");
base.StartCoroutine(this.CoCaptureScreen());
}
}
private void ClearBootData()
{
this.bootType = BootType.Default;
this.isInit = false;
this.loadData = null;
}
public override void Close()
{
base.Close();
this.Engine.UiManager.Close();
this.Engine.Config.IsSkip = false;
}
[DebuggerHidden]
private IEnumerator CoCaptureScreen()
{
return new <CoCaptureScreen>c__Iterator1 { $this = this };
}
[DebuggerHidden]
private IEnumerator CoQSave()
{
return new <CoQSave>c__Iterator3 { $this = this };
}
[DebuggerHidden]
private IEnumerator CoSave()
{
return new <CoSave>c__Iterator2 { $this = this };
}
[DebuggerHidden]
private IEnumerator CoWaitOpen()
{
return new <CoWaitOpen>c__Iterator0 { $this = this };
}
//根据active显示隐藏右侧菜单
private void DisplayMainMenu(bool active)
{
//如果菜单激活状态和显示激活状态不同
if (active != this._active)
{
//如果菜单按钮不在激活状态
if (!this.buttons.get_activeSelf())
{
//将菜单按钮激活
this.buttons.SetActive(true);
}
//num表示移动方向,如果转为未激活为-1,即隐藏菜单
float num = !active ? -1f : 1f;
//num2表示移动速度,如果转变激活状态为1,否则为0(不显示动画)
int num2 = !active ? 1 : 0;
this.buttons.GetComponent<Animator>().Play("MainMenuMovement", 0, (float) num2);
this.buttons.GetComponent<Animator>().SetFloat("speed", num);
this._active = active;
}
}
private void LateUpdate()
{
bool active = this.Engine.UiManager.IsShowingMenuButton && (this.Engine.UiManager.Status == AdvUiManager.UiStatus.Menu);
this.DisplayMainMenu(active);
if ((this.checkSkip != null) && (this.checkSkip.get_isOn() != this.Engine.Config.IsSkip))
{
this.checkSkip.set_isOn(this.Engine.Config.IsSkip);
}
if ((this.checkAuto != null) && (this.checkAuto.get_isOn() != this.Engine.Config.IsAutoBrPage))
{
this.checkAuto.set_isOn(this.Engine.Config.IsAutoBrPage);
}
}
private void OnOpen()
{
if (this.Engine.SaveManager.Type != AdvSaveManager.SaveType.SavePoint)
{
this.Engine.SaveManager.ClearCaptureTexture();
}
base.StartCoroutine(this.CoWaitOpen());
}
public void OnTapAuto(bool isOn)
{
this.Engine.Config.IsAutoBrPage = isOn;
}
public void OnTapConfig()
{
this.Close();
this.config.Open(this);
}
public void OnTapLoad()
{
if (!this.Engine.IsSceneGallery)
{
this.Close();
this.saveLoad.OpenLoad(this);
}
}
public void OnTapQLoad()
{
if (!this.Engine.IsSceneGallery)
{
this.Engine.Config.IsSkip = false;
this.Engine.QuickLoad();
}
}
public void OnTapQSave()
{
if (!this.Engine.IsSceneGallery)
{
this.Engine.Config.IsSkip = false;
base.StartCoroutine(this.CoQSave());
}
}
public void OnTapSave()
{
if (!this.Engine.IsSceneGallery)
{
base.StartCoroutine(this.CoSave());
}
}
public void OnTapSkip(bool isOn)
{
this.Engine.Config.IsSkip = isOn;
}
public void OpenLoadGame(AdvSaveData loadData)
{
this.ClearBootData();
this.bootType = BootType.Load;
this.loadData = loadData;
this.Open();
}
public void OpenSceneGallery(string scenarioLabel)
{
this.ClearBootData();
this.bootType = BootType.SceneGallery;
this.scenarioLabel = scenarioLabel;
this.Open();
}
public void OpenStartGame()
{
this.ClearBootData();
this.bootType = BootType.Start;
this.Open();
}
public void OpenStartLabel(string label)
{
this.ClearBootData();
this.bootType = BootType.StartLabel;
this.scenarioLabel = label;
this.Open();
}
private void Update()
{
if (this.isInit)
{
if (SystemUi.GetInstance() != null)
{
if (this.Engine.IsLoading)
{
SystemUi.GetInstance().StartIndicator(this);
}
else
{
SystemUi.GetInstance().StopIndicator(this);
}
}
if (this.Engine.IsEndScenario)
{
this.Close();
if (this.Engine.IsSceneGallery)
{
this.gallery.Open();
}
else
{
this.title.Open(this);
}
}
}
}
private Camera[] CaptureCameras
{
get
{
if (this._captureCameras == null)
{
Camera cachedCamera = null;
Camera camera2 = null;
foreach (Utage.LetterBoxCamera camera3 in Object.FindObjectsOfType<Utage.LetterBoxCamera>())
{
if (camera3.get_gameObject().get_name() == "SpriteCamera")
{
cachedCamera = camera3.CachedCamera;
}
else if (camera3.get_gameObject().get_name() == "UICamera")
{
camera2 = camera3.CachedCamera;
}
}
Camera[] cameraArray3 = new Camera[] { cachedCamera, camera2 };
this._captureCameras = cameraArray3;
}
return this._captureCameras;
}
}
public AdvEngine Engine
{
get
{
if (this.engine == null)
{
}
return (this.engine = Object.FindObjectOfType<AdvEngine>());
}
}
public Utage.LetterBoxCamera LetterBoxCamera
{
get
{
if (this.letterBoxCamera == null)
{
}
return (this.letterBoxCamera = Object.FindObjectOfType<Utage.LetterBoxCamera>());
}
}
[CompilerGenerated]
private sealed class <CoCaptureScreen>c__Iterator1 : IEnumerator, IDisposable, IEnumerator<object>
{
internal object $current;
internal bool $disposing;
internal int $PC;
internal UtageUguiMainGame $this;
[DebuggerHidden]
public void Dispose()
{
this.$disposing = true;
this.$PC = -1;
}
public bool MoveNext()
{
uint num = (uint) this.$PC;
this.$PC = -1;
switch (num)
{
case 0:
this.$current = new WaitForEndOfFrame();
if (!this.$disposing)
{
this.$PC = 1;
}
return true;
case 1:
this.$this.Engine.SaveManager.CaptureTexture = this.$this.CaptureScreen();
this.$PC = -1;
break;
}
return false;
}
[DebuggerHidden]
public void Reset()
{
throw new NotSupportedException();
}
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
}
[CompilerGenerated]
private sealed class <CoQSave>c__Iterator3 : IEnumerator, IDisposable, IEnumerator<object>
{
internal object $current;
internal bool $disposing;
internal int $PC;
internal UtageUguiMainGame $this;
[DebuggerHidden]
public void Dispose()
{
this.$disposing = true;
this.$PC = -1;
}
public bool MoveNext()
{
uint num = (uint) this.$PC;
this.$PC = -1;
switch (num)
{
case 0:
if (this.$this.Engine.SaveManager.Type == AdvSaveManager.SaveType.SavePoint)
{
break;
}
this.$current = new WaitForEndOfFrame();
if (!this.$disposing)
{
this.$PC = 1;
}
return true;
case 1:
this.$this.Engine.SaveManager.CaptureTexture = this.$this.CaptureScreen();
break;
default:
goto Label_00D8;
}
this.$this.Engine.QuickSave();
this.$this.Engine.UiManager.Status = AdvUiManager.UiStatus.Default;
if (this.$this.Engine.SaveManager.Type != AdvSaveManager.SaveType.SavePoint)
{
this.$this.Engine.SaveManager.ClearCaptureTexture();
}
this.$PC = -1;
Label_00D8:
return false;
}
[DebuggerHidden]
public void Reset()
{
throw new NotSupportedException();
}
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
}
[CompilerGenerated]
private sealed class <CoSave>c__Iterator2 : IEnumerator, IDisposable, IEnumerator<object>
{
internal object $current;
internal bool $disposing;
internal int $PC;
internal UtageUguiMainGame $this;
[DebuggerHidden]
public void Dispose()
{
this.$disposing = true;
this.$PC = -1;
}
public bool MoveNext()
{
uint num = (uint) this.$PC;
this.$PC = -1;
switch (num)
{
case 0:
this.$this.Engine.SaveManager.CaptureTexture = this.$this.CaptureScreen();
this.$current = new WaitForEndOfFrame();
if (!this.$disposing)
{
this.$PC = 1;
}
return true;
case 1:
this.$this.Close();
this.$this.saveLoad.OpenSave(this.$this);
this.$PC = -1;
break;
}
return false;
}
[DebuggerHidden]
public void Reset()
{
throw new NotSupportedException();
}
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
}
[CompilerGenerated]
private sealed class <CoWaitOpen>c__Iterator0 : IEnumerator, IDisposable, IEnumerator<object>
{
internal object $current;
internal bool $disposing;
internal int $PC;
internal UtageUguiMainGame $this;
[DebuggerHidden]
public void Dispose()
{
this.$disposing = true;
this.$PC = -1;
}
public bool MoveNext()
{
uint num = (uint) this.$PC;
this.$PC = -1;
switch (num)
{
case 0:
case 1:
if (this.$this.Engine.IsWaitBootLoading)
{
this.$current = null;
if (!this.$disposing)
{
this.$PC = 1;
}
return true;
}
switch (this.$this.bootType)
{
case UtageUguiMainGame.BootType.Default:
this.$this.Engine.UiManager.Open();
goto Label_0110;
case UtageUguiMainGame.BootType.Start:
this.$this.Engine.StartGame();
goto Label_0110;
case UtageUguiMainGame.BootType.Load:
this.$this.Engine.OpenLoadGame(this.$this.loadData);
goto Label_0110;
case UtageUguiMainGame.BootType.SceneGallery:
this.$this.Engine.StartSceneGallery(this.$this.scenarioLabel);
goto Label_0110;
case UtageUguiMainGame.BootType.StartLabel:
this.$this.Engine.StartGame(this.$this.scenarioLabel);
goto Label_0110;
}
break;
default:
goto Label_0150;
}
Label_0110:
this.$this.ClearBootData();
this.$this.loadData = null;
this.$this.Engine.Config.IsSkip = false;
this.$this.isInit = true;
this.$PC = -1;
Label_0150:
return false;
}
[DebuggerHidden]
public void Reset()
{
throw new NotSupportedException();
}
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return this.$current;
}
}
}
private enum BootType
{
Default,
Start,
Load,
SceneGallery,
StartLabel
}
}