Skip to content

Commit

Permalink
Tutorial UI in VR mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tyson-kubota committed Nov 8, 2017
1 parent 28466de commit 3bd4761
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 22 deletions.
2 changes: 1 addition & 1 deletion FallingLaunch.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function Awake () {

function Start () {


// PlayerPrefs.DeleteAll();
if (!alreadyLaunched) {

// TestFlightUnity.TestFlight.TakeOff( testFlightToken );
Expand Down
13 changes: 10 additions & 3 deletions FallingPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.<VRLifeMeter>();
}
reticleVRUIScript.FadeReticleIn(1.5);
}

// startingFogColor = RenderSettings.fogColor * 2;
Expand Down Expand Up @@ -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();
Expand Down
18 changes: 11 additions & 7 deletions IntroSequence1stPerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function Start () {
if (!FallingLaunch.NewGamePlus) {
PlayerController.enabled = false;
ScoreController.enabled = false;

if (!FallingLaunch.isVRMode) {
FallingPlayer.UIscriptComponent.HideGUI();
}
Expand All @@ -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) {
Expand All @@ -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.<Rigidbody>().isKinematic = false;
Expand All @@ -69,7 +73,7 @@ function EndIntro (playAudio : boolean) {
for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard"))
shard.GetComponent.<Renderer>().material.color = Color.Lerp(start, end, i);
yield;
}
}
}

function DeathHelp() {
Expand Down
19 changes: 13 additions & 6 deletions IntroUITrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,16 +62,20 @@ function Start () {

helpIcon.pixelsFromBottom(textHeight);
helpIcon.hidden = true;

audioSource = GetComponent.<AudioSource>();

}

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();}
}
}
Expand All @@ -93,6 +98,8 @@ function tutorialSpritePosition(timer : float) {
}

function ShowHelpAfterDeath() {
if (!FallingLaunch.isVRMode) {
fallingIntroUIComponent.ShowIcon(helpIcon, 2, tutorialSprite);
tutorialSpritePosition(2);
}
}
48 changes: 47 additions & 1 deletion fallingIntroUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.<Renderer>();
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;}
}
}
14 changes: 10 additions & 4 deletions lifeCountdown.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3bd4761

Please sign in to comment.