game2006/server/gameserver/android_agent.cc
aozhiwei bd56f2c193 1
2022-12-06 10:54:27 +08:00

76 lines
1.6 KiB
C++

#include "precompile.h"
#include "android_agent.h"
#include "android.h"
#include "room.h"
AndroidAgent::AndroidAgent()
{
}
AndroidAgent::~AndroidAgent()
{
}
State_e AndroidAgent::GetState()
{
return kPreBattle;
}
behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time)
{
if (status_ == behaviac::BT_RUNNING) {
return status_runing_cb_();
}
int idle_time = a8::RandEx(min_time, max_time);
xtimer_list* timer = GetOwner()->room->xtimer.AddDeadLineTimerAndAttach
(
idle_time / FRAME_RATE_MS,
a8::XParams(),
[] (const a8::XParams& param)
{
},
&GetOwner()->xtimer_attacher.timer_list_);
std::weak_ptr<a8::XTimerPtr> timer_ptr = GetOwner()->room->xtimer.GetTimerPtr(timer);
status_runing_cb_ =
[timer_ptr] ()
{
if (timer_ptr.lock()) {
return behaviac::BT_RUNNING;
} else {
return behaviac::BT_SUCCESS;
}
};
return behaviac::BT_RUNNING;
}
behaviac::EBTStatus AndroidAgent::DoRandomWalk()
{
if (status_ == behaviac::BT_RUNNING) {
return status_runing_cb_();
}
a8::Vec2 dir = GetOwner()->GetMoveDir();
dir.Rotate((10 + rand() % 360)/ 180.0f);
dir.Normalize();
GetOwner()->GetMoveHelper()->CalcTargetPos(500);
status_runing_cb_ =
[] ()
{
return behaviac::BT_SUCCESS;
};
return behaviac::BT_SUCCESS;
}
behaviac::EBTStatus AndroidAgent::DoRandomShot()
{
return behaviac::BT_SUCCESS;
}
behaviac::EBTStatus AndroidAgent::DoAttack()
{
return behaviac::BT_SUCCESS;
}