Revision bbc6471c
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.Random; |
37 | 37 |
|
38 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
39 |
|
|
40 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 39 |
|
42 | 40 |
public class TwistyHelicopter extends TwistyObject |
... | ... | |
337 | 335 |
|
338 | 336 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
339 | 337 |
|
340 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
338 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
339 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
341 | 340 |
{ |
342 |
int numAxis = ROTATION_AXIS.length; |
|
343 |
|
|
344 |
if( oldRotAxis == START_AXIS ) |
|
341 |
if( numScramble==1 ) |
|
345 | 342 |
{ |
346 |
return rnd.nextInt(numAxis);
|
|
343 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
347 | 344 |
} |
348 | 345 |
else |
349 | 346 |
{ |
350 |
int newVector = rnd.nextInt(numAxis-2);
|
|
347 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-2);
|
|
351 | 348 |
|
352 | 349 |
switch(oldRotAxis) |
353 | 350 |
{ |
354 | 351 |
case 0: |
355 |
case 1: return newVector+2; |
|
352 |
case 1: scramble[0] = newVector+2; |
|
353 |
break; |
|
356 | 354 |
case 2: |
357 |
case 3: return (newVector==0 || newVector==1) ? newVector:newVector+2; |
|
358 |
default: return newVector; |
|
355 |
case 3: scramble[0] = (newVector==0 || newVector==1) ? newVector:newVector+2; |
|
356 |
break; |
|
357 |
default: scramble[0] = newVector; |
|
358 |
break; |
|
359 | 359 |
} |
360 | 360 |
} |
361 |
} |
|
362 |
|
|
363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
364 | 361 |
|
365 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
366 |
{ |
|
367 | 362 |
float rowFloat = rnd.nextFloat(); |
368 | 363 |
|
369 | 364 |
for(int row=0; row<mRowChances.length; row++) |
370 | 365 |
{ |
371 |
if( rowFloat<=mRowChances[row] ) return row; |
|
366 |
if( rowFloat<=mRowChances[row] ) |
|
367 |
{ |
|
368 |
scramble[1] = row; |
|
369 |
break; |
|
370 |
} |
|
372 | 371 |
} |
373 | 372 |
|
374 |
return 0; |
|
373 |
int random = rnd.nextInt(remScrambles); |
|
374 |
int result = random<remDoubleScrambles ? 2:1; |
|
375 |
int sign = rnd.nextInt(2); |
|
376 |
|
|
377 |
scramble[2] = sign==0 ? result : -result; |
|
375 | 378 |
} |
376 | 379 |
|
377 | 380 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.