|
|
@ -10,58 +10,40 @@ import 'package:pinball_theme/pinball_theme.dart';
|
|
|
|
/// {@template controlled_ball}
|
|
|
|
/// {@template controlled_ball}
|
|
|
|
/// A [Ball] with a [BallController] attached.
|
|
|
|
/// A [Ball] with a [BallController] attached.
|
|
|
|
/// {@endtemplate}
|
|
|
|
/// {@endtemplate}
|
|
|
|
abstract class _ControlledBall<T extends BallController> extends Ball
|
|
|
|
class ControlledBall extends Ball with Controls<BallController> {
|
|
|
|
with Controls<T> {
|
|
|
|
/// {@macro controlled_ball}
|
|
|
|
_ControlledBall({required Color baseColor}) : super(baseColor: baseColor);
|
|
|
|
ControlledBall({required Color baseColor}) : super(baseColor: baseColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template plunger_ball}
|
|
|
|
|
|
|
|
/// A [Ball] that starts at the [Plunger].
|
|
|
|
/// A [Ball] that starts at the [Plunger].
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// When a [PlungerBall] is lost, it will decrease the [GameState.balls] count,
|
|
|
|
/// When a launched [Ball] is lost, it will decrease the [GameState.balls]
|
|
|
|
/// and a new [PlungerBall] is spawned if it's possible.
|
|
|
|
/// count, and a new [Ball] is spawned at the [Plunger].
|
|
|
|
/// {@endtemplate}
|
|
|
|
ControlledBall.launch({
|
|
|
|
class PlungerBall extends _ControlledBall<PlungerBallController> {
|
|
|
|
|
|
|
|
/// {@macro plunger_ball}
|
|
|
|
|
|
|
|
PlungerBall({
|
|
|
|
|
|
|
|
required PinballTheme theme,
|
|
|
|
required PinballTheme theme,
|
|
|
|
required Plunger plunger,
|
|
|
|
required Plunger plunger,
|
|
|
|
}) : super(baseColor: theme.characterTheme.ballColor) {
|
|
|
|
}) : super(baseColor: theme.characterTheme.ballColor) {
|
|
|
|
// TODO(alestiago): Dicuss if this is a good idea.
|
|
|
|
|
|
|
|
initialPosition = Vector2(
|
|
|
|
initialPosition = Vector2(
|
|
|
|
plunger.body.position.x,
|
|
|
|
plunger.body.position.x,
|
|
|
|
plunger.body.position.y + Ball.size.y,
|
|
|
|
plunger.body.position.y + Ball.size.y,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
controller = PlungerBallController(this);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
PlungerBallController controllerBuilder() => PlungerBallController(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template bonus_ball}
|
|
|
|
/// {@template bonus_ball}
|
|
|
|
/// {@macro controlled_ball}
|
|
|
|
/// {@macro controlled_ball}
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// When a [BonusBall] is lost, the [GameState.balls] doesn't change.
|
|
|
|
/// When a bonus [Ball] is lost, the [GameState.balls] doesn't change.
|
|
|
|
/// {@endtemplate}
|
|
|
|
/// {@endtemplate}
|
|
|
|
class BonusBall extends _ControlledBall<BallController> {
|
|
|
|
ControlledBall.bonus({
|
|
|
|
/// {@macro bonus_ball}
|
|
|
|
|
|
|
|
BonusBall({
|
|
|
|
|
|
|
|
required PinballTheme theme,
|
|
|
|
required PinballTheme theme,
|
|
|
|
}) : super(baseColor: theme.characterTheme.ballColor);
|
|
|
|
}) : super(baseColor: theme.characterTheme.ballColor) {
|
|
|
|
|
|
|
|
controller = BallController(this);
|
|
|
|
@override
|
|
|
|
|
|
|
|
BallController controllerBuilder() => BallController(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template debug_ball}
|
|
|
|
|
|
|
|
/// [Ball] used in [DebugPinballGame].
|
|
|
|
/// [Ball] used in [DebugPinballGame].
|
|
|
|
/// {@endtemplate}
|
|
|
|
ControlledBall.debug() : super(baseColor: const Color(0xFFFF0000)) {
|
|
|
|
class DebugBall extends _ControlledBall<BallController> {
|
|
|
|
controller = BallController(this);
|
|
|
|
/// {@macro debug_ball}
|
|
|
|
}
|
|
|
|
DebugBall() : super(baseColor: const Color(0xFFFF0000));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
BallController controllerBuilder() => BallController(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template ball_controller}
|
|
|
|
/// {@template ball_controller}
|
|
|
|