add walk zone

This commit is contained in:
aozhiwei 2019-06-11 09:24:50 +08:00
parent d9b4ce5554
commit 5669d2d156
2 changed files with 4 additions and 7 deletions

View File

@ -29,6 +29,7 @@ enum HumanStatus
struct xtimer_list; struct xtimer_list;
class CircleCollider; class CircleCollider;
class AabbCollider;
class Obstacle; class Obstacle;
class Human : public Entity class Human : public Entity
{ {
@ -219,6 +220,9 @@ protected:
std::set<Human*> observers_; std::set<Human*> observers_;
Human* follow_target_ = nullptr; Human* follow_target_ = nullptr;
bool follow_synced_active_player = false; bool follow_synced_active_player = false;
AabbCollider* walk_zone = nullptr;
std::set<ColliderComponent*> seen_colliders;
ColliderComponent* last_collider = nullptr;
private: private:
CircleCollider* self_collider_ = nullptr; CircleCollider* self_collider_ = nullptr;

View File

@ -120,17 +120,10 @@ void Player::UpdateMove()
pos = pos + move_dir; pos = pos + move_dir;
if (IsCollision()) { if (IsCollision()) {
pos = old_pos; pos = old_pos;
#if 1
FindPath(); FindPath();
if (rand() % 3 == 0) { if (rand() % 3 == 0) {
i += 1; i += 1;
} }
#else
if (i == 0) {
FindPath();
}
break;
#endif
} }
room->grid_service.MoveHuman(this); room->grid_service.MoveHuman(this);
} }