feat: implemented RiflemanFireState
This commit is contained in:
parent
f7ce254249
commit
0b77797943
2 changed files with 18 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "enemy_rifleman.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "wave_survival/npc_unit.h"
|
||||
#include "wave_survival/player_detector.h"
|
||||
#include "wave_survival/state_machine.h"
|
||||
|
|
@ -39,6 +40,19 @@ String RiflemanPatrolState::get_next_state() const {
|
|||
|
||||
String RiflemanChaseState::get_next_state() const {
|
||||
if (get_body()->get_detector()->line_of_sight_exists()) {
|
||||
return RiflemanFireState::get_class_static();
|
||||
}
|
||||
return get_class();
|
||||
}
|
||||
|
||||
void RiflemanFireState::enter_state() {
|
||||
get_anim()->play("fire");
|
||||
get_target()->set_movement_direction(Vector2());
|
||||
}
|
||||
|
||||
String RiflemanFireState::get_next_state() const {
|
||||
if (get_anim()->get_current_animation().is_empty()) {
|
||||
return RiflemanFireState::get_class_static();
|
||||
}
|
||||
return get_class();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ public:
|
|||
class RiflemanFireState : public RiflemanState {
|
||||
GDCLASS(RiflemanFireState, RiflemanState);
|
||||
static void _bind_methods() {}
|
||||
|
||||
public:
|
||||
void enter_state() override;
|
||||
String get_next_state() const override;
|
||||
};
|
||||
|
||||
#endif // !ENEMY_RIFLEMAN_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue