1
This commit is contained in:
parent
5934c83a63
commit
d3968caba5
@ -51,44 +51,7 @@ void AirRaid::Exec(int airraid_id)
|
||||
if (room_->IsGameOver()) {
|
||||
return;
|
||||
}
|
||||
for (auto& tuple : raid_meta->_raid_waves) {
|
||||
int num = std::get<0>(tuple);
|
||||
int delay = std::get<1>(tuple);
|
||||
glm::vec3 born_pos = center;
|
||||
|
||||
auto bomb_cb =
|
||||
[this, raid_meta, num, delay, born_pos]
|
||||
(int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
if (room_->IsGameOver()) {
|
||||
return;
|
||||
}
|
||||
glm::vec3 dir = GlmHelper::UP;
|
||||
GlmHelper::RotateY(dir, a8::RandAngle());
|
||||
glm::vec3 pos = born_pos + dir * (50.0f + rand() % 100);
|
||||
if (room_->grid_service->CanAdd(pos.x, pos.y)) {
|
||||
for (auto bomb_id : raid_meta->_bomb_ids) {
|
||||
RoomObstacle* obstacle = room_->CreateObstacle
|
||||
(
|
||||
bomb_id,
|
||||
pos.x,
|
||||
pos.y,
|
||||
pos.z
|
||||
);
|
||||
obstacle->Active();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < num; ++i) {
|
||||
room_->xtimer.SetTimeoutEx
|
||||
(delay / FRAME_RATE_MS,
|
||||
bomb_cb,
|
||||
&room_->xtimer_attacher_);
|
||||
}
|
||||
}
|
||||
ExecOneRoundAirRaid(raid_meta, center);
|
||||
};
|
||||
|
||||
room_->xtimer.SetTimeoutEx
|
||||
@ -124,3 +87,45 @@ bool AirRaid::GenAirRaidPos(const mt::AirRaid* raid_meta, glm::vec3& center)
|
||||
}
|
||||
room_->frame_event.AddAirRaid(raid_meta->appear_time(), center, raid_meta->rad());
|
||||
}
|
||||
|
||||
void AirRaid::ExecOneRoundAirRaid(const mt::AirRaid* raid_meta, const glm::vec3& pos)
|
||||
{
|
||||
for (auto& tuple : raid_meta->_raid_waves) {
|
||||
int num = std::get<0>(tuple);
|
||||
int delay = std::get<1>(tuple);
|
||||
glm::vec3 born_pos = pos;
|
||||
|
||||
auto bomb_cb =
|
||||
[this, raid_meta, num, delay, born_pos]
|
||||
(int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
if (room_->IsGameOver()) {
|
||||
return;
|
||||
}
|
||||
glm::vec3 dir = GlmHelper::UP;
|
||||
GlmHelper::RotateY(dir, a8::RandAngle());
|
||||
glm::vec3 pos = born_pos + dir * (50.0f + rand() % 100);
|
||||
if (room_->grid_service->CanAdd(pos.x, pos.y)) {
|
||||
for (auto bomb_id : raid_meta->_bomb_ids) {
|
||||
RoomObstacle* obstacle = room_->CreateObstacle
|
||||
(
|
||||
bomb_id,
|
||||
pos.x,
|
||||
pos.y,
|
||||
pos.z
|
||||
);
|
||||
obstacle->Active();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < num; ++i) {
|
||||
room_->xtimer.SetTimeoutEx
|
||||
(delay / FRAME_RATE_MS,
|
||||
bomb_cb,
|
||||
&room_->xtimer_attacher_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ class AirRaid
|
||||
|
||||
void Exec(int airraid_id);
|
||||
bool GenAirRaidPos(const mt::AirRaid* raid_meta, glm::vec3& center);
|
||||
void ExecOneRoundAirRaid(const mt::AirRaid* raid_meta, const glm::vec3& pos);
|
||||
|
||||
private:
|
||||
Room* room_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user