-
Notifications
You must be signed in to change notification settings - Fork 0
/
Loading.cs
441 lines (404 loc) · 11.1 KB
/
Loading.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
using UnityEngine;
using System.Collections;
using System;
public class Loading : SSGameMono
{
/// <summary>
/// UI摄像机.
/// </summary>
public UICamera mUICamera;
/// <summary>
/// 加密校验中.
/// </summary>
//public GameObject m_JiaMiJiaoYanZhong;
[HideInInspector]
public SSLedByAudioCtrl mLedAudioScript;
public LogoAnimation mLogoAni;
private string CoinNumSet = "1";
private string InsertCoinNum = "";
public UITexture m_BeginTex;
//public Texture m_LoadingTex;
public UITexture m_InsertTex;
public UISprite CoinNumSetTex;
public UISprite m_InsertNumS;
public UISprite m_InsertNumG;
private int m_InserNum = 0;
private int m_CoinNumSet = 0;
private bool m_IsBeginOk = false;
private float m_PressTimmer = 0.0f;
private float m_InserTimmer = 0.0f;
private bool m_IsStartGame =false;
public AudioSource m_TbSource;
public AudioSource m_BeginSource;
public AudioSource m_LevelSource;
public GameObject m_Loading;
public GameObject m_Tishi;
private string GameMode = "";
public UITexture m_pTishiTexture;
public Texture[] m_pTexture;
//public MovieTexture m_MovieTex;
public UITexture m_FreeTexture;
public GameObject m_ToubiObj;
private bool timmerstar = false;
private float timmerforstar = 0.0f;
public static bool m_HasBegin = false;
public bool IsLuPingTest;
internal SSUICenter m_SSUICenterCom;
void Start ()
{
XKGameVersionCtrl gameVersionCom = gameObject.AddComponent<XKGameVersionCtrl>();
if (gameVersionCom != null)
{
gameVersionCom.Init();
}
if (IsLuPingTest)
{
gameObject.SetActive(false);
}
m_HasBegin = false;
GameMode = ReadGameInfo.GetInstance ().ReadGameStarMode();
if(GameMode == ReadGameInfo.GameMode.Oper.ToString())
{
m_FreeTexture.enabled = false;
CoinNumSet = ReadGameInfo.GetInstance ().ReadStarCoinNumSet();
InsertCoinNum = ReadGameInfo.GetInstance ().ReadInsertCoinNum();
CoinNumSetTex.spriteName = CoinNumSet;
m_InserNum = Convert.ToInt32(InsertCoinNum);
m_CoinNumSet = Convert.ToInt32(CoinNumSet);
UpdateInsertCoin();
UpdateTex();
}
else
{
m_ToubiObj.SetActive(false);
m_FreeTexture.enabled = true;
}
m_Loading.SetActive(false);
InputEventCtrl.GetInstance().mListenPcInputEvent.ClickSetEnterBtEvent += ClickSetEnterBtEvent;
if (GameMode == ReadGameInfo.GameMode.Free.ToString())
{
InputEventCtrl.GetInstance().mListenPcInputEvent.ClickCloseDongGanBtEvent += ClickStartBtOneEvent;
}
else
{
InputEventCtrl.GetInstance().mListenPcInputEvent.ClickTVYaoKongEnterBtEvent += ClickStartBtOneEvent;
InputEventCtrl.GetInstance().mListenPcInputEvent.ClickTVYaoKongExitBtEvent += ClickTVYaoKongExitBtEvent;
}
if (m_InserNum >= m_CoinNumSet && GameMode == ReadGameInfo.GameMode.Oper.ToString())
{
UpdateTex();
//ClickStartBtOneEvent(InputEventCtrl.ButtonState.DOWN); 关闭自动开始游戏.
}
m_SSUICenterCom = gameObject.AddComponent<SSUICenter>();
if (mUICamera != null)
{
m_SSUICenterCom.Init(mUICamera.transform);
}
InputEventCtrl.GetInstance().OnCaiPiaJiChuPiaoEvent += OnCaiPiaJiChuPiaoEvent;
InputEventCtrl.GetInstance().OnCaiPiaJiWuPiaoEvent += OnCaiPiaJiWuPiaoEvent;
}
private void ClickTVYaoKongExitBtEvent(InputEventCtrl.ButtonState val)
{
if (val == InputEventCtrl.ButtonState.UP)
{
if (m_SSUICenterCom != null)
{
m_SSUICenterCom.SpawnExitGameDlg();
}
}
}
void OnCaiPiaJiWuPiaoEvent(pcvrTXManage.CaiPiaoJi val)
{
Debug.Log(val + ":: CaiPiaoJi wuPiao!");
}
void OnCaiPiaJiChuPiaoEvent(pcvrTXManage.CaiPiaoJi val)
{
GlobalData.GetInstance().CaiPiaoCur--;
Debug.Log("CaiPiaoCur == " + GlobalData.GetInstance().CaiPiaoCur);
}
//float m_LastJiaoYanTime = 0f;
void Update ()
{
/*if (m_JiaMiJiaoYanZhong.activeSelf)
{
if (VerifyEnvironmentObj.VerifyIsSucceedShowImg
|| (Time.time - m_LastJiaoYanTime > 8f && GameRoot.m_VerifyEnvironmentObj == null))
{
//隐藏校验中.
SetActiveJiaMiJiaoYan(false);
}
}*/
if (!m_IsStartGame) {
UpdateTex();
}
if (pcvr.bIsHardWare)
{
if (GlobalData.GetInstance().CoinCur != m_InserNum && GameMode == ReadGameInfo.GameMode.Oper.ToString())
{
m_InserNum = GlobalData.GetInstance().CoinCur - 1;
OnClickInsertBt();
}
}
else
{
//if (pcvr.IsTestNoInput)
//{
// return;
//}
//if(Input.GetKeyDown(KeyCode.T) && GameMode == ReadGameInfo.GameMode.Oper.ToString())
//{
// OnClickInsertBt();
//}
}
OnLoadingClicked();
}
void ClickStartBtOneEvent(InputEventCtrl.ButtonState val)
{
if (val == InputEventCtrl.ButtonState.UP)
{
return;
}
if (m_SSUICenterCom != null && m_SSUICenterCom.m_ExitGameUI != null)
{
return;
}
if (m_IsStartGame == true)
{
return;
}
if (mLevelSelectUI == null)
{
SpawnLevelSelectUI();
}
else
{
RemoveLevelSelectUI();
OnClickBeginBt();
}
}
void ClickSetEnterBtEvent(InputEventCtrl.ButtonState val)
{
if (val == InputEventCtrl.ButtonState.UP) {
return;
}
if (m_HasBegin) {
return;
}
XkGameCtrl.IsLoadingLevel = true;
Resources.UnloadUnusedAssets();
GC.Collect();
Application.LoadLevel(6);
}
void UpdateInsertCoin()
{
int n = 1;
int num = m_InserNum;
int temp = num;
while(num > 9)
{
num /= 10;
n++;
}
if(n > 2)
{
m_InsertNumS.spriteName = "9";
m_InsertNumG.spriteName = "9";
}
else if(n==2)
{
int shiwei = (int)(temp/10);
int gewei = (int)(temp-shiwei*10);
m_InsertNumS.spriteName = shiwei.ToString();
m_InsertNumG.spriteName = gewei.ToString();
}
else if(n == 1)
{
m_InsertNumS.spriteName = "0";
m_InsertNumG.spriteName = temp.ToString();
}
}
void UpdateTex()
{
if(GameMode == ReadGameInfo.GameMode.Free.ToString() || m_InserNum >= Convert.ToInt32(CoinNumSet))
{
m_InserTimmer = 0.0f;
m_IsBeginOk = true;
m_InsertTex.enabled = false;
m_BeginTex.enabled =true;
if (m_pTishiTexture.gameObject.activeInHierarchy == true)
{
m_pTishiTexture.enabled = true;
}
m_PressTimmer+=(Time.deltaTime / Time.timeScale);
if(m_PressTimmer >= 0.0f && m_PressTimmer <= 0.5f)
{
m_BeginTex.enabled =true;
if (m_pTishiTexture.gameObject.activeInHierarchy == true)
{
m_pTishiTexture.mainTexture = m_pTexture[0];
}
}
else if(m_PressTimmer > 0.5f && m_PressTimmer <= 1.0f)
{
m_BeginTex.enabled =false;
if (m_pTishiTexture.gameObject.activeInHierarchy == true)
{
m_pTishiTexture.mainTexture = m_pTexture[1];
}
}
else
{
m_PressTimmer = 0.0f;
}
//pcvr.StartBtLight = StartLightState.Shan;
}
else
{
//pcvr.StartBtLight = StartLightState.Mie;
m_InserTimmer+=(Time.deltaTime / Time.timeScale);
m_IsBeginOk = false;
m_InsertTex.enabled = true;
m_BeginTex.enabled =false;
m_pTishiTexture.enabled = false;
m_PressTimmer = 0.0f;
if(m_InserTimmer >= 0.0f && m_InserTimmer <= 0.4f)
{
m_InsertTex.enabled = true;
}
else if(m_InserTimmer > 0.4f && m_InserTimmer <= 0.8f)
{
m_InsertTex.enabled = false;
}
else
{
m_InserTimmer = 0.0f;
}
}
}
IEnumerator loadScene(int num)
{
XkGameCtrl.IsLoadingLevel = true;
Resources.UnloadUnusedAssets();
GC.Collect();
AsyncOperation async = Application.LoadLevelAsync(num);
yield return async;
}
void OnClickInsertBt()
{
m_InserNum++;
m_TbSource.Play();
ReadGameInfo.GetInstance().WriteInsertCoinNum(m_InserNum.ToString());
UpdateInsertCoin();
if (m_InserNum >= m_CoinNumSet)
{
UpdateTex();
ClickStartBtOneEvent(InputEventCtrl.ButtonState.DOWN);
}
}
void OnClickBeginBt()
{
if (PlayerControllerForMoiew.IsLoadMovieLevel) {
return;
}
if(m_IsBeginOk && !m_HasBegin)
{
m_BeginSource.Play();
m_IsStartGame = true;
if(GameMode == ReadGameInfo.GameMode.Oper.ToString())
{
m_InserNum -= Convert.ToInt32(CoinNumSet);
UpdateInsertCoin();
ReadGameInfo.GetInstance().WriteInsertCoinNum(m_InserNum.ToString());
if (pcvr.bIsHardWare) {
pcvr.GetInstance().mPcvrTXManage.SubPlayerCoin(Convert.ToInt32(CoinNumSet), pcvrTXManage.PlayerCoinEnum.player01);
}
}
m_Tishi.SetActive(false);
m_Loading.SetActive(true);
timmerstar = true;
m_HasBegin = true;
}
}
int _mLoadSceneCount = 0;
/// <summary>
/// 加载游戏的关卡信息.
/// </summary>
[HideInInspector]
public int mLoadSceneCount
{
set
{
Debug.Log("Loading -> mLoadSceneCount == " + value);
_mLoadSceneCount = value;
}
get
{
return _mLoadSceneCount;
}
}
//static int LoadSceneCount;
void OnLoadingClicked()
{
if(timmerstar)
{
timmerforstar += Time.deltaTime;
if(timmerforstar > 1.5f)
{
int sceneCount = (mLoadSceneCount % (Application.levelCount - 3)) + 2;
Debug.Log("OnLoadingClicked -> sceneCount =================== " + sceneCount);
StartCoroutine (loadScene(sceneCount));
timmerstar = false;
//LoadSceneCount++;
}
}
}
/*public void SetActiveJiaMiJiaoYan(bool isActive)
{
m_LastJiaoYanTime = Time.time;
m_JiaMiJiaoYanZhong.SetActive(isActive);
}*/
/// <summary>
/// 游戏场景选择控制脚本.
/// </summary>
[HideInInspector]
public LevelSelectUI mLevelSelectUI;
/// <summary>
/// 产生选择游戏场景UI.
/// </summary>
void SpawnLevelSelectUI()
{
if (mUICamera == null)
{
SSDebug.LogWarning("SpawnLevelSelectUI -> mUICamera was null");
return;
}
if (mLevelSelectUI == null)
{
GameObject objPrefab = (GameObject)Resources.Load("Prefab/Gui/LevelSelect/LevelSelect");
if (objPrefab != null)
{
SSDebug.Log("SpawnLevelSelectUI...");
GameObject obj = (GameObject)Instantiate(objPrefab, mUICamera.transform);
mLevelSelectUI = obj.GetComponent<LevelSelectUI>();
mLevelSelectUI.Init(this);
if (m_pTishiTexture != null)
{
m_pTishiTexture.gameObject.SetActive(false);
}
}
else
{
SSDebug.LogWarning("SpawnLevelSelectUI -> objPrefab was null");
}
}
}
void RemoveLevelSelectUI()
{
if (mLevelSelectUI != null)
{
mLevelSelectUI.RemoveSelf();
mLevelSelectUI = null;
Resources.UnloadUnusedAssets();
}
}
}