This commit is contained in:
aozhiwei 2019-09-10 18:53:39 +08:00
parent 40fb1b60ad
commit ecce9ffa0a

View File

@ -1274,7 +1274,7 @@ void Room::InitAirDrop()
void Room::AirDrop(int appear_time, int box_id)
{
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(box_id);
if (thing_meta) {
if (thing_meta && thing_meta->i->type() == 2) {
a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle());
a8::Vec2 box_pos = gas_data.pos_new + dir * (500 + rand() % 300);
@ -1305,6 +1305,13 @@ void Room::AirDrop(int appear_time, int box_id)
box_pos.x = new_x;
box_pos.y = new_y;
}
if (box_pos.x + thing_meta->i->width()/2 + 2 > map_meta->i->map_width() ||
box_pos.x - thing_meta->i->width()/2 - 2 < 1 ||
box_pos.y + thing_meta->i->height()/2 + 2 > map_meta->i->map_height() ||
box_pos.y - thing_meta->i->height()/2 - 2 < 1
) {
return;
}
frame_event.AddAirDrop(appear_time, box_id, box_pos);
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * appear_time / 1000.f,
a8::XParams()