Project

General

Profile

« Previous | Next » 

Revision 13ed203c

Added by Leszek Koltunski about 4 years ago

Progress creating the Tutorial Activity.

View differences:

src/main/java/org/distorted/tutorial/TutorialPreRender.java
27 27
import org.distorted.objects.ObjectList;
28 28
import org.distorted.objects.TwistyObject;
29 29
import org.distorted.main.RubikPreRender.ActionFinishedListener;
30
import org.distorted.scores.RubikScores;
30 31

  
31 32
///////////////////////////////////////////////////////////////////////////////////////////////////
32 33

  
......
35 36
  private ActionFinishedListener mAddActionListener;
36 37
  private TutorialSurfaceView mView;
37 38
  private boolean mFinishRotation, mRemoveRotation, mAddRotation,
38
                  mSetQuat, mChangeObject, mSetupObject, mSolveObject,
39
                  mSetQuat, mChangeObject, mSetupObject, mSolveObject, mScrambleObject,
39 40
                  mInitializeObject, mResetAllTextureMaps, mRemovePatternRotation;
40 41
  private boolean mCanPlay;
41 42
  private boolean mIsSolved;
......
49 50
  private long mAddRotationDuration;
50 51
  private long mAddRotationID, mRemoveRotationID;
51 52
  private int mNearestAngle;
53
  private int mScrambleObjectNum;
52 54

  
53 55
///////////////////////////////////////////////////////////////////////////////////////////////////
54 56

  
......
63 65
    mChangeObject   = false;
64 66
    mSetupObject    = false;
65 67
    mSolveObject    = false;
68
    mScrambleObject = false;
69

  
66 70
    mCanPlay        = true;
67 71
    mOldObject      = null;
68 72
    mNewObject      = null;
69
    mScreenWidth    = 0;
73

  
74
    mScreenWidth       = 0;
75
    mScrambleObjectNum = 0;
70 76

  
71 77
    mRemovePatternRotation= false;
72 78
    }
......
219 225
    doEffectNow( BaseEffect.Type.SOLVE );
220 226
    }
221 227

  
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

  
230
  private void scrambleObjectNow()
231
    {
232
    mScrambleObject = false;
233
    mCanPlay        = false;
234
    mIsSolved       = false;
235
    RubikScores.getInstance().incrementNumPlays();
236
    doEffectNow( BaseEffect.Type.SCRAMBLE );
237
    }
238

  
222 239
///////////////////////////////////////////////////////////////////////////////////////////////////
223 240

  
224 241
  private void initializeObjectNow()
......
296 313
    if( mChangeObject          ) changeObjectNow();
297 314
    if( mSetupObject           ) setupObjectNow();
298 315
    if( mSolveObject           ) solveObjectNow();
316
    if( mScrambleObject        ) scrambleObjectNow();
299 317
    if( mAddRotation           ) addRotationNow();
300 318
    if( mInitializeObject      ) initializeObjectNow();
301 319
    if( mResetAllTextureMaps   ) resetAllTextureMapsNow();
......
329 347

  
330 348
  public int getNumScrambles()
331 349
    {
332
    return 0;
350
    return mScrambleObjectNum;
333 351
    }
334 352

  
335 353
///////////////////////////////////////////////////////////////////////////////////////////////////
......
342 360
      }
343 361
    }
344 362

  
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

  
365
  public void scrambleObject(int num)
366
    {
367
    if( mCanPlay )
368
      {
369
      mScrambleObject = true;
370
      mScrambleObjectNum = num;
371
      }
372
    }
373

  
345 374
///////////////////////////////////////////////////////////////////////////////////////////////////
346 375

  
347 376
  public void resetAllTextureMaps()
src/main/java/org/distorted/tutorial/TutorialState.java
26 26
import org.distorted.main.R;
27 27
import org.distorted.main.RubikActivity;
28 28
import org.distorted.main.RubikPreRender;
29
import org.distorted.objects.ObjectList;
29 30
import org.distorted.objects.TwistyObject;
31
import org.distorted.states.RubikStatePlay;
32
import org.distorted.states.StateList;
30 33
import org.distorted.states.TransparentImageButton;
31 34

  
32 35
import java.util.ArrayList;
......
173 176
      @Override
174 177
      public void onClick(View v)
175 178
        {
176
        TutorialPreRender pre = act.getPreRender();
177
        // TODO
179
        RubikStatePlay play = (RubikStatePlay) StateList.PLAY.getStateClass();
180
        int size = play.getSize();
181
        int object= play.getObject();
182
        int sizeIndex = ObjectList.getSizeIndex(object,size);
183
        int maxLevel = ObjectList.getMaxLevel(object, sizeIndex);
184

  
185
        act.getPreRender().scrambleObject(maxLevel);
178 186
        }
179 187
      });
180 188
    }
src/main/res/layout/tutorial.xml
17 17
        android:id="@+id/lowerPart"
18 18
        android:layout_width="match_parent"
19 19
        android:layout_height="0dp"
20
        android:layout_weight="1"
20
        android:layout_weight="1.2"
21 21
        android:orientation="horizontal"
22 22
        android:background="@android:color/transparent">
23 23

  

Also available in: Unified diff