2021-02-26 20:03:35 +00:00
|
|
|
use crate::common::Direction;
|
2022-11-19 17:20:03 +00:00
|
|
|
use crate::framework::error::GameResult;
|
|
|
|
use crate::game::npc::NPC;
|
|
|
|
use crate::game::shared_game_state::SharedGameState;
|
2020-10-02 01:30:42 +00:00
|
|
|
|
|
|
|
impl NPC {
|
2022-11-19 17:20:03 +00:00
|
|
|
pub(crate) fn tick_n127_machine_gun_trail_l2(&mut self, state: &mut SharedGameState) -> GameResult {
|
2021-02-26 20:03:35 +00:00
|
|
|
self.anim_counter += 1;
|
|
|
|
if self.anim_counter > 0 {
|
|
|
|
self.anim_counter = 0;
|
|
|
|
self.anim_num += 1;
|
|
|
|
if self.anim_num > 2 {
|
|
|
|
self.cond.set_alive(false);
|
|
|
|
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match self.direction {
|
|
|
|
Direction::Left | Direction::Right => {
|
|
|
|
self.anim_rect = state.constants.npc.n127_machine_gun_trail_l2[self.anim_num as usize];
|
|
|
|
}
|
|
|
|
Direction::Up | Direction::Bottom => {
|
|
|
|
self.anim_rect = state.constants.npc.n127_machine_gun_trail_l2[self.anim_num as usize + 3];
|
|
|
|
}
|
2021-10-08 02:41:31 +00:00
|
|
|
_ => (),
|
2021-02-26 20:03:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-11-19 17:20:03 +00:00
|
|
|
pub(crate) fn tick_n128_machine_gun_trail_l3(&mut self, state: &mut SharedGameState) -> GameResult {
|
2021-02-26 20:03:35 +00:00
|
|
|
self.anim_counter += 1;
|
|
|
|
if self.anim_counter > 0 {
|
|
|
|
self.anim_counter = 0;
|
|
|
|
self.anim_num += 1;
|
|
|
|
if self.anim_num > 4 {
|
|
|
|
self.cond.set_alive(false);
|
|
|
|
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.action_num == 0 {
|
|
|
|
self.action_num = 1;
|
|
|
|
|
|
|
|
match self.direction {
|
|
|
|
Direction::Left | Direction::Right => {
|
|
|
|
self.display_bounds.left = 0x800;
|
|
|
|
self.display_bounds.top = 0x1000;
|
|
|
|
}
|
|
|
|
Direction::Bottom | Direction::Up => {
|
|
|
|
self.display_bounds.left = 0x1000;
|
|
|
|
self.display_bounds.top = 0x800;
|
|
|
|
}
|
2021-10-08 02:41:31 +00:00
|
|
|
_ => (),
|
2021-02-26 20:03:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match self.direction {
|
|
|
|
Direction::Left => {
|
|
|
|
self.anim_rect = state.constants.npc.n128_machine_gun_trail_l3[self.anim_num as usize];
|
|
|
|
}
|
|
|
|
Direction::Up => {
|
|
|
|
self.anim_rect = state.constants.npc.n128_machine_gun_trail_l3[self.anim_num as usize + 5];
|
|
|
|
}
|
|
|
|
Direction::Right => {
|
|
|
|
self.anim_rect = state.constants.npc.n128_machine_gun_trail_l3[self.anim_num as usize + 10];
|
|
|
|
}
|
|
|
|
Direction::Bottom => {
|
|
|
|
self.anim_rect = state.constants.npc.n128_machine_gun_trail_l3[self.anim_num as usize + 15];
|
|
|
|
}
|
2021-10-08 02:41:31 +00:00
|
|
|
_ => (),
|
2021-02-26 20:03:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-10-02 01:30:42 +00:00
|
|
|
pub(crate) fn tick_n129_fireball_snake_trail(&mut self, state: &mut SharedGameState) -> GameResult {
|
|
|
|
self.anim_counter += 1;
|
|
|
|
|
|
|
|
if self.anim_counter > 1 {
|
|
|
|
self.anim_counter = 0;
|
|
|
|
|
|
|
|
self.anim_num += 1;
|
|
|
|
if self.anim_num > 2 {
|
|
|
|
self.cond.set_alive(false);
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self.y += self.vel_y;
|
|
|
|
|
|
|
|
if self.anim_counter == 1 {
|
|
|
|
let frame = (self.action_counter2 as usize % 6) * 3 + self.anim_num as usize;
|
|
|
|
self.anim_rect = state.constants.npc.n129_fireball_snake_trail[frame];
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|