refactor: ramp bonus listen when refactored

pull/416/head
RuiAlonso 3 years ago
parent a3b03976e3
commit a5b05f0ac8

@ -23,10 +23,13 @@ class RampBonusBehavior extends Component with ParentIsA<SpaceshipRamp> {
await super.onLoad(); await super.onLoad();
await add( await add(
FlameBlocListener<SpaceshipRampCubit, SpaceshipRampState>( FlameBlocListener<SpaceshipRampCubit, SpaceshipRampState>(
listenWhen: (previousState, newState) => listenWhen: (previousState, newState) {
previousState.hits != newState.hits && final hasChanged = previousState.hits != newState.hits;
newState.hits != 0 && final hasHit = newState.hits != 0;
newState.hits % 10 == 0, final achievedOneMillionPoints = newState.hits % 10 == 0;
return hasChanged && hasHit && achievedOneMillionPoints;
},
onNewState: (state) { onNewState: (state) {
parent.add( parent.add(
ScoringBehavior( ScoringBehavior(

Loading…
Cancel
Save