@@ -89,6 +89,7 @@ public class HelloARController : MonoBehaviour
89
89
// Settable parameters
90
90
public GameObject prefab ;
91
91
public ParticleSystem boost ;
92
+ public ParticleSystem goalExplosion ;
92
93
public GameObject field ;
93
94
public GameObject ball ;
94
95
public GameObject namePrefab ;
@@ -102,6 +103,7 @@ public class HelloARController : MonoBehaviour
102
103
private GameObject ballObject ;
103
104
private GameObject fieldObject ;
104
105
private GameObject rootObject ;
106
+ private ParticleSystem goalExplosionObject ;
105
107
private float currentTime = 0f ;
106
108
private int currentFrame = 0 ;
107
109
private List < GameObject > cars = new List < GameObject > ( ) ;
@@ -195,6 +197,13 @@ private void Spawn(Vector3 position, Quaternion rotation, Transform parent)
195
197
ballObject . transform . parent = rootObject . transform ;
196
198
ballObject . transform . localPosition = new Vector3 ( 0f , 0f , 0f ) ;
197
199
ballObject . transform . localScale = new Vector3 ( 10 * 1000 / scaleFactor , 10 * 1000 / scaleFactor , 10 * 1000 / scaleFactor ) ;
200
+
201
+ goalExplosionObject = Instantiate ( goalExplosion , new Vector3 ( 0f , 0f , 0f ) , Quaternion . identity ) ;
202
+ goalExplosionObject . transform . parent = rootObject . transform ;
203
+ goalExplosionObject . transform . localScale = new Vector3 ( 4 / scaleFactor , 4 / scaleFactor , 4 / scaleFactor ) ;
204
+ goalExplosionObject . Stop ( ) ;
205
+
206
+
198
207
currentTime = ( float ) gameData . frames [ 0 ] [ 2 ] ;
199
208
}
200
209
@@ -289,7 +298,7 @@ public void Update()
289
298
for ( int i = 0 ; i < cars . Count ; i ++ )
290
299
{
291
300
var frameData = gameData . players [ i ] [ currentFrame ] ;
292
- float x = ( float ) ( double ) frameData [ 0 ] / localScale ;
301
+ float x = - ( float ) ( double ) frameData [ 0 ] / localScale ;
293
302
float y = ( float ) ( double ) frameData [ 2 ] / localScale ;
294
303
float z = ( float ) ( double ) frameData [ 1 ] / localScale ;
295
304
@@ -299,8 +308,8 @@ public void Update()
299
308
var yOffset = ( double ) - 0.25 ;
300
309
var zOffset = ( double ) 0 ;
301
310
var xCoeff = ( double ) 1 ;
302
- var yCoeff = ( double ) - 1 ;
303
- var zCoeff = ( double ) - 1 ;
311
+ var yCoeff = ( double ) 1 ;
312
+ var zCoeff = ( double ) 1 ;
304
313
305
314
var rotX = ( ( double ) frameData [ 3 ] / ( 2 * PI ) + xOffset ) * xCoeff * 360 ; // pitch
306
315
var rotY = ( ( double ) frameData [ 4 ] / ( 2 * PI ) + yOffset ) * yCoeff * 360 ; // yaw
@@ -333,13 +342,26 @@ public void Update()
333
342
names [ i ] . transform . Rotate ( Vector3 . up - new Vector3 ( 0 , 180 , 0 ) ) ;
334
343
}
335
344
336
- float ballx = ( float ) gameData . ball [ currentFrame ] [ 0 ] / localScale ;
345
+ float ballx = - ( float ) gameData . ball [ currentFrame ] [ 0 ] / localScale ;
337
346
float bally = ( float ) gameData . ball [ currentFrame ] [ 2 ] / localScale ;
338
347
float ballz = ( float ) gameData . ball [ currentFrame ] [ 1 ] / localScale ;
339
348
ballObject . transform . localPosition = new Vector3 ( ballx , bally , ballz ) ;
340
349
350
+ // Goal Explosions
351
+
352
+ foreach ( Goal g in StaticReplayScript . proto . gameMetadata . goals )
353
+ {
354
+ if ( g . frameNumber == currentFrame )
355
+ {
356
+ goalExplosionObject . transform . localPosition = new Vector3 ( ballx , bally , ballz ) ;
357
+ goalExplosionObject . Play ( ) ;
358
+ }
359
+ }
360
+
361
+
362
+
341
363
// Time management
342
- currentTime += Time . deltaTime ;
364
+ currentTime += Time . deltaTime ;
343
365
344
366
var currentFrameTime = gameData . frames [ currentFrame ] [ 2 ] ;
345
367
var nextFrameTime = gameData . frames [ currentFrame + 1 ] [ 2 ] ;
@@ -364,38 +386,40 @@ public void OnGUI()
364
386
{
365
387
var width = Screen . width ;
366
388
var height = Screen . height ;
367
- var zoomOut = GUI . Button ( new Rect ( width * 2 / 10 , 25 , width / 25 , width / 25 ) , "-" ) ;
368
- var zoomIn = GUI . Button ( new Rect ( width * 3 / 10 , 25 , width / 25 , width / 25 ) , "+" ) ;
369
- if ( zoomOut )
370
- {
371
- scaleFactor += 100 ;
372
- rootObject . transform . localScale = new Vector3 ( 1 / scaleFactor , 1 / scaleFactor , 1 / scaleFactor ) ;
373
- }
374
- else if ( zoomIn )
375
- {
376
- scaleFactor -= 100 ;
377
- rootObject . transform . localScale = new Vector3 ( 1 / scaleFactor , 1 / scaleFactor , 1 / scaleFactor ) ;
378
- }
389
+
379
390
380
391
381
392
// Scoreboard
382
393
int offset = 100 ;
383
394
Color orange = new Color ( 1F , 0.64F , 0F ) ;
384
395
var halfway = width / 2 ;
385
396
GUIStyle timeStyle = new GUIStyle ( ) ;
386
- timeStyle . fontSize = 30 ;
397
+ timeStyle . fontSize = 40 ;
387
398
timeStyle . fontStyle = FontStyle . Bold ;
388
399
389
400
timeStyle . normal . textColor = Color . gray ;
390
401
timeStyle . alignment = TextAnchor . MiddleCenter ;
402
+
403
+
404
+
405
+
391
406
int timeRemaining = 300 ;
392
407
if ( StaticReplayScript . gameData != null )
393
408
{
394
409
timeRemaining = ( int ) StaticReplayScript . gameData . frames [ currentFrame ] [ 1 ] ;
395
410
}
396
411
//int timeRemaining = 175;
397
412
int minRemaining = timeRemaining / 60 ;
398
- GUI . Label ( new Rect ( halfway , 35 , 50 , 50 ) , String . Format ( "{0}:{1:D2}" , minRemaining , timeRemaining % ( minRemaining * 60 ) ) , timeStyle ) ;
413
+ int secondsRemaining ;
414
+ if ( minRemaining > 0 )
415
+ {
416
+ secondsRemaining = timeRemaining % ( minRemaining * 60 ) ;
417
+ }
418
+ else
419
+ {
420
+ secondsRemaining = timeRemaining ;
421
+ }
422
+ GUI . Label ( new Rect ( halfway , 35 , 50 , 50 ) , String . Format ( "{0}:{1:D2}" , minRemaining , secondsRemaining ) , timeStyle ) ;
399
423
400
424
401
425
var team0Score = 0 ;
@@ -429,7 +453,7 @@ public void OnGUI()
429
453
430
454
GUIStyle style = new GUIStyle ( ) ;
431
455
///style.font = new Font("Liberation Sans");
432
- style . fontSize = 30 ;
456
+ style . fontSize = 40 ;
433
457
style . fontStyle = FontStyle . Bold ;
434
458
435
459
style . normal . textColor = Color . white ;
@@ -447,6 +471,12 @@ public void OnGUI()
447
471
Proto proto = StaticReplayScript . proto ;
448
472
if ( gameData != null && proto != null && fieldObject != null )
449
473
{
474
+ // Slider Styling
475
+ GUIStyle thumbStyle = new GUIStyle ( GUI . skin . horizontalSliderThumb ) ;
476
+ GUIStyle sliderStyle = new GUIStyle ( GUI . skin . horizontalSlider ) ;
477
+ sliderStyle . padding = new RectOffset ( width / 10 , width / 10 , width / 10 , width / 10 ) ;
478
+
479
+
450
480
var logoWidth = width / 60 ;
451
481
var nextFrame = ( int ) GUI . HorizontalSlider ( new Rect ( 0 , 19 / 20f * height , width , height / 20f ) , currentFrame , 0 , gameData . frames . Count ) ;
452
482
if ( nextFrame != currentFrame )
@@ -473,14 +503,29 @@ public void OnGUI()
473
503
}
474
504
}
475
505
506
+ GUIStyle buttonStyle = new GUIStyle ( GUI . skin . button ) ;
476
507
508
+ buttonStyle . fontSize = 30 ;
477
509
// Button
478
- var back = GUI . Button ( new Rect ( 25 , 25 , width / 10 , width / 25 ) , "Back to Menu" ) ;
510
+ var back = GUI . Button ( new Rect ( 25 , 25 , width / 10 , width / 25 ) , "Back to Menu" , buttonStyle ) ;
479
511
if ( back )
480
512
{
481
513
SceneManager . LoadScene ( "Menu" ) ;
482
514
}
483
515
516
+ var zoomOut = GUI . Button ( new Rect ( width * 2 / 10 , 25 , width / 25 , width / 25 ) , "-" , buttonStyle ) ;
517
+ var zoomIn = GUI . Button ( new Rect ( width * 3 / 10 , 25 , width / 25 , width / 25 ) , "+" , buttonStyle ) ;
518
+ if ( zoomOut )
519
+ {
520
+ scaleFactor += 100 ;
521
+ rootObject . transform . localScale = new Vector3 ( 1 / scaleFactor , 1 / scaleFactor , 1 / scaleFactor ) ;
522
+ }
523
+ else if ( zoomIn )
524
+ {
525
+ scaleFactor -= 100 ;
526
+ rootObject . transform . localScale = new Vector3 ( 1 / scaleFactor , 1 / scaleFactor , 1 / scaleFactor ) ;
527
+ }
528
+
484
529
485
530
if ( dataMsg != null )
486
531
{
0 commit comments