Project

General

Profile

« Previous | Next » 

Revision b1370e3b

Added by Leszek Koltunski almost 2 years ago

IAP part 6: new 'Present' object effect (cont'd)

View differences:

src/main/java/org/distorted/objectlib/effects/present/PresentEffect.java
41 41

  
42 42
  private static final int NUM_EFFECTS = PresentEffect.Type.values().length;
43 43
  private static final int FAKE_EFFECT_ID  = -6;
44
  private static final int EXTRA_DURATION = 5000;
44 45
  private static final PresentEffect.Type[] types;
45 46

  
46 47
  static
......
102 103
      totalDegrees += absAngle*basicDegrees;
103 104
      }
104 105

  
105
    mDurationPerDegree = duration/totalDegrees;
106
    mDurationPerDegree = duration/(2*totalDegrees);
106 107
    mNumScrambles = 0;
107 108

  
108 109
    mRotReady    = false;
......
117 118
    {
118 119
    if( mNumScramblesLeft>0 )
119 120
      {
120
      int axis = mScrambles[mNumScrambles][0];
121
      int row  = mScrambles[mNumScrambles][1];
122
      int angle= mScrambles[mNumScrambles][2];
123

  
124
android.util.Log.e("D", "1 scramble: axis="+axis+" row="+row+" angle="+angle);
125

  
126
      mNumScramblesLeft--;
127
      mPre.addRotation(this, axis, (1<<row), angle, mDurationPerDegree);
128
      mNumScrambles++;
121
      addRotation(true);
129 122
      }
130 123
    else
131 124
      {
132 125
      if( mNumScrambles>0 )
133 126
        {
134
        mNumScrambles--;
135
        int axis = mScrambles[mNumScrambles][0];
136
        int row  = mScrambles[mNumScrambles][1];
137
        int angle=-mScrambles[mNumScrambles][2];
138

  
139
android.util.Log.e("D", "2 scramble: axis="+axis+" row="+row+" angle="+angle);
140

  
141
        mPre.addRotation(this, axis, (1<<row), angle, mDurationPerDegree);
127
        if( mNumScramblesLeft==0 )
128
          {
129
          Thread thread = new Thread()
130
            {
131
            public void run()
132
              {
133
              try { sleep(EXTRA_DURATION); }
134
              catch(InterruptedException ex) { }
135
              addRotation(false);
136
              }
137
            };
138

  
139
          thread.start();
140
          }
141
        else
142
          {
143
          addRotation(false);
144
          }
142 145
        }
143 146
      else
144 147
        {
......
148 151
      }
149 152
    }
150 153

  
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

  
156
  private void addRotation(boolean forward)
157
    {
158
    if( !forward )
159
      {
160
      mNumScrambles--;
161
      mNumScramblesLeft--;
162
      }
163

  
164
    int axis = mScrambles[mNumScrambles][0];
165
    int row  = mScrambles[mNumScrambles][1];
166
    int angle= mScrambles[mNumScrambles][2];
167

  
168
    if( !forward ) angle = -angle;
169

  
170
    mPre.addRotation(this, axis, (1<<row), angle, mDurationPerDegree);
171

  
172
    if( forward )
173
      {
174
      mNumScrambles++;
175
      mNumScramblesLeft--;
176
      }
177
    }
178

  
151 179
///////////////////////////////////////////////////////////////////////////////////////////////////
152 180

  
153 181
  private void assignEffects()
......
171 199

  
172 200
  private void disassignEffects()
173 201
    {
174
    android.util.Log.e("D", "disassigning effects");
175

  
176

  
177 202
    for(int i=0; i<mCubeEffectNumber; i++)
178 203
      {
179 204
      mObject.removeEffect(mCubeEffects[i].getID());
......
216 241

  
217 242
  public void onActionFinished(final long effectID)
218 243
    {
219
android.util.Log.e("D", "onActionFinished");
220

  
221

  
222 244
    addNewScramble();
223 245
    }
224 246

  
......
242 264

  
243 265
  public void effectFinished(final long effectID)
244 266
    {
245
android.util.Log.e("D", "effectFinished");
246

  
247 267
    for(int i=0; i<mCubeEffectNumber; i++)
248 268
      {
249 269
      long id = mCubeEffects[i].getID();
......
288 308
    mScrambles = new int[numScrambles][3];
289 309
    int dura = (int)(duration*Math.pow(numScrambles,0.66f));
290 310
    createBaseEffects(dura,numScrambles);
291
    createEffects    (dura,numScrambles);
311
    createEffects    (dura+EXTRA_DURATION,numScrambles);
292 312

  
293 313
    if( mCubeEffectNumber==0 && mNodeEffectNumber==0 )
294 314
      {

Also available in: Unified diff