Revision 47ba5ddc
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/effect/solve/SolveEffect.java | ||
---|---|---|
80 | 80 |
|
81 | 81 |
SolveEffect() |
82 | 82 |
{ |
83 |
mPhase = 0;
|
|
83 |
mPhase= 0;
|
|
84 | 84 |
|
85 | 85 |
mCubeEffectNumber = new int[NUM_PHASES]; |
86 | 86 |
mNodeEffectNumber = new int[NUM_PHASES]; |
... | ... | |
92 | 92 |
|
93 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
94 | 94 |
|
95 |
abstract void createEffectsPhase0(int duration); |
|
96 |
abstract void createEffectsPhase1(int duration); |
|
97 |
|
|
98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
99 |
|
|
100 |
private void assignEffects(int phase) |
|
101 |
{ |
|
102 |
mCubeEffectNumber[phase] = ( mCubeEffects[phase]!=null ) ? mCubeEffects[phase].length : 0; |
|
103 |
mNodeEffectNumber[phase] = ( mNodeEffects[phase]!=null ) ? mNodeEffects[phase].length : 0; |
|
104 |
|
|
105 |
if( mCubeEffectNumber[phase]==0 && mNodeEffectNumber[phase]==0 ) |
|
106 |
{ |
|
107 |
throw new RuntimeException("Cube and Node Effects ("+phase+" phase) both not created!"); |
|
108 |
} |
|
109 |
|
|
110 |
for(int i=0; i<mCubeEffectNumber[phase]; i++) |
|
111 |
{ |
|
112 |
mCube.apply(mCubeEffects[phase][i],mCubeEffectPosition[phase][i]); |
|
113 |
mCubeEffects[phase][i].notifyWhenFinished(this); |
|
114 |
} |
|
115 |
|
|
116 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
117 |
|
|
118 |
for(int i=0; i<mNodeEffectNumber[phase]; i++) |
|
119 |
{ |
|
120 |
nodeEffects.apply(mNodeEffects[phase][i],mNodeEffectPosition[phase][i]); |
|
121 |
mNodeEffects[phase][i].notifyWhenFinished(this); |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
private void effectAction(int phase) |
|
128 |
{ |
|
129 |
switch(phase) |
|
130 |
{ |
|
131 |
case 0: mEffectReturned = 0; |
|
132 |
mPhase = 1; |
|
133 |
mCube.solve(); |
|
134 |
createEffectsPhase1(mDuration); |
|
135 |
assignEffects(mPhase); |
|
136 |
break; |
|
137 |
case 1: mListener.effectFinished(FAKE_EFFECT_ID); |
|
138 |
break; |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
143 |
// PUBLIC API |
|
144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
145 |
|
|
146 |
@SuppressWarnings("unused") |
|
95 | 147 |
public static String[] getNames() |
96 | 148 |
{ |
97 | 149 |
String[] names = new String[NUM_EFFECTS]; |
... | ... | |
106 | 158 |
|
107 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
108 | 160 |
|
161 |
@SuppressWarnings("unused") |
|
109 | 162 |
public static SolveEffect create(int ordinal) throws InstantiationException, IllegalAccessException |
110 | 163 |
{ |
111 | 164 |
return types[ordinal].effect.newInstance(); |
112 | 165 |
} |
113 | 166 |
|
114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
|
|
116 |
abstract void createEffectsPhase0(int duration); |
|
117 |
abstract void createEffectsPhase1(int duration); |
|
118 |
|
|
119 | 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
120 | 168 |
|
121 | 169 |
public void effectFinished(final long effectID) |
... | ... | |
148 | 196 |
|
149 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
150 | 198 |
|
151 |
private void effectAction(int phase) |
|
152 |
{ |
|
153 |
switch(phase) |
|
154 |
{ |
|
155 |
case 0: mEffectReturned = 0; |
|
156 |
mPhase = 1; |
|
157 |
mCube.solve(); |
|
158 |
createEffectsPhase1(mDuration); |
|
159 |
assignEffects(mPhase); |
|
160 |
break; |
|
161 |
case 1: mListener.effectFinished(FAKE_EFFECT_ID); |
|
162 |
break; |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
167 |
|
|
199 |
@SuppressWarnings("unused") |
|
168 | 200 |
public long start(int duration, RubikRenderer renderer) |
169 | 201 |
{ |
170 | 202 |
mScreen = renderer.getScreen(); |
... | ... | |
178 | 210 |
return FAKE_EFFECT_ID; |
179 | 211 |
} |
180 | 212 |
|
181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
182 |
|
|
183 |
private void assignEffects(int phase) |
|
184 |
{ |
|
185 |
mCubeEffectNumber[phase] = ( mCubeEffects[phase]!=null ) ? mCubeEffects[phase].length : 0; |
|
186 |
mNodeEffectNumber[phase] = ( mNodeEffects[phase]!=null ) ? mNodeEffects[phase].length : 0; |
|
187 |
|
|
188 |
if( mCubeEffectNumber[phase]==0 && mNodeEffectNumber[phase]==0 ) |
|
189 |
{ |
|
190 |
throw new RuntimeException("Cube and Node Effects ("+phase+" phase) both not created!"); |
|
191 |
} |
|
192 |
|
|
193 |
for(int i=0; i<mCubeEffectNumber[phase]; i++) |
|
194 |
{ |
|
195 |
mCube.apply(mCubeEffects[phase][i],mCubeEffectPosition[phase][i]); |
|
196 |
mCubeEffects[phase][i].notifyWhenFinished(this); |
|
197 |
} |
|
198 |
|
|
199 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
200 |
|
|
201 |
for(int i=0; i<mNodeEffectNumber[phase]; i++) |
|
202 |
{ |
|
203 |
nodeEffects.apply(mNodeEffects[phase][i],mNodeEffectPosition[phase][i]); |
|
204 |
mNodeEffects[phase][i].notifyWhenFinished(this); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 | 213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
209 | 214 |
|
210 | 215 |
@SuppressWarnings("unused") |
Also available in: Unified diff
RubikCube: further fixes