Revision d7f0c07d
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/main/RubikObjectLibInterface.java | ||
---|---|---|
22 | 22 |
import com.google.firebase.analytics.FirebaseAnalytics; |
23 | 23 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
24 | 24 |
|
25 |
import org.distorted.library.main.DistortedScreen; |
|
25 | 26 |
import org.distorted.library.message.EffectMessageSender; |
26 | 27 |
|
27 | 28 |
import org.distorted.external.RubikNetwork; |
... | ... | |
35 | 36 |
import org.distorted.external.RubikScores; |
36 | 37 |
import org.distorted.objects.RubikObject; |
37 | 38 |
import org.distorted.objects.RubikObjectList; |
39 |
import org.distorted.overlays.DataStars; |
|
40 |
import org.distorted.overlays.ListenerOverlay; |
|
41 |
import org.distorted.overlays.OverlayStars; |
|
38 | 42 |
import org.distorted.screens.RubikScreenPlay; |
39 | 43 |
import org.distorted.screens.RubikScreenReady; |
40 | 44 |
import org.distorted.screens.RubikScreenSolver; |
... | ... | |
45 | 49 |
import java.lang.ref.WeakReference; |
46 | 50 |
|
47 | 51 |
import static org.distorted.external.RubikScores.RECORD_FIRST; |
52 |
import static org.distorted.external.RubikScores.RECORD_NEW; |
|
48 | 53 |
import static org.distorted.external.RubikScores.RECORD_NOT_NEW; |
49 | 54 |
|
50 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
51 | 56 |
|
52 |
public class RubikObjectLibInterface implements ObjectLibInterface |
|
57 |
public class RubikObjectLibInterface implements ObjectLibInterface, ListenerOverlay
|
|
53 | 58 |
{ |
54 | 59 |
private final WeakReference<RubikActivity> mAct; |
55 | 60 |
private int mIsNewRecord; |
... | ... | |
185 | 190 |
} |
186 | 191 |
} |
187 | 192 |
|
188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
189 |
|
|
190 |
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) |
|
191 |
{ |
|
192 |
if( ScreenList.getCurrentScreen()== ScreenList.SOLV ) |
|
193 |
{ |
|
194 |
RubikActivity act = mAct.get(); |
|
195 |
Bundle bundle = new Bundle(); |
|
196 |
bundle.putLong("time", mNewRecord ); |
|
197 |
|
|
198 |
reportRecord(act,startTime,endTime,debug,scrambleNum); |
|
199 |
requestReview(act); |
|
200 |
|
|
201 |
if( mIsNewRecord!=RECORD_NOT_NEW ) |
|
202 |
{ |
|
203 |
if( mIsNewRecord==RECORD_FIRST && RubikObjectList.thereAreLockedObjects() ) |
|
204 |
{ |
|
205 |
|
|
206 |
} |
|
207 |
else |
|
208 |
{ |
|
209 |
RubikDialogNewRecord dialog = new RubikDialogNewRecord(); |
|
210 |
dialog.setArguments(bundle); |
|
211 |
dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() ); |
|
212 |
} |
|
213 |
} |
|
214 |
else |
|
215 |
{ |
|
216 |
RubikDialogSolved dialog = new RubikDialogSolved(); |
|
217 |
dialog.setArguments(bundle); |
|
218 |
dialog.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() ); |
|
219 |
} |
|
220 |
|
|
221 |
act.runOnUiThread(new Runnable() |
|
222 |
{ |
|
223 |
@Override |
|
224 |
public void run() |
|
225 |
{ |
|
226 |
ScreenList.switchScreen( act, ScreenList.DONE); |
|
227 |
} |
|
228 |
}); |
|
229 |
} |
|
230 |
} |
|
231 |
|
|
232 | 193 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
233 | 194 |
|
234 | 195 |
public void onScrambleEffectFinished() |
... | ... | |
473 | 434 |
mLastCubitColor = -1; |
474 | 435 |
} |
475 | 436 |
} |
437 |
|
|
438 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
439 |
|
|
440 |
public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) |
|
441 |
{ |
|
442 |
if( ScreenList.getCurrentScreen()== ScreenList.SOLV ) |
|
443 |
{ |
|
444 |
RubikActivity act = mAct.get(); |
|
445 |
Bundle bundle = new Bundle(); |
|
446 |
bundle.putLong("time", mNewRecord ); |
|
447 |
|
|
448 |
reportRecord(act,startTime,endTime,debug,scrambleNum); |
|
449 |
requestReview(act); |
|
450 |
|
|
451 |
switch(mIsNewRecord) |
|
452 |
{ |
|
453 |
case RECORD_FIRST : RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
454 |
int level = play.getLevel(); |
|
455 |
RubikScores scores = RubikScores.getInstance(); |
|
456 |
int totStars = scores.getNumStars(); |
|
457 |
int newStars = RubikObjectList.computeNumStars(level); |
|
458 |
DistortedScreen screen = act.getScreen(); |
|
459 |
|
|
460 |
OverlayStars stars = new OverlayStars(); |
|
461 |
DataStars data = new DataStars(totStars,newStars,act.getResources()); |
|
462 |
stars.startOverlay(screen,this,data); |
|
463 |
break; |
|
464 |
case RECORD_NEW : RubikDialogNewRecord d2 = new RubikDialogNewRecord(); |
|
465 |
d2.setArguments(bundle); |
|
466 |
d2.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() ); |
|
467 |
break; |
|
468 |
case RECORD_NOT_NEW: RubikDialogSolved d3 = new RubikDialogSolved(); |
|
469 |
d3.setArguments(bundle); |
|
470 |
d3.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() ); |
|
471 |
break; |
|
472 |
} |
|
473 |
|
|
474 |
act.runOnUiThread(new Runnable() |
|
475 |
{ |
|
476 |
@Override |
|
477 |
public void run() |
|
478 |
{ |
|
479 |
ScreenList.switchScreen( act, ScreenList.DONE); |
|
480 |
} |
|
481 |
}); |
|
482 |
} |
|
483 |
} |
|
484 |
|
|
485 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
486 |
|
|
487 |
public void overlayFinished(long id) |
|
488 |
{ |
|
489 |
RubikActivity act = mAct.get(); |
|
490 |
Bundle bundle = new Bundle(); |
|
491 |
bundle.putLong("time", mNewRecord ); |
|
492 |
|
|
493 |
RubikDialogNewRecord d2 = new RubikDialogNewRecord(); |
|
494 |
d2.setArguments(bundle); |
|
495 |
d2.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() ); |
|
496 |
} |
|
476 | 497 |
} |
Also available in: Unified diff
Beginnings of support for 'Overlays': first overlay will be the rotating star which little stars fly to when one solves a level for the first time.