1
This commit is contained in:
parent
b774a1030f
commit
bc99e625bc
@ -16,6 +16,9 @@ void AndroidAI::Update(int delta_time)
|
||||
if (hum->poisoning) {
|
||||
hum->UpdatePoisoning();
|
||||
}
|
||||
if (hum->dead) {
|
||||
return;
|
||||
}
|
||||
switch (state) {
|
||||
case AS_thinking:
|
||||
{
|
||||
@ -81,35 +84,21 @@ void AndroidAI::ChangeToState(AndroidState_e to_state)
|
||||
|
||||
void AndroidAI::DoMove()
|
||||
{
|
||||
#if 1
|
||||
Human* hum = (Human*)owner;
|
||||
int speed = std::max(1, (int)hum->GetSpeed());
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = hum->pos;
|
||||
hum->pos = hum->pos + hum->move_dir;
|
||||
if (hum->IsCollision()) {
|
||||
hum->pos = old_pos;
|
||||
if (i == 0) {
|
||||
hum->FindPath();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (owner->movement) {
|
||||
if (owner->movement->Arrived()) {
|
||||
float distance = 8.0f + rand() % 10;
|
||||
Vector2D out_pos;
|
||||
if (owner->room->RandomPos((Human*)owner, distance, out_pos)) {
|
||||
Human* hum = (Human*)owner;
|
||||
hum->movement->ClearPath();
|
||||
hum->movement->AddPathPoint(out_pos, distance, owner->GetSpeed());
|
||||
hum->attack_dir = out_pos - owner->pos;
|
||||
hum->attack_dir.Normalize();
|
||||
if (owner->updated_times % 2 == 0) {
|
||||
Human* hum = (Human*)owner;
|
||||
int speed = std::max(1, (int)hum->GetSpeed());
|
||||
for (int i = 0; i < speed; ++i) {
|
||||
Vector2D old_pos = hum->pos;
|
||||
hum->pos = hum->pos + hum->move_dir;
|
||||
if (hum->IsCollision()) {
|
||||
hum->pos = old_pos;
|
||||
if (i == 0) {
|
||||
hum->FindPath();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AndroidAI::DoAttack()
|
||||
|
@ -629,17 +629,17 @@ void Room::UpdateGas()
|
||||
if (pair.second->dead) {
|
||||
continue;
|
||||
}
|
||||
if (!CircleContainCircle(gas_data.pos_old,
|
||||
gas_data.rad_old,
|
||||
pair.second->pos,
|
||||
pair.second->GetRadius()
|
||||
) &&
|
||||
!CircleContainCircle(gas_data.pos_new,
|
||||
gas_data.rad_new,
|
||||
pair.second->pos,
|
||||
pair.second->GetRadius()
|
||||
)
|
||||
) {
|
||||
bool b1 = CircleContainCircle(gas_data.pos_old,
|
||||
gas_data.rad_old,
|
||||
pair.second->pos,
|
||||
pair.second->GetRadius()
|
||||
);
|
||||
bool b2 = CircleContainCircle(gas_data.pos_new,
|
||||
gas_data.rad_new,
|
||||
pair.second->pos,
|
||||
pair.second->GetRadius()
|
||||
);
|
||||
if (!b1 && !b2) {
|
||||
pair.second->poisoning = true;
|
||||
} else {
|
||||
pair.second->poisoning = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user