|
|
@ -4,7 +4,7 @@ import 'package:pinball/game/game.dart';
|
|
|
|
import 'package:pinball/gen/gen.dart';
|
|
|
|
import 'package:pinball/gen/gen.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template game_hud}
|
|
|
|
/// {@template game_hud}
|
|
|
|
/// Overlay of a [PinballGame].
|
|
|
|
/// Overlay on the [PinballGame].
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Displays the current [GameState.score], [GameState.balls] and animates when
|
|
|
|
/// Displays the current [GameState.score], [GameState.balls] and animates when
|
|
|
|
/// the player gets a [GameBonus].
|
|
|
|
/// the player gets a [GameBonus].
|
|
|
@ -33,7 +33,8 @@ class _GameHudState extends State<GameHud> {
|
|
|
|
height: _width / _ratio,
|
|
|
|
height: _width / _ratio,
|
|
|
|
width: _width,
|
|
|
|
width: _width,
|
|
|
|
child: BlocListener<GameBloc, GameState>(
|
|
|
|
child: BlocListener<GameBloc, GameState>(
|
|
|
|
listenWhen: _listenWhenBonusChanges,
|
|
|
|
listenWhen: (previous, current) =>
|
|
|
|
|
|
|
|
previous.bonusHistory.length != current.bonusHistory.length,
|
|
|
|
listener: (_, __) => setState(() => showAnimation = true),
|
|
|
|
listener: (_, __) => setState(() => showAnimation = true),
|
|
|
|
child: AnimatedSwitcher(
|
|
|
|
child: AnimatedSwitcher(
|
|
|
|
duration: kThemeAnimationDuration,
|
|
|
|
duration: kThemeAnimationDuration,
|
|
|
@ -51,12 +52,6 @@ class _GameHudState extends State<GameHud> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool _listenWhenBonusChanges(GameState previous, GameState current) {
|
|
|
|
|
|
|
|
final previousCount = previous.bonusHistory.length;
|
|
|
|
|
|
|
|
final currentCount = current.bonusHistory.length;
|
|
|
|
|
|
|
|
return previousCount != currentCount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _ScoreViewDecoration extends StatelessWidget {
|
|
|
|
class _ScoreViewDecoration extends StatelessWidget {
|
|
|
@ -105,12 +100,12 @@ class _AnimationView extends StatelessWidget {
|
|
|
|
return BonusAnimation.dashNest(onCompleted: onComplete);
|
|
|
|
return BonusAnimation.dashNest(onCompleted: onComplete);
|
|
|
|
case GameBonus.sparkyTurboCharge:
|
|
|
|
case GameBonus.sparkyTurboCharge:
|
|
|
|
return BonusAnimation.sparkyTurboCharge(onCompleted: onComplete);
|
|
|
|
return BonusAnimation.sparkyTurboCharge(onCompleted: onComplete);
|
|
|
|
case GameBonus.dino:
|
|
|
|
case GameBonus.dinoChomp:
|
|
|
|
return BonusAnimation.dino(onCompleted: onComplete);
|
|
|
|
return BonusAnimation.dinoChomp(onCompleted: onComplete);
|
|
|
|
case GameBonus.googleWord:
|
|
|
|
case GameBonus.googleWord:
|
|
|
|
return BonusAnimation.google(onCompleted: onComplete);
|
|
|
|
return BonusAnimation.googleWord(onCompleted: onComplete);
|
|
|
|
case GameBonus.android:
|
|
|
|
case GameBonus.androidSpaceship:
|
|
|
|
return BonusAnimation.android(onCompleted: onComplete);
|
|
|
|
return BonusAnimation.androidSpaceship(onCompleted: onComplete);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|