This commit is contained in:
aozhiwei 2023-10-13 17:23:32 +08:00
parent 949c532867
commit 41c2b17f77
2 changed files with 22 additions and 7 deletions

View File

@ -6,8 +6,12 @@
#include "room.h" #include "room.h"
#include "movement.h" #include "movement.h"
#include "netdata.h" #include "netdata.h"
#include "glmhelper.h"
#include "target_agent.h"
#include "weapon.h"
#include "mt/Hero.h" #include "mt/Hero.h"
#include "mt/Equip.h"
HeroAgent::HeroAgent():BaseAgent() HeroAgent::HeroAgent():BaseAgent()
{ {
@ -126,12 +130,12 @@ int HeroAgent::GetBattleTimes()
void HeroAgent::SetMoveDir(const glm::vec3& dir) void HeroAgent::SetMoveDir(const glm::vec3& dir)
{ {
owner_->SetMoveDir(dir);
} }
void HeroAgent::SetAttackDir(const glm::vec3& dir) void HeroAgent::SetAttackDir(const glm::vec3& dir)
{ {
owner_->SetAttackDir(dir);
} }
void HeroAgent::ShotNormal(const glm::vec3& dir) void HeroAgent::ShotNormal(const glm::vec3& dir)
@ -146,22 +150,32 @@ void HeroAgent::ShotTrace()
glm::vec3 HeroAgent::GetRandomDir() glm::vec3 HeroAgent::GetRandomDir()
{ {
glm::vec3 dir = owner_->GetMoveDir();
GlmHelper::RotateY(dir, (10 + rand() % 360)/ 180.0f);
return dir;
} }
glm::vec3 HeroAgent::GetTargetDir() glm::vec3 HeroAgent::GetTargetDir()
{ {
if (current_target_agent->IsValid()) {
return owner_->GetMoveDir();
}
glm::vec3 dir = current_target_agent->GetPos() - owner_->GetPos().ToGlmVec3();
GlmHelper::Normalize(dir);
return dir;
} }
glm::vec3 HeroAgent::RandomPoint(float range) glm::vec3 HeroAgent::RandomPoint(float range)
{ {
abort();
} }
float HeroAgent::GetShotRange() float HeroAgent::GetShotRange()
{ {
if (owner_->GetCurrWeapon()) {
return owner_->GetCurrWeapon()->meta->range();
}
return 0.0f;
} }
void HeroAgent::SetV(int id, int val) void HeroAgent::SetV(int id, int val)

View File

@ -5,6 +5,7 @@
class Hero; class Hero;
class RoomAgent; class RoomAgent;
class TeamAgent; class TeamAgent;
class TargetAgent;
class HeroAgent : public BaseAgent class HeroAgent : public BaseAgent
{ {
public: public:
@ -65,7 +66,7 @@ public:
RoomAgent* room_agent = nullptr; RoomAgent* room_agent = nullptr;
TeamAgent* team_agent = nullptr; TeamAgent* team_agent = nullptr;
HeroAgent* master_agent = nullptr; HeroAgent* master_agent = nullptr;
HeroAgent* current_target_agent = nullptr; TargetAgent* current_target_agent = nullptr;
float task_param0 = 0.0f; float task_param0 = 0.0f;
float task_param1 = 0.0f; float task_param1 = 0.0f;
float task_param2 = 0.0f; float task_param2 = 0.0f;