Revision bbc6471c
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.Random; |
37 | 37 |
|
38 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
39 | 38 |
import static org.distorted.objects.FactoryCubit.REX_D; |
40 | 39 |
|
41 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
393 | 392 |
|
394 | 393 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
395 | 394 |
|
396 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
395 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
396 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
397 | 397 |
{ |
398 |
int numAxis = ROTATION_AXIS.length; |
|
399 |
|
|
400 |
if( oldRotAxis == START_AXIS ) |
|
398 |
if( numScramble==1 ) |
|
401 | 399 |
{ |
402 |
return rnd.nextInt(numAxis);
|
|
400 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
403 | 401 |
} |
404 | 402 |
else |
405 | 403 |
{ |
406 |
int newVector = rnd.nextInt(numAxis-1);
|
|
407 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
404 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
405 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
408 | 406 |
} |
409 |
} |
|
410 |
|
|
411 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
412 | 407 |
|
413 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
414 |
{ |
|
415 | 408 |
float rowFloat = rnd.nextFloat(); |
416 | 409 |
|
417 | 410 |
for(int row=0; row<mRowChances.length; row++) |
418 | 411 |
{ |
419 |
if( rowFloat<=mRowChances[row] ) return row; |
|
412 |
if( rowFloat<=mRowChances[row] ) |
|
413 |
{ |
|
414 |
scramble[1] = row; |
|
415 |
break; |
|
416 |
} |
|
420 | 417 |
} |
421 | 418 |
|
422 |
return 0; |
|
419 |
int random = rnd.nextInt(remScrambles); |
|
420 |
int result = random<remDoubleScrambles ? 2:1; |
|
421 |
int sign = rnd.nextInt(2); |
|
422 |
|
|
423 |
scramble[2] = sign==0 ? result : -result; |
|
423 | 424 |
} |
424 | 425 |
|
425 | 426 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.