68 lines
1.3 KiB
C++
68 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "aicomponent.h"
|
|
|
|
enum ZombieState_e
|
|
{
|
|
ZSE_Idle = 0,
|
|
ZSE_Thinking = 1,
|
|
ZSE_Attack = 2,
|
|
ZSE_RandomWalk = 3,
|
|
ZSE_Pursuit = 4
|
|
};
|
|
|
|
class Human;
|
|
class ZombieAINode
|
|
{
|
|
public:
|
|
ZombieState_e main_state = ZSE_Idle;
|
|
long long frameno = 0;
|
|
long long exec_frame_num = 0;
|
|
long long start_shot_frameno = 0;
|
|
long long next_random_move_frameno = 0;
|
|
int shot_times = 0;
|
|
int total_shot_times = 0;
|
|
int next_total_shot_times = 0;
|
|
|
|
long long param1 = 0;
|
|
Human* target = nullptr;
|
|
Human* nearest_human = nullptr;
|
|
long long last_check_nearest_human_frameno = 0;
|
|
a8::Vec2 shot_dir;
|
|
};
|
|
|
|
namespace MetaData
|
|
{
|
|
class AI;
|
|
}
|
|
|
|
class Human;
|
|
class ZombieAI : public AIComponent
|
|
{
|
|
public:
|
|
|
|
virtual ~ZombieAI() override;
|
|
virtual void Update(int delta_time) override;
|
|
float GetAttackRate();
|
|
|
|
private:
|
|
void UpdateAI();
|
|
void UpdateIdle();
|
|
void UpdateThinking();
|
|
void UpdateAttack();
|
|
void UpdateRandomWalk();
|
|
void UpdatePursuit();
|
|
void DoMove();
|
|
void ChangeToState(ZombieState_e to_state);
|
|
void DoShot();
|
|
|
|
Human* GetTarget();
|
|
float GetAttackRange();
|
|
int GetAttackTimes();
|
|
|
|
private:
|
|
MetaData::AI* ai_meta = nullptr;
|
|
ZombieAINode node_;
|
|
bool moving_ = false;
|
|
};
|