@Override
public void init() {
attachModelImmediately( gravity );
attachModelImmediately( new ModelDeactivator( onLand, true ) );
addTileMapCollisions( Group.HORIZONTAL, instance.tileMap, bumpingWalls, null );
addTileMapCollisions( Group.VERTICAL, instance.tileMap, verticalCollisionHandler, null );
jumpingAnimation = new AnimationModel( false, jumpingAnimationSpeed, 8, 8 );
fallingAnimation = new AnimationModel( true, jumpingAnimationSpeed, 3, 13, true );
AnimationModel firingAnimation = new AnimationModel( false, firingAnimationSpeed, 8, 16 );
if( parameterExists( "jumping" ) ) {
double[] parameters= getDoubleParameters( "jumping", "-" );
RandomWaitingModel waitingForJump = new RandomWaitingModel( parameters[ 0 ], parameters[ 1 ] );
attachModel( waitingForJump );
IsModelActive onLandCondition = new IsModelActive( onLand );
waitingForJump.nextModels.addLast( onLandCondition );
IsModelActive animationActive = new IsModelActive( firingAnimation );
onLandCondition.trueModels.addLast( animationActive );
onLandCondition.falseModels.addLast( waitingForJump );
animationActive.trueModels.addLast( waitingForJump );
animationActive.falseModels.addLast( new ModelActivator( jumpingAnimation ) );
animationActive.falseModels.addLast( new ModelDeactivator( horizontalMovementModel() ) );
animationActive.falseModels.addLast( new ModelDeactivator( gravity ) );
jumpingAnimation.nextModels.addLast( new ModelActivator( fallingAnimation ) );
parameters= getDoubleParameters( "jumping_strength", "-" );
FixedWaitingModel pauseBeforeJump = FixedWaitingModel.create( jumpingPause );
pauseBeforeJump.nextModels.addLast( new Jump( parameters[ 0 ], parameters[ 1 ] ) );
pauseBeforeJump.nextModels.addLast( new ModelActivator( horizontalMovementModel() ) );
pauseBeforeJump.nextModels.addLast( new ModelActivator( gravity ) );
pauseBeforeJump.nextModels.addLast( waitingForJump );
animationActive.falseModels.addLast( pauseBeforeJump );
addToStack( jumpingAnimation );
score += 200;
}
addToStack( fallingAnimation );
if( parameterExists( "firing" ) ) {
double[] parameters = getDoubleParameters( "firing", "-" );
RandomWaitingModel waitingForFire = new RandomWaitingModel( parameters[ 0 ], parameters[ 1 ] );
attachModel( waitingForFire );
IsModelActive onLandCondition = new IsModelActive( onLand );
waitingForFire.nextModels.addLast( onLandCondition );
IsModelActive animationActive = new IsModelActive( jumpingAnimation );
onLandCondition.trueModels.addLast( animationActive );
onLandCondition.falseModels.addLast( waitingForFire );
animationActive.trueModels.addLast( waitingForFire );
animationActive.falseModels.addLast( new ModelActivator( firingAnimation ) );
animationActive.falseModels.addLast( new ModelDeactivator( horizontalMovementModel() ) );
firingAnimation.nextModels.addLast( new ModelActivator( horizontalMovementModel() ) );
parameters = getDoubleParameters( "firing_speed", "-" );
FixedWaitingModel pauseBeforeBullet = FixedWaitingModel.create( bulletPause );