-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfallingIntroUI.js
74 lines (62 loc) · 2.21 KB
/
fallingIntroUI.js
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
#pragma strict
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);
if (currentIcon) {
currentIcon.hidden = true;
bgIcon.hidden = true;
}
currentIcon = icon;
icon.hidden = false;
bgIcon.hidden = false;
icon.alphaFromTo( 1.0f, 0.0f, 1.0f, Easing.Sinusoidal.easeIn);
if (FallingPlayer.isAlive == 0) {icon.hidden = true; bgIcon.hidden = true; return;}
yield WaitForSeconds (timer/2);
if (FallingPlayer.isAlive == 0) {icon.hidden = true; bgIcon.hidden = true; return;}
yield WaitForSeconds (timer/2);
if (FallingPlayer.isAlive == 0) {icon.hidden = true; bgIcon.hidden = true; return;}
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;}
}
}