Revision 3c4a326c
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/effect/scramble/ScrambleEffect.java | ||
---|---|---|
23 | 23 |
import org.distorted.library.effect.Effect; |
24 | 24 |
import org.distorted.library.main.DistortedEffects; |
25 | 25 |
import org.distorted.library.message.EffectListener; |
26 |
import org.distorted.library.type.Static3D; |
|
26 | 27 |
import org.distorted.magic.RubikRenderer; |
27 | 28 |
import org.distorted.object.RubikObject; |
28 | 29 |
|
29 | 30 |
import java.lang.reflect.Method; |
30 | 31 |
import java.util.Random; |
31 | 32 |
|
32 |
import static org.distorted.object.RubikObjectList.VECTX; |
|
33 |
import static org.distorted.object.RubikObjectList.VECTY; |
|
34 |
import static org.distorted.object.RubikObjectList.VECTZ; |
|
35 |
|
|
36 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 34 |
|
38 | 35 |
public abstract class ScrambleEffect extends BaseEffect implements EffectListener |
... | ... | |
55 | 52 |
private static final int FAKE_EFFECT_ID = -3; |
56 | 53 |
private static final Type[] types; |
57 | 54 |
|
55 |
private static final Static3D VECTX = new Static3D(1,0,0); |
|
56 |
private static final Static3D VECTY = new Static3D(0,1,0); |
|
57 |
private static final Static3D VECTZ = new Static3D(0,0,1); |
|
58 |
private static final Static3D VECTU = new Static3D(0,0,0); |
|
59 |
|
|
60 |
private static final Static3D[] VECTORS = { VECTX, VECTY, VECTZ, VECTZ }; |
|
61 |
|
|
58 | 62 |
static |
59 | 63 |
{ |
60 | 64 |
int i=0; |
... | ... | |
86 | 90 |
ScrambleEffect() |
87 | 91 |
{ |
88 | 92 |
mRnd = new Random( System.currentTimeMillis() ); |
89 |
mLastVector = -1;
|
|
93 |
mLastVector = 3;
|
|
90 | 94 |
} |
91 | 95 |
|
92 | 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
123 | 127 |
{ |
124 | 128 |
if( mNumScramblesLeft>0 ) |
125 | 129 |
{ |
126 |
if( mLastVector == -1 )
|
|
130 |
if( mLastVector == 3 )
|
|
127 | 131 |
{ |
128 |
switch(mRnd.nextInt(3)) |
|
129 |
{ |
|
130 |
case 0: mLastVector = VECTX; break; |
|
131 |
case 1: mLastVector = VECTY; break; |
|
132 |
case 2: mLastVector = VECTZ; break; |
|
133 |
} |
|
132 |
mLastVector = mRnd.nextInt(3); |
|
134 | 133 |
} |
135 | 134 |
else |
136 | 135 |
{ |
... | ... | |
138 | 137 |
|
139 | 138 |
switch(mLastVector) |
140 | 139 |
{ |
141 |
case VECTX: mLastVector = (newVector==0 ? VECTY: VECTZ); break;
|
|
142 |
case VECTY: mLastVector = (newVector==0 ? VECTX: VECTZ); break;
|
|
143 |
case VECTZ: mLastVector = (newVector==0 ? VECTX: VECTY); break;
|
|
140 |
case 0: mLastVector = (newVector==0 ? 1:2); break;
|
|
141 |
case 1: mLastVector = (newVector==0 ? 0:2); break;
|
|
142 |
case 2: mLastVector = (newVector==0 ? 0:1); break;
|
|
144 | 143 |
} |
145 | 144 |
} |
146 | 145 |
|
... | ... | |
157 | 156 |
android.util.Log.e("effect", "ERROR: "+mNumDoubleScramblesLeft); |
158 | 157 |
} |
159 | 158 |
|
160 |
mCurrentBaseEffectID = mObject.addNewRotation(mLastVector, row, angle*90, durationMillis, this );
|
|
159 |
mCurrentBaseEffectID = mObject.addNewRotation(VECTORS[mLastVector], row, angle*90, durationMillis, this );
|
|
161 | 160 |
} |
162 | 161 |
else |
163 | 162 |
{ |
Also available in: Unified diff
More work on making new types of RubikObjects easily creatable.