Revision 47ba5ddc
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/effect/scramble/ScrambleEffect.java | ||
---|---|---|
85 | 85 |
mLastVector = -1; |
86 | 86 |
} |
87 | 87 |
|
88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
89 |
|
|
90 |
public static String[] getNames() |
|
91 |
{ |
|
92 |
String[] names = new String[NUM_EFFECTS]; |
|
93 |
|
|
94 |
for( int i=0; i<NUM_EFFECTS; i++) |
|
95 |
{ |
|
96 |
names[i] = types[i].name(); |
|
97 |
} |
|
98 |
|
|
99 |
return names; |
|
100 |
} |
|
101 |
|
|
102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
103 |
|
|
104 |
public static ScrambleEffect create(int ordinal) throws InstantiationException, IllegalAccessException |
|
105 |
{ |
|
106 |
return types[ordinal].effect.newInstance(); |
|
107 |
} |
|
108 |
|
|
109 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
110 | 89 |
|
111 | 90 |
abstract void createEffects(int duration); |
112 | 91 |
abstract void effectFinishedPlugin(final long effectID); |
113 | 92 |
|
114 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
94 |
// first compute how many out of 'numScrambles' are double turns (this will matter when we compute |
|
95 |
// the time a single quarter-turn takes! |
|
115 | 96 |
|
116 | 97 |
private void createBaseEffects(int duration, int numScrambles) |
117 | 98 |
{ |
118 | 99 |
mNumScramblesLeft = numScrambles; |
119 | 100 |
|
120 |
// compute how many out of 'numScrambles' are double turns. |
|
121 | 101 |
mNumDoubleScramblesLeft=0; |
122 | 102 |
|
123 | 103 |
for(int i=0; i<numScrambles; i++) |
... | ... | |
197 | 177 |
return sign==0 ? result : -result; |
198 | 178 |
} |
199 | 179 |
|
180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
|
|
182 |
private void assignEffects() |
|
183 |
{ |
|
184 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
185 |
{ |
|
186 |
mCube.apply(mCubeEffects[i],mCubeEffectPosition[i]); |
|
187 |
mCubeEffects[i].notifyWhenFinished(this); |
|
188 |
} |
|
189 |
|
|
190 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
191 |
|
|
192 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
193 |
{ |
|
194 |
nodeEffects.apply(mNodeEffects[i],mNodeEffectPosition[i]); |
|
195 |
mNodeEffects[i].notifyWhenFinished(this); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
200 |
|
|
201 |
private void disassignEffects() |
|
202 |
{ |
|
203 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
204 |
{ |
|
205 |
mCube.remove(mCubeEffects[i].getID()); |
|
206 |
} |
|
207 |
|
|
208 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
209 |
|
|
210 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
211 |
{ |
|
212 |
nodeEffects.abortById(mNodeEffects[i].getID()); |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
217 |
// PUBLIC API |
|
218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
219 |
|
|
220 |
@SuppressWarnings("unused") |
|
221 |
public static String[] getNames() |
|
222 |
{ |
|
223 |
String[] names = new String[NUM_EFFECTS]; |
|
224 |
|
|
225 |
for( int i=0; i<NUM_EFFECTS; i++) |
|
226 |
{ |
|
227 |
names[i] = types[i].name(); |
|
228 |
} |
|
229 |
|
|
230 |
return names; |
|
231 |
} |
|
232 |
|
|
233 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
234 |
|
|
235 |
@SuppressWarnings("unused") |
|
236 |
public static ScrambleEffect create(int ordinal) throws InstantiationException, IllegalAccessException |
|
237 |
{ |
|
238 |
return types[ordinal].effect.newInstance(); |
|
239 |
} |
|
240 |
|
|
200 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
201 | 242 |
|
202 | 243 |
public void effectFinished(final long effectID) |
... | ... | |
257 | 298 |
|
258 | 299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
259 | 300 |
|
301 |
@SuppressWarnings("unused") |
|
260 | 302 |
public long start(int duration, RubikRenderer renderer) |
261 | 303 |
{ |
262 | 304 |
mCube = renderer.getCube(); |
... | ... | |
277 | 319 |
return FAKE_EFFECT_ID; |
278 | 320 |
} |
279 | 321 |
|
280 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
281 |
|
|
282 |
private void assignEffects() |
|
283 |
{ |
|
284 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
285 |
{ |
|
286 |
mCube.apply(mCubeEffects[i],mCubeEffectPosition[i]); |
|
287 |
mCubeEffects[i].notifyWhenFinished(this); |
|
288 |
} |
|
289 |
|
|
290 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
291 |
|
|
292 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
293 |
{ |
|
294 |
nodeEffects.apply(mNodeEffects[i],mNodeEffectPosition[i]); |
|
295 |
mNodeEffects[i].notifyWhenFinished(this); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
300 |
|
|
301 |
private void disassignEffects() |
|
302 |
{ |
|
303 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
304 |
{ |
|
305 |
mCube.remove(mCubeEffects[i].getID()); |
|
306 |
} |
|
307 |
|
|
308 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
309 |
|
|
310 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
311 |
{ |
|
312 |
nodeEffects.abortById(mNodeEffects[i].getID()); |
|
313 |
} |
|
314 |
} |
|
315 |
|
|
316 | 322 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
317 | 323 |
|
318 | 324 |
@SuppressWarnings("unused") |
Also available in: Unified diff
RubikCube: further fixes