Project

General

Profile

« Previous | Next » 

Revision 486b3417

Added by Leszek Koltunski over 2 years ago

Convert the Diamonds & the Helicopter to the new, unified scrambling method.

View differences:

src/main/java/org/distorted/objects/TwistyHelicopter.java
23 23

  
24 24
import org.distorted.helpers.ObjectShape;
25 25
import org.distorted.helpers.ObjectSticker;
26
import org.distorted.helpers.ScrambleStateGraph;
26 27
import org.distorted.library.main.DistortedEffects;
27 28
import org.distorted.library.main.DistortedTexture;
28 29
import org.distorted.library.mesh.MeshSquare;
......
235 236
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
236 237
    }
237 238

  
239
  private int mCurrState;
240
  private int mIndexExcluded;
241
  private final ScrambleStateGraph[] mStates;
242

  
238 243
///////////////////////////////////////////////////////////////////////////////////////////////////
239 244

  
240 245
  TwistyHelicopter(int size, Static4D quat, DistortedTexture texture,
241 246
                   MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
242 247
    {
243 248
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.HELI, res, scrWidth);
249

  
250
    mStates = new ScrambleStateGraph[]
251
      {
252
      new ScrambleStateGraph( new int[][] { {0,1,1,2,1,2},{0,1,3,2,1,4},{0,1,5,2,1,6},{0,1,7,2,1,8},{0,1,9,2,1,10},{0,1,11,2,1,12} } ),
253
      new ScrambleStateGraph( new int[][] { {           },{           },{0,1,5      },{0,1,7      },{      2,1,10},{       2,1,12} } ),
254
      new ScrambleStateGraph( new int[][] { {           },{           },{      2,1,6},{      2,1,8},{0,1,9       },{0,1,11       } } ),
255
      new ScrambleStateGraph( new int[][] { {           },{           },{0,1,5      },{0,1,7      },{0,1,9       },{0,1,11       } } ),
256
      new ScrambleStateGraph( new int[][] { {           },{           },{      2,1,6},{      2,1,8},{      2,1,10},{       2,1,12} } ),
257
      new ScrambleStateGraph( new int[][] { {0,1,1      },{0,1,3      },{           },{           },{0,1,9       },{       2,1,12} } ),
258
      new ScrambleStateGraph( new int[][] { {      2,1,2},{      2,1,4},{           },{           },{      2,1,10},{0,1,11       } } ),
259
      new ScrambleStateGraph( new int[][] { {0,1,1      },{0,1,3      },{           },{           },{      2,1,10},{0,1,11       } } ),
260
      new ScrambleStateGraph( new int[][] { {      2,1,2},{      2,1,4},{           },{           },{0,1,9       },{       2,1,12} } ),
261
      new ScrambleStateGraph( new int[][] { {      2,1,2},{0,1,3      },{0,1,5      },{      2,1,8},{            },{             } } ),
262
      new ScrambleStateGraph( new int[][] { {0,1,1      },{      2,1,4},{      2,1,6},{0,1,7      },{            },{             } } ),
263
      new ScrambleStateGraph( new int[][] { {      2,1,2},{0,1,3      },{      2,1,6},{0,1,7      },{            },{             } } ),
264
      new ScrambleStateGraph( new int[][] { {0,1,1      },{      2,1,4},{0,1,5      },{      2,1,8},{            },{             } } ),
265
      };
244 266
    }
245 267

  
246 268
///////////////////////////////////////////////////////////////////////////////////////////////////
......
409 431

  
410 432
///////////////////////////////////////////////////////////////////////////////////////////////////
411 433

  
412
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
434
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
413 435
    {
414 436
    if( curr==0 )
415 437
      {
416
      scramble[curr][0] = rnd.nextInt(NUM_AXIS);
417
      }
418
    else
419
      {
420
      int newVector = rnd.nextInt(NUM_AXIS -2);
421

  
422
      switch(scramble[curr-1][0])
423
        {
424
        case  0:
425
        case  1: scramble[curr][0] = newVector+2;
426
                 break;
427
        case  2:
428
        case  3: scramble[curr][0] = (newVector==0 || newVector==1) ? newVector:newVector+2;
429
                 break;
430
        default: scramble[curr][0] = newVector;
431
                 break;
432
        }
438
      mCurrState     = 0;
439
      mIndexExcluded =-1;
433 440
      }
434 441

  
435
    scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 2;
442
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
443
    int random= rnd.nextInt(total);
444
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
436 445

  
437
    switch( rnd.nextInt(2) )
438
      {
439
      case 0: scramble[curr][2] = -1; break;
440
      case 1: scramble[curr][2] =  1; break;
441
      }
446
    scramble[curr][0] = info[0];
447
    scramble[curr][1] = info[1];
448
    scramble[curr][2] = info[2];
449

  
450
    mCurrState     = info[3];
451
    mIndexExcluded = info[0];
442 452
    }
443 453

  
444 454
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff