1
This commit is contained in:
parent
e47bcdd646
commit
cda47bc442
@ -641,7 +641,19 @@ namespace MetaData
|
|||||||
|
|
||||||
void AirRaid::Init()
|
void AirRaid::Init()
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->raid_wave(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
std::vector<std::string> strings2;
|
||||||
|
a8::Split(str, strings2, ':');
|
||||||
|
raid_waves.push_back(std::make_tuple(
|
||||||
|
a8::XValue(strings2[0]).GetInt(),
|
||||||
|
a8::XValue(strings2[1]).GetInt()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirLine::Init()
|
void AirLine::Init()
|
||||||
|
@ -171,6 +171,7 @@ namespace MetaData
|
|||||||
struct AirRaid
|
struct AirRaid
|
||||||
{
|
{
|
||||||
const metatable::AirRaid* i = nullptr;
|
const metatable::AirRaid* i = nullptr;
|
||||||
|
std::vector<std::tuple<int, int>> raid_waves;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
@ -3943,6 +3943,9 @@ void Room::AirRaid(int airraid_id)
|
|||||||
frame_event.AddAirRaid(raid_meta->i->appear_time(), center, raid_meta->i->rad());
|
frame_event.AddAirRaid(raid_meta->i->appear_time(), center, raid_meta->i->rad());
|
||||||
|
|
||||||
auto raid_cb =
|
auto raid_cb =
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
auto bomb_cb =
|
||||||
[] (const a8::XParams& param)
|
[] (const a8::XParams& param)
|
||||||
{
|
{
|
||||||
Room* room = (Room*)param.sender.GetUserData();
|
Room* room = (Room*)param.sender.GetUserData();
|
||||||
@ -3955,7 +3958,6 @@ void Room::AirRaid(int airraid_id)
|
|||||||
param.param2.GetDouble(),
|
param.param2.GetDouble(),
|
||||||
param.param3.GetDouble()
|
param.param3.GetDouble()
|
||||||
);
|
);
|
||||||
for (int i = 0; i < raid_meta->i->bomb_num(); ++i) {
|
|
||||||
a8::Vec2 dir = a8::Vec2::UP;
|
a8::Vec2 dir = a8::Vec2::UP;
|
||||||
dir.Rotate(a8::RandAngle());
|
dir.Rotate(a8::RandAngle());
|
||||||
a8::Vec2 pos = center + dir * (50 + rand() % 100);;
|
a8::Vec2 pos = center + dir * (50 + rand() % 100);;
|
||||||
@ -3966,11 +3968,26 @@ void Room::AirRaid(int airraid_id)
|
|||||||
pos.y
|
pos.y
|
||||||
);
|
);
|
||||||
obstacle->Active();
|
obstacle->Active();
|
||||||
if (obstacle) {
|
};
|
||||||
|
Room* room = (Room*)param.sender.GetUserData();
|
||||||
|
if (room->IsGameOver()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MetaData::AirRaid* raid_meta = (MetaData::AirRaid*)param.param1.GetUserData();
|
||||||
|
for (auto& tuple : raid_meta->raid_waves) {
|
||||||
|
int num = std::get<0>(tuple);
|
||||||
|
int delay = std::get<1>(tuple);
|
||||||
|
for (int i = 0; i < num; ++i) {
|
||||||
|
room->xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(delay / FRAME_RATE_MS,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(room)
|
||||||
|
.SetParam1(raid_meta)
|
||||||
|
.SetParam2(param.param2.GetDouble())
|
||||||
|
.SetParam3(param.param3.GetDouble()),
|
||||||
|
bomb_cb,
|
||||||
|
&room->xtimer_attacher_.timer_list_);
|
||||||
}
|
}
|
||||||
#if 1
|
|
||||||
room->BroadcastDebugMsg(a8::Format("airraid pos=%d:%d", {pos.x, pos.y}));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ message AirRaid
|
|||||||
optional int32 time = 2;
|
optional int32 time = 2;
|
||||||
optional int32 appear_time = 3;
|
optional int32 appear_time = 3;
|
||||||
optional int32 bomb_id = 4;
|
optional int32 bomb_id = 4;
|
||||||
optional int32 bomb_num = 5;
|
optional string raid_wave = 5;
|
||||||
optional float rad = 6;
|
optional float rad = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user