修复机器人随机跳伞逻辑

This commit is contained in:
aozhiwei 2019-05-13 17:41:32 +08:00
parent f3e54250fd
commit a1a981775f
2 changed files with 29 additions and 21 deletions

View File

@ -711,13 +711,17 @@ void Room::UpdateGas()
gas_data.gas_start_frameno = frame_no; gas_data.gas_start_frameno = frame_no;
ShuaPlane(); ShuaPlane();
RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid); RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid);
for (size_t i = 1; i < 7; ++i) { int auto_jump_interval = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_interval");
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3 * i, auto_jump_timer_ = xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE * auto_jump_interval,
a8::XParams() a8::XParams()
.SetSender(this), .SetSender(this),
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Room* room = (Room*)param.sender.GetUserData(); Room* room = (Room*)param.sender.GetUserData();
int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num");
int auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num");
int jump_num = a8::RandEx(auto_jump_min_num, auto_jump_max_num);
for (int i = 0; i < jump_num; ++i) {
room->TouchHumanList( room->TouchHumanList(
a8::XParams() a8::XParams()
.SetSender(room), .SetSender(room),
@ -729,11 +733,11 @@ void Room::UpdateGas()
} }
return true; return true;
}); });
}
}, },
&xtimer_attacher.timer_list_); &xtimer_attacher.timer_list_);
} }
} }
}
break; break;
case GasJump: case GasJump:
{ {
@ -794,6 +798,8 @@ void Room::UpdateGas()
gas_data.rad_old = gas_data.old_area_meta->i->rad(); gas_data.rad_old = gas_data.old_area_meta->i->rad();
gas_data.rad_new = gas_data.new_area_meta->i->rad(); gas_data.rad_new = gas_data.new_area_meta->i->rad();
battle_start_frameno_ = frame_no; battle_start_frameno_ = frame_no;
xtimer.DeleteTimer(auto_jump_timer_);
auto_jump_timer_ = nullptr;
} }
} }
break; break;

View File

@ -21,6 +21,7 @@ struct RoomProfile
}; };
struct timer_list; struct timer_list;
struct xtimer_list;
class Entity; class Entity;
class Obstacle; class Obstacle;
class Bullet; class Bullet;
@ -115,6 +116,7 @@ private:
int alive_count_ = 0; int alive_count_ = 0;
MetaData::AirLine* airline_ = nullptr; MetaData::AirLine* airline_ = nullptr;
a8::XTimerAttacher xtimer_attacher; a8::XTimerAttacher xtimer_attacher;
xtimer_list* auto_jump_timer_ = nullptr;
int current_teamid = 0; int current_teamid = 0;
unsigned short current_uniid = 0; unsigned short current_uniid = 0;