This commit is contained in:
aozhiwei 2019-07-18 20:39:32 +08:00
parent dfa635308a
commit 70516badb3
2 changed files with 6 additions and 42 deletions

View File

@ -269,41 +269,6 @@ void Human::RecalcSelfCollider()
self_collider_->rad = meta->i->radius();
}
bool Human::IsCollision()
{
if (room->OverBorder(pos, meta->i->radius())){
return true;
}
std::vector<Entity*> objects;
for (auto& grid : grid_list) {
for (Entity* entity : grid->entity_list) {
switch (entity->entity_type) {
case ET_Obstacle:
{
if (TestCollision(entity)){
objects.push_back(entity);
}
}
break;
case ET_Building:
{
if (TestCollision(entity)) {
objects.push_back(entity);
}
}
break;
default:
{
}
break;
}
}
}
return !objects.empty();
}
bool Human::IsCollisionInMapService()
{
if (room->OverBorder(pos, meta->i->radius())){
@ -341,34 +306,34 @@ void Human::FindPath()
if (std::abs(up_dot) <= 0.001f) { //相互垂直
//向上
pos = old_pos + a8::Vec2::UP;
if (!IsCollision()) {
if (!IsCollisionInMapService()) {
return;
} else {
//向下
pos = old_pos + a8::Vec2::DOWN;
if (!IsCollision()) {
if (!IsCollisionInMapService()) {
return;
}
}
} else if (up_dot > 0.001f) { //基本相同
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
if (!IsCollision()) {
if (!IsCollisionInMapService()) {
return;
} else {
//向上
pos = old_pos + a8::Vec2::UP;
if (!IsCollision()) {
if (!IsCollisionInMapService()) {
return;
}
}
} else if (up_dot < 0.001f) { //基本相反
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
if (!IsCollision()) {
if (!IsCollisionInMapService()) {
return;
} else {
//向下
pos = old_pos + a8::Vec2::DOWN;
if (!IsCollision()) {
if (!IsCollisionInMapService()) {
return;
}
}

View File

@ -135,7 +135,6 @@ class Human : public Entity
void Shot();
void DirectShot(MetaData::Equip* bullet_meta, int skill_id);
void RecalcSelfCollider();
bool IsCollision();
bool IsCollisionInMapService();
void FindPath();
void FindPathInMapService();