diff --git a/assets/beach/beach.level.yaml b/assets/beach/beach.level.yaml index 1ea6e8f4..dbdfd197 100644 --- a/assets/beach/beach.level.yaml +++ b/assets/beach/beach.level.yaml @@ -50,7 +50,7 @@ players: location: [-70, 30, 0] enemies: - - fighter: &slinger /fighters/slinger/slinger.fighter.yaml + - fighter: &slinger /fighters/slinger/slinger.fighter.yaml location: [325, 0, 0] trip_point_x: -1 - fighter: *slinger @@ -68,6 +68,12 @@ enemies: - fighter: *brute location: [450, 20, 0] trip_point_x: 300 + - fighter: /fighters/big_bass/big_bass.fighter.yaml + location: [1000, 20, 0] + trip_point_x: 700 + boss: true + +stop_points: [500, 1000] items: - item: &bottle /items/bottle/bottle.item.yaml diff --git a/assets/fighters/big_bass/BigBass.png b/assets/fighters/big_bass/BigBass.png new file mode 100644 index 00000000..290538e8 Binary files /dev/null and b/assets/fighters/big_bass/BigBass.png differ diff --git a/assets/fighters/big_bass/big_bass.fighter.yaml b/assets/fighters/big_bass/big_bass.fighter.yaml new file mode 100644 index 00000000..0c6fb28e --- /dev/null +++ b/assets/fighters/big_bass/big_bass.fighter.yaml @@ -0,0 +1,42 @@ +name: Bandit + +stats: + health: 350 + damage: 35 + movement_speed: 75 + +hud: + portrait: + image: portrait.png + image_size: [35, 35] + +spritesheet: + image: [BigBass.png] + tile_size: [156, 176] + columns: 15 + rows: 3 + + animation_fps: 0.12 + animations: + idle: + frames: [0, 3] + repeat: true + running: + frames: [15, 24] + repeat: true + knocked_right: + frames: [0, 3] + knocked_left: + frames: [0, 3] + dying: + frames: [0, 3] + waiting: + frames: [0, 3] + repeat: false + attacking: + frames: [30, 44] + +audio: + effects: + attacking: + 16: hit.ogg diff --git a/assets/fighters/big_bass/hit.ogg b/assets/fighters/big_bass/hit.ogg new file mode 100644 index 00000000..d0169abb Binary files /dev/null and b/assets/fighters/big_bass/hit.ogg differ diff --git a/assets/fighters/big_bass/portrait.png b/assets/fighters/big_bass/portrait.png new file mode 100644 index 00000000..128b3c1e Binary files /dev/null and b/assets/fighters/big_bass/portrait.png differ diff --git a/src/attack.rs b/src/attack.rs index 9e743865..4bc73eb4 100644 --- a/src/attack.rs +++ b/src/attack.rs @@ -23,6 +23,7 @@ use crate::{ self, ATTACK_HEIGHT, ATTACK_LAYER, ATTACK_WIDTH, ITEM_BOTTLE_NAME, ITEM_HEIGHT, ITEM_LAYER, ITEM_WIDTH, THROW_ITEM_ROTATION_SPEED, }, + enemy::Boss, input::PlayerAction, item::item_carried_by_player, metadata::{FighterMeta, GameMeta, ItemMeta}, @@ -43,6 +44,7 @@ impl Plugin for AttackPlugin { .with_system(player_projectile_attack) .with_system(player_throw) .with_system(player_flop) + .with_system(boss_jump_attack) .with_system(activate_hitbox) .with_system(deactivate_hitbox) .with_system(projectile_cleanup) @@ -53,6 +55,11 @@ impl Plugin for AttackPlugin { enemy_attack .run_in_state(GameState::InGame) .after("move_to_target"), + ) + .add_system( + boss_attack + .run_in_state(GameState::InGame) + .after("move_to_target"), ); } } @@ -401,7 +408,7 @@ fn player_flop( fn enemy_attack( mut query: Query< (Entity, &mut State, &Facing, &Handle), - (With, With), + (With, With, Without), >, mut event_reader: EventReader, mut commands: Commands, @@ -456,6 +463,88 @@ fn enemy_attack( } } +fn boss_attack( + mut query: Query<(Entity, &mut State), (With, With, With)>, + mut event_reader: EventReader, + mut commands: Commands, +) { + for event in event_reader.iter() { + if let Ok((entity, mut state)) = query.get_mut(event.0) { + if *state != State::Attacking { + if rand::random() && *state != State::Waiting { + state.set(State::Waiting); + } else { + state.set(State::Attacking); + + let attack_entity = commands + .spawn_bundle(TransformBundle::from_transform(Transform::default())) + .insert(Sensor(true)) + .insert(ActiveEvents::COLLISION_EVENTS) + .insert( + ActiveCollisionTypes::default() | ActiveCollisionTypes::STATIC_STATIC, + ) + .insert(CollisionGroups::new( + BodyLayers::ENEMY_ATTACK, + BodyLayers::PLAYER, + )) + .insert(Attack { damage: 30 }) + .insert(AttackFrames { + //TODO: Check if this is correct + startup: 5, + active: 9, + recovery: 14, + }) + .id(); + + commands.entity(entity).push_children(&[attack_entity]); + } + } + } + } +} + +fn boss_jump_attack( + mut query: Query<(&State, &Facing, &Animation, &mut Transform)>, + time: Res