@@ -64,7 +64,7 @@ private void Awake()
64
64
65
65
instance = this ;
66
66
DontDestroyOnLoad ( gameObject ) ; //ne pas supprimer un objet quand on change de scene
67
-
67
+
68
68
potions = new int [ , ] { { 10 , 10 , 10 } , { 10 , 10 , 10 } } ;
69
69
hearths = new int [ ] { 0 , 0 } ;
70
70
}
@@ -94,7 +94,10 @@ private void Update()
94
94
}
95
95
}
96
96
97
- if ( PhotonNetwork . IsMasterClient && SceneManager . GetActiveScene ( ) . name != "FinalScene" ) //cheat code
97
+
98
+ if ( PhotonNetwork . IsMasterClient &&
99
+ ( ( PhotonNetwork . CurrentRoom . Name . Length >= 5 && PhotonNetwork . CurrentRoom . Name . Substring ( 0 , 5 ) == "debug" ) || PhotonNetwork . CurrentRoom . Name == "t" )
100
+ && SceneManager . GetActiveScene ( ) . name != "FinalScene" ) //cheat code
98
101
{
99
102
if ( Input . GetKeyDown ( KeyCode . M ) ) //go to main room
100
103
{
@@ -125,23 +128,34 @@ private void Update()
125
128
}
126
129
else if ( Input . GetKeyDown ( KeyCode . A ) || Input . GetKeyDown ( KeyCode . Alpha2 ) )
127
130
{
128
- LoadNextArrows ( ) ;
131
+ GoBackToOneLevel ( Scenes [ "Arrows" ] ) ;
132
+ PhotonNetwork . LoadLevel ( "Loading" ) ; //load scene load
133
+ Invoke ( "LoadNextArrows" , 0.5f ) ;
134
+
129
135
}
130
136
else if ( Input . GetKeyDown ( KeyCode . C ) || Input . GetKeyDown ( KeyCode . Alpha3 ) )
131
137
{
132
- LoadNextCrate ( ) ;
138
+ GoBackToOneLevel ( Scenes [ "Crate" ] ) ;
139
+ PhotonNetwork . LoadLevel ( "Loading" ) ; //load scene load
140
+ Invoke ( "LoadNextCrate" , 0.5f ) ;
133
141
}
134
142
else if ( Input . GetKeyDown ( KeyCode . W ) || Input . GetKeyDown ( KeyCode . Alpha4 ) )
135
143
{
136
- LoadNextWires ( ) ;
144
+ GoBackToOneLevel ( Scenes [ "Wires" ] ) ;
145
+ PhotonNetwork . LoadLevel ( "Loading" ) ; //load scene load
146
+ Invoke ( "LoadNextWires" , 0.5f ) ;
137
147
}
138
148
else if ( Input . GetKeyDown ( KeyCode . L ) || Input . GetKeyDown ( KeyCode . Alpha5 ) )
139
149
{
140
- LoadNextLabyInvi ( ) ;
150
+ GoBackToOneLevel ( Scenes [ "LabyInvisible" ] ) ;
151
+ PhotonNetwork . LoadLevel ( "Loading" ) ; //load scene load
152
+ Invoke ( "LoadNextLaby" , 0.5f ) ;
141
153
}
142
154
else if ( Input . GetKeyDown ( KeyCode . P ) || Input . GetKeyDown ( KeyCode . Alpha6 ) )
143
155
{
144
- LoadNextPipe ( ) ;
156
+ GoBackToOneLevel ( Scenes [ "Pipe" ] ) ;
157
+ PhotonNetwork . LoadLevel ( "Loading" ) ; //load scene load
158
+ Invoke ( "LoadNextPipe" , 0.5f ) ;
145
159
}
146
160
}
147
161
}
@@ -186,7 +200,8 @@ public bool LoadData()
186
200
187
201
}
188
202
189
- public void ContinueGame ( ) {
203
+ public void ContinueGame ( )
204
+ {
190
205
if ( LoadData ( ) ) //if could load prev game
191
206
{
192
207
continuePrevGame = true ;
@@ -238,9 +253,9 @@ public void DoorUpdate(int increment, bool doubleD)
238
253
{
239
254
if ( PhotonNetwork . IsMasterClient )
240
255
{
241
- Debug . Log ( "door update; incremnet: " + increment + "; dooractivated: " + increment + doorActivated ) ;
256
+ Debug . Log ( "door update; incremnet: " + increment + "; dooractivated: " + increment + doorActivated ) ;
242
257
doorActivated += increment ; //number of pressure pressed
243
- if ( ( doubleD && doorActivated >= 2 ) || ( ! doubleD && doorActivated >= 1 ) ) //test is good number is pressed based on type of door
258
+ if ( ( doubleD && doorActivated >= 2 ) || ( ! doubleD && doorActivated >= 1 ) ) //test is good number is pressed based on type of door
244
259
{
245
260
if ( IsLevelCompleted ( ) )
246
261
{
@@ -285,7 +300,7 @@ private bool IsLevelCompleted()
285
300
public void LoadNextScene ( )
286
301
{
287
302
Debug . Log ( "next scene" ) ;
288
-
303
+
289
304
Debug . Log ( sceneName ) ;
290
305
if ( NextScene != null )
291
306
{
@@ -320,7 +335,10 @@ public void LoadNextScene()
320
335
case "Wires" :
321
336
LoadNextWires ( ) ;
322
337
break ;
323
- default : //LabyInvisible Donjon
338
+ case "LabyInvisible" :
339
+ LoadNextLabyInvi ( ) ;
340
+ break ;
341
+ default : //Donjon
324
342
PhotonNetwork . LoadLevel ( Scenes [ NextSceneDoor ] ) ;
325
343
break ;
326
344
}
@@ -344,13 +362,13 @@ public void LoadNextScene()
344
362
private int PipeIndex = 0 ;
345
363
private void LoadNextPipe ( )
346
364
{
347
- if ( PipeIndex == 0 ) //tutos
365
+ if ( PipeIndex == 0 ) //tutos
348
366
{
349
367
PhotonNetwork . LoadLevel ( Scenes [ "Pipe" ] ) ; //load scene pipe
350
368
Invoke ( "SubNextPipe" , 0.5f ) ;
351
369
352
370
}
353
- else if ( PipeIndex <= 4 ) //3 levels after
371
+ else if ( PipeIndex <= 4 ) //3 levels after
354
372
{
355
373
PhotonNetwork . LoadLevel ( Scenes [ "Pipe" ] ) ; //load scene pipe
356
374
Invoke ( "SubNextPipe" , 0.5f ) ;
@@ -388,7 +406,7 @@ private void SubNextPipe()
388
406
private void LoadNextCrate ( )
389
407
{
390
408
Debug . Log ( "load next crate" ) ;
391
- if ( CrateIndex < ListCrate . Length )
409
+ if ( CrateIndex < ListCrate . Length )
392
410
{
393
411
PhotonNetwork . LoadLevel ( Scenes [ "Crate" ] ) ; //load scene crate
394
412
Invoke ( "SubNextCrate" , 0.5f ) ;
@@ -421,8 +439,8 @@ private void SubNextCrate()
421
439
private int ArrowIndex = 0 ;
422
440
private void LoadNextArrows ( )
423
441
{
424
-
425
- if ( ArrowIndex <= 2 )
442
+
443
+ if ( ArrowIndex <= 2 )
426
444
{
427
445
PhotonNetwork . LoadLevel ( Scenes [ "Arrows" ] ) ;
428
446
Invoke ( "LoadArrows" , 0.5f ) ;
@@ -452,13 +470,13 @@ private void LoadArrows()
452
470
private int WiresIndex = 0 ;
453
471
private void LoadNextWires ( )
454
472
{
455
- if ( WiresIndex == 0 ) //tutos
473
+ if ( WiresIndex == 0 ) //tutos
456
474
{
457
475
PhotonNetwork . LoadLevel ( Scenes [ "Wires" ] ) ;
458
476
Invoke ( "LoadWires" , 0.5f ) ;
459
477
WiresIndex ++ ;
460
478
}
461
- else if ( WiresIndex < 2 )
479
+ else if ( WiresIndex < 2 )
462
480
{
463
481
PhotonNetwork . LoadLevel ( Scenes [ "Wires" ] ) ;
464
482
WiresIndex ++ ;
@@ -483,8 +501,8 @@ private void LoadNextLabyInvi()
483
501
{
484
502
if ( LabyInviIndex < 2 )
485
503
{
486
- LabyInviIndex ++ ;
487
504
PhotonNetwork . LoadLevel ( Scenes [ "LabyInvisible" ] ) ;
505
+ LabyInviIndex ++ ;
488
506
}
489
507
else
490
508
{
@@ -495,14 +513,15 @@ private void LoadNextLabyInvi()
495
513
496
514
}
497
515
498
- private void GoBackToOneLevel ( )
516
+ private void GoBackToOneLevel ( string scene = "" )
499
517
{
518
+ string testScene = scene == "" ? sceneName : scene ;
500
519
//remove one level from the scene exited preventing skipping levels
501
- if ( sceneName == Scenes [ "Crate" ] ) CrateIndex = CrateIndex > 0 ? CrateIndex - 1 : CrateIndex ;
502
- else if ( sceneName == Scenes [ "Pipe" ] ) PipeIndex = PipeIndex > 0 ? PipeIndex - 1 : PipeIndex ;
503
- else if ( sceneName == Scenes [ "Arrows" ] ) ArrowIndex = ArrowIndex > 0 ? ArrowIndex - 1 : ArrowIndex ;
504
- else if ( sceneName == Scenes [ "Wires" ] ) WiresIndex = WiresIndex > 0 ? WiresIndex - 1 : WiresIndex ;
505
- else if ( sceneName == Scenes [ "LabyInvisible" ] ) LabyInviIndex = LabyInviIndex > 0 ? LabyInviIndex - 1 : LabyInviIndex ;
520
+ if ( testScene == Scenes [ "Crate" ] ) CrateIndex = CrateIndex > 0 ? CrateIndex - 1 : CrateIndex ;
521
+ else if ( testScene == Scenes [ "Pipe" ] ) PipeIndex = PipeIndex > 0 ? PipeIndex - 1 : PipeIndex ;
522
+ else if ( testScene == Scenes [ "Arrows" ] ) ArrowIndex = ArrowIndex > 0 ? ArrowIndex - 1 : ArrowIndex ;
523
+ else if ( testScene == Scenes [ "Wires" ] ) WiresIndex = WiresIndex > 0 ? WiresIndex - 1 : WiresIndex ;
524
+ else if ( testScene == Scenes [ "LabyInvisible" ] ) LabyInviIndex = LabyInviIndex > 0 ? LabyInviIndex - 1 : LabyInviIndex ;
506
525
}
507
526
508
527
public void GoBackToLobby ( )
0 commit comments