1
This commit is contained in:
parent
d4cd17eaa8
commit
5e95617be7
@ -494,12 +494,23 @@ void AndroidNewAI::UpdateAttack()
|
|||||||
switch (ai_meta->i->attack_type()) {
|
switch (ai_meta->i->attack_type()) {
|
||||||
case kShotClick:
|
case kShotClick:
|
||||||
{
|
{
|
||||||
|
if (ai_meta->i->attack_interval() > 0) {
|
||||||
|
if (myself->room->GetFrameNo() - node_.start_shot_frameno >
|
||||||
|
ai_meta->i->attack_interval() / 100) {
|
||||||
|
//本轮射击结束
|
||||||
|
node_.shot_times = 0;
|
||||||
|
}
|
||||||
|
if (node_.shot_times < ai_meta->i->attack_times()) {
|
||||||
|
DoShotNewAI();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DoShotNewAI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kShotHold:
|
case kShotHold:
|
||||||
{
|
{
|
||||||
|
DoShotNewAI();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -632,3 +643,27 @@ float AndroidNewAI::GetAttackRange()
|
|||||||
attack_range = std::min(500.0f, attack_range);
|
attack_range = std::min(500.0f, attack_range);
|
||||||
return attack_range;
|
return attack_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidNewAI::DoShotNewAI()
|
||||||
|
{
|
||||||
|
Human* myself = (Human*)owner;
|
||||||
|
if (!node_.target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool shot_ok = false;
|
||||||
|
a8::Vec2 shot_dir = node_.target->GetPos() - myself->GetPos();
|
||||||
|
if (std::abs(shot_dir.x) > FLT_EPSILON ||
|
||||||
|
std::abs(shot_dir.y) > FLT_EPSILON) {
|
||||||
|
shot_dir.Normalize();
|
||||||
|
myself->attack_dir = shot_dir;
|
||||||
|
shot_dir.Rotate(ai_meta->i->shot_offset_angle() / 180.0f);
|
||||||
|
myself->Shot(shot_dir, shot_ok);
|
||||||
|
if (shot_ok) {
|
||||||
|
if (node_.shot_times <= 0) {
|
||||||
|
node_.start_shot_frameno = myself->room->GetFrameNo();
|
||||||
|
}
|
||||||
|
++node_.shot_times;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,11 +18,12 @@ public:
|
|||||||
AndroidStateEx_e main_state = ASE_Idle;
|
AndroidStateEx_e main_state = ASE_Idle;
|
||||||
long long frameno = 0;
|
long long frameno = 0;
|
||||||
long long exec_frame_num = 0;
|
long long exec_frame_num = 0;
|
||||||
|
long long start_shot_frameno = 0;
|
||||||
|
int shot_times = 0;
|
||||||
|
|
||||||
long long param1 = 0;
|
long long param1 = 0;
|
||||||
Human* target = nullptr;
|
Human* target = nullptr;
|
||||||
a8::Vec2 shot_dir;
|
a8::Vec2 shot_dir;
|
||||||
int shot_times = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OldAiData
|
struct OldAiData
|
||||||
@ -64,6 +65,7 @@ private:
|
|||||||
void UpdateRandomWalk();
|
void UpdateRandomWalk();
|
||||||
void DoMoveNewAI();
|
void DoMoveNewAI();
|
||||||
void ChangeToStateNewAI(AndroidStateEx_e to_state);
|
void ChangeToStateNewAI(AndroidStateEx_e to_state);
|
||||||
|
void DoShotNewAI();
|
||||||
|
|
||||||
Human* GetTarget();
|
Human* GetTarget();
|
||||||
float GetAttackRange();
|
float GetAttackRange();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user