Revision d12bb11b
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/effect/scramble/ScrambleEffect.java | ||
---|---|---|
72 | 72 |
private RubikObject mObject; |
73 | 73 |
private int mNumAxis; |
74 | 74 |
private int mBasicAngle; |
75 |
private int mSize; |
|
75 | 76 |
|
76 | 77 |
Effect[] mNodeEffects; |
77 | 78 |
int[] mNodeEffectPosition; |
... | ... | |
141 | 142 |
mLastVector = (newVector>=mLastVector ? newVector+1 : newVector); |
142 | 143 |
} |
143 | 144 |
|
144 |
int rowBitmap = (1<<mRnd.nextInt(mObject.getSize()));
|
|
145 |
int rowBitmap = (1<<mRnd.nextInt(mSize));
|
|
145 | 146 |
int angle= randomizeAngle(); |
146 | 147 |
int absAngle = (angle<0 ? -angle : angle); |
147 | 148 |
long durationMillis = absAngle*mDurationSingleTurn; |
... | ... | |
244 | 245 |
|
245 | 246 |
public void onActionFinished(final long effectID) |
246 | 247 |
{ |
247 |
mObject.removeRotationNow(); |
|
248 | 248 |
addNewScramble(); |
249 | 249 |
} |
250 | 250 |
|
... | ... | |
311 | 311 |
|
312 | 312 |
mNumAxis = mObject.getRotationAxis().length; |
313 | 313 |
mBasicAngle = mObject.getBasicAngle(); |
314 |
mSize = mObject.getSize(); |
|
314 | 315 |
|
315 | 316 |
int numScrambles = post.getNumScrambles(); |
316 | 317 |
int dura = (int)(duration*Math.pow(numScrambles,0.6f)); |
src/main/java/org/distorted/magic/RubikPostRender.java | ||
---|---|---|
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
private RubikSurfaceView mView; |
45 |
private boolean mFinishRotation, mRemoveRotation, mAddRotation, mSetQuatCurrent, mSetQuatAccumulated; |
|
45 |
private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation, |
|
46 |
mSetQuatCurrent, mSetQuatAccumulated; |
|
46 | 47 |
private boolean mChangeObject, mSolveObject, mScrambleObject; |
47 | 48 |
private boolean mCanRotate, mCanDrag, mCanUI; |
48 | 49 |
private boolean mIsSolved; |
... | ... | |
60 | 61 |
private int mAddRotationAxis, mAddRotationRowBitmap, mAddRotationAngle; |
61 | 62 |
private long mAddRotationDuration; |
62 | 63 |
private ActionFinishedListener mAddActionListener; |
63 |
private long mAddRotationID; |
|
64 |
private long mAddRotationID, mRemoveRotationID; |
|
65 |
private boolean mInitializeObject; |
|
64 | 66 |
|
65 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
66 | 68 |
|
... | ... | |
68 | 70 |
{ |
69 | 71 |
mView = view; |
70 | 72 |
|
71 |
mFinishRotation = false; |
|
72 |
mRemoveRotation = false; |
|
73 |
mAddRotation = false; |
|
74 |
mSetQuatCurrent = false; |
|
75 |
mSetQuatAccumulated = false; |
|
76 |
mChangeObject = false; |
|
77 |
mSolveObject = false; |
|
78 |
mScrambleObject = false; |
|
73 |
mFinishRotation = false; |
|
74 |
mRemoveRotation = false; |
|
75 |
mRemovePatternRotation= false; |
|
76 |
mAddRotation = false; |
|
77 |
mSetQuatCurrent = false; |
|
78 |
mSetQuatAccumulated = false; |
|
79 |
mChangeObject = false; |
|
80 |
mSolveObject = false; |
|
81 |
mScrambleObject = false; |
|
79 | 82 |
|
80 | 83 |
mCanRotate = true; |
81 | 84 |
mCanDrag = true; |
... | ... | |
182 | 185 |
mRemoveRotation = true; |
183 | 186 |
} |
184 | 187 |
|
188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
189 |
|
|
190 |
private void removePatternRotation() |
|
191 |
{ |
|
192 |
mRemovePatternRotation = true; |
|
193 |
} |
|
194 |
|
|
195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
196 |
|
|
197 |
private void removePatternRotationNow() |
|
198 |
{ |
|
199 |
mRemovePatternRotation=false; |
|
200 |
mNewObject.removeRotationNow(); |
|
201 |
mAddActionListener.onActionFinished(mRemoveRotationID); |
|
202 |
} |
|
203 |
|
|
185 | 204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
186 | 205 |
|
187 | 206 |
private void addRotationNow() |
188 | 207 |
{ |
189 | 208 |
mAddRotation = false; |
190 |
|
|
191 | 209 |
mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap, |
192 | 210 |
mAddRotationAngle, mAddRotationDuration, this); |
193 | 211 |
} |
... | ... | |
252 | 270 |
doEffectNow( BaseEffect.Type.SOLVE ); |
253 | 271 |
} |
254 | 272 |
|
273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
274 |
|
|
275 |
private void initializeObjectNow() |
|
276 |
{ |
|
277 |
mInitializeObject = false; |
|
278 |
mNewObject.initializeObject(mNextMoves); |
|
279 |
} |
|
280 |
|
|
255 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
256 | 282 |
|
257 | 283 |
private void setQuatCurrentNow() |
... | ... | |
374 | 400 |
|
375 | 401 |
void postRender() |
376 | 402 |
{ |
377 |
if( mSetQuatCurrent ) setQuatCurrentNow(); |
|
378 |
if( mSetQuatAccumulated ) setQuatAccumulatedNow(); |
|
379 |
if( mFinishRotation ) finishRotationNow(); |
|
380 |
if( mRemoveRotation ) removeRotationNow(); |
|
381 |
if( mChangeObject ) changeObjectNow(); |
|
382 |
if( mSolveObject ) solveObjectNow(); |
|
383 |
if( mScrambleObject ) scrambleObjectNow(); |
|
384 |
if( mAddRotation ) addRotationNow(); |
|
403 |
if( mSetQuatCurrent ) setQuatCurrentNow(); |
|
404 |
if( mSetQuatAccumulated ) setQuatAccumulatedNow(); |
|
405 |
if( mFinishRotation ) finishRotationNow(); |
|
406 |
if( mRemoveRotation ) removeRotationNow(); |
|
407 |
if( mRemovePatternRotation ) removePatternRotationNow(); |
|
408 |
if( mChangeObject ) changeObjectNow(); |
|
409 |
if( mSolveObject ) solveObjectNow(); |
|
410 |
if( mScrambleObject ) scrambleObjectNow(); |
|
411 |
if( mAddRotation ) addRotationNow(); |
|
412 |
if( mInitializeObject ) initializeObjectNow(); |
|
385 | 413 |
} |
386 | 414 |
|
387 | 415 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
399 | 427 |
mAddRotationDuration = duration; |
400 | 428 |
} |
401 | 429 |
|
430 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
431 |
|
|
432 |
public void initializeObject(int[][] moves) |
|
433 |
{ |
|
434 |
mInitializeObject = true; |
|
435 |
mNextMoves = moves; |
|
436 |
} |
|
437 |
|
|
402 | 438 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
403 | 439 |
|
404 | 440 |
public RubikObject getObject() |
... | ... | |
432 | 468 |
else if( effectID == mAddRotationID ) |
433 | 469 |
{ |
434 | 470 |
mAddRotationID = 0; |
435 |
mAddActionListener.onActionFinished(effectID); |
|
471 |
mRemoveRotationID = effectID; |
|
472 |
removePatternRotation(); |
|
436 | 473 |
} |
437 | 474 |
else |
438 | 475 |
{ |
src/main/java/org/distorted/patterns/RubikPattern.java | ||
---|---|---|
158 | 158 |
private int[][] moves; |
159 | 159 |
private int curMove; |
160 | 160 |
private int numMove; |
161 |
|
|
162 | 161 |
private boolean mCanRotate; |
163 |
private RubikObject mObject; |
|
164 | 162 |
|
165 | 163 |
///////////////////////////////////////////////////////////// |
166 | 164 |
|
... | ... | |
223 | 221 |
curMove++; |
224 | 222 |
RubikObject object = post.getObject(); |
225 | 223 |
|
226 |
if( curMove>numMove ) |
|
227 |
{ |
|
228 |
curMove= 0; |
|
229 |
object.initializeObject(null); |
|
230 |
} |
|
231 |
else |
|
224 |
if( mCanRotate ) |
|
232 | 225 |
{ |
233 |
if( mCanRotate ) |
|
226 |
if( curMove>numMove ) |
|
227 |
{ |
|
228 |
curMove= 0; |
|
229 |
post.initializeObject(null); |
|
230 |
} |
|
231 |
else |
|
234 | 232 |
{ |
235 | 233 |
mCanRotate = false; |
236 |
mObject = object; |
|
237 | 234 |
|
238 | 235 |
int axis =moves[curMove-1][0]; |
239 | 236 |
int rowBitmap=moves[curMove-1][1]; |
... | ... | |
243 | 240 |
|
244 | 241 |
post.addRotation(this, axis, rowBitmap, angle, numRot*DURATION_MILLIS); |
245 | 242 |
} |
246 |
else |
|
247 |
{ |
|
248 |
android.util.Log.e("pattern", "failed to make Move!"); |
|
249 |
|
|
250 |
curMove--; |
|
251 |
} |
|
243 |
} |
|
244 |
else |
|
245 |
{ |
|
246 |
android.util.Log.e("pattern", "failed to make Move!"); |
|
247 |
curMove--; |
|
252 | 248 |
} |
253 | 249 |
} |
254 | 250 |
|
... | ... | |
259 | 255 |
curMove--; |
260 | 256 |
RubikObject object = post.getObject(); |
261 | 257 |
|
262 |
if( curMove<0 ) |
|
263 |
{ |
|
264 |
curMove=numMove; |
|
265 |
object.initializeObject(moves); |
|
266 |
} |
|
267 |
else |
|
258 |
if( mCanRotate ) |
|
268 | 259 |
{ |
269 |
if( mCanRotate ) |
|
260 |
if( curMove<0 ) |
|
261 |
{ |
|
262 |
curMove=numMove; |
|
263 |
post.initializeObject(moves); |
|
264 |
} |
|
265 |
else |
|
270 | 266 |
{ |
271 | 267 |
mCanRotate = false; |
272 |
mObject = object; |
|
273 | 268 |
|
274 | 269 |
int axis =moves[curMove][0]; |
275 | 270 |
int rowBitmap=moves[curMove][1]; |
... | ... | |
279 | 274 |
|
280 | 275 |
post.addRotation(this, axis, rowBitmap, -angle, numRot*DURATION_MILLIS); |
281 | 276 |
} |
282 |
else
|
|
283 |
{
|
|
284 |
android.util.Log.e("pattern", "failed to back Move!");
|
|
285 |
curMove++;
|
|
286 |
}
|
|
277 |
}
|
|
278 |
else
|
|
279 |
{
|
|
280 |
android.util.Log.e("pattern", "failed to back Move!");
|
|
281 |
curMove++;
|
|
287 | 282 |
} |
288 | 283 |
} |
289 | 284 |
|
... | ... | |
298 | 293 |
|
299 | 294 |
public void onActionFinished(final long effectID) |
300 | 295 |
{ |
301 |
mObject.removeRotationNow(); |
|
302 | 296 |
mCanRotate = true; |
303 | 297 |
} |
304 | 298 |
} |
Also available in: Unified diff
Bugfixes - do more stuff 'post render'