-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogicControl.cs
More file actions
executable file
·220 lines (182 loc) · 4.89 KB
/
Copy pathLogicControl.cs
File metadata and controls
executable file
·220 lines (182 loc) · 4.89 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
using UnityEngine;
using System.Collections;
public class LogicControl : MonoBehaviour {
public GameObject WholeMediaHub;
public GameObject AnimatedBuilding;
public GameObject StaticBuilding;
public GameObject ARCamera;
public GameObject RestartBtn;
public GameObject PhotoBtn;
public GameObject LoseTrackTexture;
public AudioClip AmbientClip;
//public Light Light_Flare;
public GameObject Light_Flare;
public bool StartAnimation;
private bool tempStartStatus;
public bool showStatic;
private bool tempAnimationStatus;
//private Animation anim;
// Use this for initialization
public bool TrackingStatus = false; //only set to false from beginning
private bool tempTrackingStatus;
public bool TriggerReset;
void Start () {
Reset();
}
// Update is called once per frame
void Update () {
if(Application.platform == RuntimePlatform.Android)
{
if (Input.GetKey(KeyCode.Home) || Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.Menu))
{
Application.Quit();
return;
}
}
if(TriggerReset == true)
{
Reset();
}
/*
if (Input.GetMouseButtonDown(0))
{
RaycastHit hitInfo = new RaycastHit();
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo))
{
string hitTarget = hitInfo.transform.gameObject.tag;
Debug.Log ("Hit "+hitTarget);
CheckHitTarget(hitTarget);
}
}
if(Input.touches.Length > 0)
{
RaycastHit hitTouch = new RaycastHit();
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.touches[0].position), out hitTouch))
{
string hitTarget = hitTouch.transform.gameObject.tag;
Debug.Log ("Hit "+hitTarget);
CheckHitTarget(hitTarget);
}
}
*/
if(StartAnimation != tempStartStatus)
{
if(StartAnimation == true)
{
tempStartStatus = StartAnimation;
StaticBuilding.SetActive(false);
Light_Flare.SetActive(true);
Light_Flare.GetComponent<Animation>().Play("LightAnimation_2");
AnimatedBuilding.SetActive(true);
//RestartBtn.GetComponent<UIButton>().onClick();
//anim.Play();
}
else
{
tempStartStatus = StartAnimation;
StaticBuilding.SetActive(true);
//Light_Flare.enabled = false;
AnimatedBuilding.SetActive(false);
//anim.Stop();
/*
audio.clip = AmbientClip;
audio.loop = true;
audio.Play();
*/
//Fade in floor and tree
WholeMediaHub.GetComponent<Animation>().Play("FadeInFloorTree");
}
}
/*
if(showStatic != tempAnimationStatus)
{
if(showStatic == true)
{
tempAnimationStatus = showStatic;
AnimatedBuilding.SetActive(false);
StaticBuilding.SetActive(true);
//Light_Flare.enabled = false;
//ARCamera.GetComponent<UI>().ShowResetBtn = true;
//NGUITools.SetActive(ResetBtn, true);
}
}
*/
if(TrackingStatus != tempTrackingStatus)
{
if(TrackingStatus == true) //Tracking
{
tempTrackingStatus = TrackingStatus;
//Show Restart Btns
NGUITools.SetActive(RestartBtn, true);
LoseTrackTexture.GetComponent<UIPlayTween>().Play(false);
if(StartAnimation == false) //If animation has not started yet
{
if(showStatic == false)
{
Light_Flare.SetActive(true);
Light_Flare.GetComponent<Animation>().Play("LightAnimation_1");
}
//Show TakePhoto button
NGUITools.SetActive(PhotoBtn, true);
//Play Music (Ambient)
audio.clip = AmbientClip;
audio.loop = true;
audio.Play();
}
}
else //Lose Tracking
{
tempTrackingStatus = TrackingStatus;
Light_Flare.SetActive(false); //.enabled = false;
//Hide Btns
NGUITools.SetActive(RestartBtn, false);
NGUITools.SetActive(PhotoBtn, false);
//Enable noise
//ARCamera.GetComponent<NoiseEffect>().enabled = true;
LoseTrackTexture.GetComponent<UIPlayTween>().Play(true);
if(StartAnimation == false)
{
//Pause Music (Ambient)
audio.Pause();
}
}
}
}
/*
void CheckHitTarget(string hitTarget)
{
switch (hitTarget)
{
case "Floor":
{ //StartAnimation = true;
//RestartBtn.GetComponent<UIButton>().onClick; // GetComponent<UIPlayTween>().Play(true);
break;
}
}
}*/
void Reset()
{
StartAnimation = tempStartStatus = showStatic = tempAnimationStatus = false;
tempTrackingStatus = true;
AnimatedBuilding.SetActive(false);
//anim = AnimatedBuilding.GetComponent<Animation>();
StaticBuilding.SetActive(false);
/*
if(TrackingStatus == true)
Light_Flare.enabled = true;
else
Light_Flare.enabled = false;
*/
//Turn on the light flare
Light_Flare.SetActive(true);// .enabled = true;
Light_Flare.GetComponent<Animation>().Play("LightAnimation_1");
TriggerReset = false;
//ARCamera.GetComponent<UI>().ShowResetBtn = false;
//NGUITools.SetActive(ResetBtn, false);
}
void OnApplicationPause()
{
Application.Quit();
return;
}
}