-
Notifications
You must be signed in to change notification settings - Fork 1
/
scriptForPlane.js
executable file
·231 lines (176 loc) · 3.99 KB
/
scriptForPlane.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
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
221
222
223
224
225
226
227
228
229
230
#pragma strict
/*
*Creation : 26/04/2013
*Author : Fabien Daoulas
*Last update : 29/04/2013
number of lines : 230
*/
import System.IO;
/********************** VARIABLES **********************/
// name of the plane to which this script is attached to
private var Name : String;
// hashtable containing informations about interface
private var HT : Hashtable;
// position of plane in world
private var posPlane : Vector3;
// rotation of plane in world
private var rotPlane : Vector3;
// Point vers lequel est orienté le plan
private var orientedTo : Vector3 ;
// speed of plane
private var deltaX : float = 0;
private var deltaY : float = 0;
private var deltaZ : float = 0;
// plan is visible
private var visible : boolean ;
// Time when the object have been moved last
private var lastMoveTime : float = 0;
private var beginTime : float ;
private var endTime : float ;
// gestionnaire des fichiers
private var datasHandler : dataFolderHandler ;
/********************** METHODS **********************/
/*
*init script attached to each plane
*/
function InitScript( t : Hashtable ){
// init name, hashtable, position
if( t.ContainsKey( 'name' ) )
InitName( t['name'] );
InitHT( t );
if( t.ContainsKey( 'speed' ) )
InitDelta( 'y', float.Parse( t['speed']+'' ) );
if( t.ContainsKey( 'deltax' ) )
InitDelta( 'x', float.Parse( t['deltax']+'' ) );
if( t.ContainsKey( 'deltay' ) )
InitDelta( 'y', float.Parse( t['deltay']+'' ) );
if( t.ContainsKey( 'deltaz' ) )
InitDelta( 'z', float.Parse( t['deltaz']+'' ) );
if( t.ContainsKey( 'begint' ) )
beginTime = float.Parse( t['begint']+'' ) ;
else
beginTime = -1 ;
if( t.ContainsKey( 'endt' ) )
endTime = float.Parse( t['endt']+'' ) ;
else
endTime = -1 ;
// Initialisatiion du gestionnaire de l'architecture de fichier
datasHandler = gameObject.GetComponent("dataFolderHandler") as dataFolderHandler ;
if( ! datasHandler )
datasHandler = gameObject.AddComponent("dataFolderHandler") as dataFolderHandler ;
if( !HT.Contains('gui') )
HT['gui'] = null ;
datasHandler.Init( HT['gui'], Name );
}
public function getHandler() {
return datasHandler ;
}
/*
*initialize variable Name
*/
public function InitName( s : String ){
Name = s;
}
/*
*get Name
*/
public function getName(){
return Name;
}
/*
*initialize hashtable
*/
public function InitHT( t : Hashtable ){
HT = t;
}
/*
*get hashtable
*/
public function getHT(){
return HT;
}
/*
*initialize posPlane
*/
public function InitPosPlane( v : Vector3 ){
posPlane = v;
}
/*
*get position of plane in the wordl coordinates
*/
public function getPosPlane(){
return posPlane;
}
/*
*initialize posPlane
*/
public function InitRotPlane( v : Vector3 ){
rotPlane = v;
}
/*
*get rotation of plane in the wordl coordinates
*/
public function getRotPlane(){
return rotPlane;
}
/*
*initialize orientedTo
*/
public function InitOrientedTo( v : Vector3 ){
orientedTo = v;
}
/*
*get the point where the plane is oriented to
*/
public function getOrientedTo(){
return orientedTo;
}
/*
*initialize speed of plane
*/
public function InitDelta( coord : String, s : float ){
switch(coord) {
case'x' : deltaX = s; break;
case'y' : deltaY = s; break;
case'z' : deltaZ = s; break;
default : deltaY = s; break;
}
}
/*
*get speed of plane
*/
public function getDelta( coord : String ){
switch(coord) {
case'x' : return deltaX; break;
case'y' : return deltaY; break;
case'z' : return deltaZ; break;
default : return deltaY; break;
}
}
/*
* Accessors of lastMoveTime
*/
public function updateLastMoveTime() {
lastMoveTime = Time.time ;
}
public function getLastMoveTime() : float {
return lastMoveTime ;
}
/*
* The plan could be visible ?
*/
public function setVisible ( b : boolean ) {
visible = b ;
}
public function getVisible() : boolean {
return visible ;
}
public function getBeginTime() {
return beginTime ;
}
public function getEndTime() {
return endTime ;
}
static function isOnIpad() : boolean {
return ( SystemInfo.deviceType == DeviceType.Handheld );
}