1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-17 19:32:43 +00:00
doukutsu-rs/src/game/npc/ai/weapon_trail.rs

102 lines
3.1 KiB
Rust
Raw Normal View History

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-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-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-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(())
}
}