1
This commit is contained in:
parent
d4b03e49ba
commit
befa38e799
@ -769,74 +769,21 @@ void Room::OnHumanRevive(Human* hum)
|
|||||||
|
|
||||||
bool Room::OverBorder(const Position& pos, float radius)
|
bool Room::OverBorder(const Position& pos, float radius)
|
||||||
{
|
{
|
||||||
CircleCollider collider;
|
{
|
||||||
collider.pos.x = pos.x;
|
if (pos.GetX() - radius < 0.0001f) {
|
||||||
collider.pos.y = pos.z;
|
return true;
|
||||||
collider.rad = radius;
|
|
||||||
return OverBorder(pos, &collider);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Room::OverBorder(const Position& pos, ColliderComponent* collider)
|
|
||||||
{
|
|
||||||
switch (collider->type) {
|
|
||||||
case CT_Aabb:
|
|
||||||
{
|
|
||||||
AabbCollider* aabb_box = (AabbCollider*)collider;
|
|
||||||
//检查x轴
|
|
||||||
{
|
|
||||||
float left_x = (pos.ToVec2() + aabb_box->_min).x;
|
|
||||||
if (left_x < 0.001f) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
float right_x = (pos.ToVec2() + aabb_box->_max).x;
|
|
||||||
if (right_x > map_meta_->map_width()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//检查y轴
|
|
||||||
{
|
|
||||||
float down_y = (pos.ToVec2() + aabb_box->_min).y;
|
|
||||||
if (down_y < 0.001f) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
float up_y = (pos.ToVec2() + aabb_box->_max).y;
|
|
||||||
if (up_y > map_meta_->map_height()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
if (pos.GetX() + radius > map_meta_->map_width()) {
|
||||||
case CT_Circle:
|
return true;
|
||||||
{
|
|
||||||
CircleCollider* circle_collider = (CircleCollider*)collider;
|
|
||||||
//检查x轴
|
|
||||||
{
|
|
||||||
float left_x = pos.x - circle_collider->rad;
|
|
||||||
if (left_x < 0.001f) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
float right_x = pos.x + circle_collider->rad;
|
|
||||||
if (right_x > map_meta_->map_width()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//检查y轴
|
|
||||||
{
|
|
||||||
float down_y = pos.y - circle_collider->rad;
|
|
||||||
if (down_y < 0.001f) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
float up_y = pos.y + circle_collider->rad;
|
|
||||||
if (up_y > map_meta_->map_height()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
{
|
||||||
{
|
if (pos.GetZ() - radius < 0.0001f) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pos.GetZ() + radius > map_meta_->map_height()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,6 @@ public:
|
|||||||
void OnHumanDie(Human* hum);
|
void OnHumanDie(Human* hum);
|
||||||
void OnHumanRevive(Human* hum);
|
void OnHumanRevive(Human* hum);
|
||||||
bool OverBorder(const Position& pos, float radius);
|
bool OverBorder(const Position& pos, float radius);
|
||||||
bool OverBorder(const Position& pos, ColliderComponent* collider);
|
|
||||||
Human* GetWatchWarTarget(Human* hum);
|
Human* GetWatchWarTarget(Human* hum);
|
||||||
bool BattleStarted();
|
bool BattleStarted();
|
||||||
int GetTeamNum();
|
int GetTeamNum();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user