1
This commit is contained in:
parent
dfa635308a
commit
70516badb3
@ -269,41 +269,6 @@ void Human::RecalcSelfCollider()
|
|||||||
self_collider_->rad = meta->i->radius();
|
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()
|
bool Human::IsCollisionInMapService()
|
||||||
{
|
{
|
||||||
if (room->OverBorder(pos, meta->i->radius())){
|
if (room->OverBorder(pos, meta->i->radius())){
|
||||||
@ -341,34 +306,34 @@ void Human::FindPath()
|
|||||||
if (std::abs(up_dot) <= 0.001f) { //相互垂直
|
if (std::abs(up_dot) <= 0.001f) { //相互垂直
|
||||||
//向上
|
//向上
|
||||||
pos = old_pos + a8::Vec2::UP;
|
pos = old_pos + a8::Vec2::UP;
|
||||||
if (!IsCollision()) {
|
if (!IsCollisionInMapService()) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
//向下
|
//向下
|
||||||
pos = old_pos + a8::Vec2::DOWN;
|
pos = old_pos + a8::Vec2::DOWN;
|
||||||
if (!IsCollision()) {
|
if (!IsCollisionInMapService()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (up_dot > 0.001f) { //基本相同
|
} else if (up_dot > 0.001f) { //基本相同
|
||||||
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
|
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
|
||||||
if (!IsCollision()) {
|
if (!IsCollisionInMapService()) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
//向上
|
//向上
|
||||||
pos = old_pos + a8::Vec2::UP;
|
pos = old_pos + a8::Vec2::UP;
|
||||||
if (!IsCollision()) {
|
if (!IsCollisionInMapService()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (up_dot < 0.001f) { //基本相反
|
} else if (up_dot < 0.001f) { //基本相反
|
||||||
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
|
pos = old_pos + (at_left_side ? a8::Vec2::LEFT : a8::Vec2::RIGHT);
|
||||||
if (!IsCollision()) {
|
if (!IsCollisionInMapService()) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
//向下
|
//向下
|
||||||
pos = old_pos + a8::Vec2::DOWN;
|
pos = old_pos + a8::Vec2::DOWN;
|
||||||
if (!IsCollision()) {
|
if (!IsCollisionInMapService()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,6 @@ class Human : public Entity
|
|||||||
void Shot();
|
void Shot();
|
||||||
void DirectShot(MetaData::Equip* bullet_meta, int skill_id);
|
void DirectShot(MetaData::Equip* bullet_meta, int skill_id);
|
||||||
void RecalcSelfCollider();
|
void RecalcSelfCollider();
|
||||||
bool IsCollision();
|
|
||||||
bool IsCollisionInMapService();
|
bool IsCollisionInMapService();
|
||||||
void FindPath();
|
void FindPath();
|
||||||
void FindPathInMapService();
|
void FindPathInMapService();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user