From 3bd4761cfe845b028300ed7a67c315f564695368 Mon Sep 17 00:00:00 2001 From: tyson-kubota Date: Tue, 7 Nov 2017 23:28:49 -0800 Subject: [PATCH] Tutorial UI in VR mode --- FallingLaunch.js | 2 +- FallingPlayer.js | 13 ++++++++--- IntroSequence1stPerson.js | 18 +++++++++------ IntroUITrigger.js | 19 +++++++++++----- fallingIntroUI.js | 48 ++++++++++++++++++++++++++++++++++++++- lifeCountdown.js | 14 ++++++++---- 6 files changed, 92 insertions(+), 22 deletions(-) diff --git a/FallingLaunch.js b/FallingLaunch.js index 518c0d9..23ff5f6 100644 --- a/FallingLaunch.js +++ b/FallingLaunch.js @@ -60,7 +60,7 @@ function Awake () { function Start () { - + // PlayerPrefs.DeleteAll(); if (!alreadyLaunched) { // TestFlightUnity.TestFlight.TakeOff( testFlightToken ); diff --git a/FallingPlayer.js b/FallingPlayer.js index 9463e59..6ec39a4 100644 --- a/FallingPlayer.js +++ b/FallingPlayer.js @@ -84,12 +84,12 @@ private var scoreUIVRMatl : Material; private var peakScoreFlashValueVR : float = 1.0; var reticleVRUIObj : GameObject; -private var reticleVRUIScript : VRLifeMeter; +static var reticleVRUIScript : VRLifeMeter; var clearDestroyedObjects : boolean = false; var whiteFader : FadeInOutAlt; -var introComponent : IntroSequence1stPerson; +private var introComponent : IntroSequence1stPerson; introComponent = GetComponent("IntroSequence1stPerson"); var simpleVelocityLimiterComponent : SimpleVelocityLimiter; @@ -180,7 +180,6 @@ function Start() { Debug.LogError("You forgot to assign an object for the VR reticle... trying to look up manually"); reticleVRUIScript = GameObject.Find("vr-radial-life-meter").GetComponent.(); } - reticleVRUIScript.FadeReticleIn(1.5); } // startingFogColor = RenderSettings.fogColor * 2; @@ -212,8 +211,16 @@ function Start() { rb.isKinematic = false; } + // introComponent's existence is a proxy for level 1, + // where we don't want the reticle to be visible yet + // (resuming from a level 1 post-intro checkpoint + // is handled in Respawn.js (mainRespawnScript): if (!introComponent) { UIscriptComponent.UnhideGUI(); + + if (FallingLaunch.isVRMode) { + reticleVRUIScript.FadeReticleIn(1.5); + } } LevelStartFade(); diff --git a/IntroSequence1stPerson.js b/IntroSequence1stPerson.js index 794641c..9682777 100644 --- a/IntroSequence1stPerson.js +++ b/IntroSequence1stPerson.js @@ -15,6 +15,7 @@ function Start () { if (!FallingLaunch.NewGamePlus) { PlayerController.enabled = false; ScoreController.enabled = false; + if (!FallingLaunch.isVRMode) { FallingPlayer.UIscriptComponent.HideGUI(); } @@ -27,16 +28,15 @@ function Start () { destructible.enabled = false; shardColor = shardRenderer.material.color; } - } - else if (FallingLaunch.NewGamePlus) { + } else if (FallingLaunch.NewGamePlus) { PlayerController.enabled = true; ScoreController.enabled = true; LifeController.enabled = true; - //FallingPlayer.UIscriptComponent.HideGUI(); - FallingPlayer.UIscriptComponent.UnhideGUI(); - } - + if (!FallingLaunch.isVRMode) { + FallingPlayer.UIscriptComponent.UnhideGUI(); + } + } } function EndIntro (playAudio : boolean) { @@ -48,6 +48,10 @@ function EndIntro (playAudio : boolean) { FallingPlayer.UIscriptComponent.UnhideGUI(); } + if (FallingLaunch.isVRMode) { + FallingPlayer.reticleVRUIScript.FadeReticleIn(1.5); + } + for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) { destructible = shard.GetComponent(ProjectileDestroy); shard.GetComponent.().isKinematic = false; @@ -69,7 +73,7 @@ function EndIntro (playAudio : boolean) { for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) shard.GetComponent.().material.color = Color.Lerp(start, end, i); yield; - } + } } function DeathHelp() { diff --git a/IntroUITrigger.js b/IntroUITrigger.js index dbb7fe7..5751f5a 100644 --- a/IntroUITrigger.js +++ b/IntroUITrigger.js @@ -7,13 +7,14 @@ var fallingUI : GameObject; static var fallingUIComponent : fallingUITest; enum Triggers { -trigger1, -trigger2, -trigger3 + trigger1, + trigger2, + trigger3 }; var helpIcon: UISprite; var thisIcon : String; +var iconNameVR : String; var thisTimer : float = 8; var thisTrigger : Triggers; var tutorialSprite : UISprite; @@ -61,7 +62,7 @@ function Start () { helpIcon.pixelsFromBottom(textHeight); helpIcon.hidden = true; - + audioSource = GetComponent.(); } @@ -69,8 +70,12 @@ function Start () { function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player") && activeIntro == false && FallingLaunch.NewGamePlus == false) { activeIntro = true; - fallingIntroUIComponent.ShowIcon(helpIcon, thisTimer, tutorialSprite); - tutorialSpritePosition(thisTimer); + if (FallingLaunch.isVRMode) { + fallingIntroUIComponent.ShowIconVR(iconNameVR, thisTimer); + } else { + fallingIntroUIComponent.ShowIcon(helpIcon, thisTimer, tutorialSprite); + tutorialSpritePosition(thisTimer); + } if (audioSource) {audioSource.Play();} } } @@ -93,6 +98,8 @@ function tutorialSpritePosition(timer : float) { } function ShowHelpAfterDeath() { + if (!FallingLaunch.isVRMode) { fallingIntroUIComponent.ShowIcon(helpIcon, 2, tutorialSprite); tutorialSpritePosition(2); + } } \ No newline at end of file diff --git a/fallingIntroUI.js b/fallingIntroUI.js index eae4e05..e22a29b 100644 --- a/fallingIntroUI.js +++ b/fallingIntroUI.js @@ -2,9 +2,13 @@ var scriptName : GameObject; static var currentIcon : UISprite; +private var tutorialObjVR : GameObject; +private var iconVRMatl : Material; +private var iconVRRenderer : Renderer; function Start () { - } + tutorialObjVR = gameObject.Find("tutorial-vr-ui-group"); +} function ShowIcon(icon : UISprite, timer : float, bgIcon : UISprite) { // tutorialSpritePosition(timer); @@ -25,4 +29,46 @@ function ShowIcon(icon : UISprite, timer : float, bgIcon : UISprite) { icon.alphaTo( 2.0f, 0.0f, Easing.Sinusoidal.easeOut); yield WaitForSeconds (2); icon.hidden = true; +} + +function ShowIconVR(iconName : String, timer : float) { + // TODO: Improve perf by grabbing and caching these in Start? + // find corresponding gameObject in children: + // Debug.Log("Showing " + iconName); + var thisIcon : GameObject = tutorialObjVR.transform.Find(iconName).gameObject; + + if (thisIcon) { + thisIcon.SetActive(true); + iconVRRenderer = thisIcon.GetComponent.(); + iconVRMatl = iconVRRenderer.material; + // iconVRMatl.color.a = 1; + FadeIconVR(timer/4, FadeDir.In); + + yield WaitForSeconds (timer/2); + if (FallingPlayer.isAlive == 0) { + iconVRMatl.color.a = 0; thisIcon.SetActive(false); return; + } + yield WaitForSeconds (timer/4); + + FadeIconVR(timer/4, FadeDir.Out); + + yield WaitForSeconds (timer/4); + // iconVRMatl.color.a = 0; + thisIcon.SetActive(false); + } +} + +function FadeIconVR (timer : float, fadeType : FadeDir) { + + var start = fadeType == FadeDir.In ? 0.0 : 0.8; + var end = fadeType == FadeDir.In ? 0.8 : 0.0; + var i = 0.0; + var step = 1.0/timer; + + while (i <= 1.0) { + i += step * Time.deltaTime; + iconVRMatl.color.a = Mathf.Lerp(start, end, i); + yield; + if (FallingPlayer.isAlive == 0) {iconVRMatl.color.a = 0.0; break;} + } } \ No newline at end of file diff --git a/lifeCountdown.js b/lifeCountdown.js index d26e496..ecb6d84 100644 --- a/lifeCountdown.js +++ b/lifeCountdown.js @@ -1,13 +1,15 @@ -var script : ScoreController; +private var script : ScoreController; var LifeFlashTexture : GameObject; static var LifeFlashTextureScript : GUITextureLaunch; LifeFlashTextureScript = LifeFlashTexture.GetComponent("GUITextureLaunch"); var lifeFlashUIVR : GameObject; -var lifeFlashUIRenderer : Renderer; -var lifeFlashUIMatl : Material; -var peakLifeFlashValueVR : float = 0.33; +private var lifeFlashUIRenderer : Renderer; +private var lifeFlashUIMatl : Material; +private var peakLifeFlashValueVR : float = 0.7; + +var fallingIntroUIComponent : fallingIntroUI; static var inOutro : boolean = false; @@ -110,6 +112,10 @@ function TickingAway (delay : float) { if (!FallingLaunch.isVRMode) { GetComponent(FallingPlayer).ShowDeathHelp(); + } else if (fallingIntroUIComponent) { + // fallingIntroUIComponent only exists on intro level: + // 'tutorial-vr-intro-2' is the name of the 'gather orbs to survive' icon + fallingIntroUIComponent.ShowIconVR('tutorial-vr-intro-2', 8); } // New GameAnalytics "Design" event syntax: