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