This commit is contained in:
aozhiwei 2020-07-28 16:52:33 +08:00
parent 2f8844344e
commit 3652d1e436
3 changed files with 72 additions and 38 deletions

View File

@ -1318,7 +1318,7 @@ void Room::InitAirDrop()
{ {
Room* room = (Room*)param.sender.GetUserData(); Room* room = (Room*)param.sender.GetUserData();
if (!room->IsGameOver()) { if (!room->IsGameOver()) {
room->AirDrop(param.param1, param.param2); room->AirDrop(param.param1, param.param2, param.param3);
} }
}, },
&xtimer_attacher_.timer_list_); &xtimer_attacher_.timer_list_);
@ -1328,7 +1328,8 @@ void Room::InitAirDrop()
std::list<MetaData::AirDrop>& air_drops = MetaMgr::Instance()->GetAirDrops(); std::list<MetaData::AirDrop>& air_drops = MetaMgr::Instance()->GetAirDrops();
for (auto& air_drop : air_drops) { for (auto& air_drop : air_drops) {
if (air_drop.i->id() >= 1 && air_drop.i->id() <= 6) { if (air_drop.i->id() >= 1 && air_drop.i->id() <= 6) {
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * air_drop.i->time(), xtimer.AddDeadLineTimerAndAttach
(SERVER_FRAME_RATE * air_drop.i->time(),
a8::XParams() a8::XParams()
.SetSender(this) .SetSender(this)
.SetParam1(air_drop.i->appear_time()) .SetParam1(air_drop.i->appear_time())
@ -1338,7 +1339,7 @@ void Room::InitAirDrop()
{ {
Room* room = (Room*)param.sender.GetUserData(); Room* room = (Room*)param.sender.GetUserData();
if (!room->IsGameOver()) { if (!room->IsGameOver()) {
room->AirDrop(param.param1, param.param2); room->AirDrop(param.param1, param.param2, param.param3);
} }
}, },
&xtimer_attacher_.timer_list_); &xtimer_attacher_.timer_list_);
@ -1347,7 +1348,7 @@ void Room::InitAirDrop()
} }
} }
void Room::AirDrop(int appear_time, int box_id) void Room::AirDrop(int appear_time, int box_id, int airdrop_id)
{ {
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(box_id); MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(box_id);
if (room_type_ == RT_NewBrid && if (room_type_ == RT_NewBrid &&
@ -1359,8 +1360,8 @@ void Room::AirDrop(int appear_time, int box_id)
} }
} }
if (GetRoomMode() == kZombieMode) { if (GetRoomMode() == kZombieMode) {
for (auto& pair : accountid_hash_) { if (airdrop_id != map_meta_->i->terminator_airdrop()) {
pair.second->SendShowCountdown("距离物资箱抵达还有%d秒", appear_time / 1000); NotifyCountdown("距离物资箱抵达还有%d秒", appear_time / 1000);
} }
} }
if (thing_meta && thing_meta->i->type() == 2) { if (thing_meta && thing_meta->i->type() == 2) {
@ -1403,22 +1404,38 @@ void Room::AirDrop(int appear_time, int box_id)
return; return;
} }
frame_event.AddAirDrop(appear_time, box_id, box_pos); frame_event.AddAirDrop(appear_time, box_id, box_pos);
xtimer. xtimer.AddDeadLineTimerAndAttach
AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * appear_time / 1000.f, (SERVER_FRAME_RATE * appear_time / 1000.f,
a8::XParams() a8::XParams()
.SetSender(this) .SetSender(this)
.SetParam1(box_id) .SetParam1(a8::MakeInt64(airdrop_id, box_id))
.SetParam2(box_pos.x) .SetParam2(box_pos.x)
.SetParam3(box_pos.y), .SetParam3(box_pos.y),
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Room* room = (Room*)param.sender.GetUserData(); Room* room = (Room*)param.sender.GetUserData();
if (!room->IsGameOver()) { if (!room->IsGameOver()) {
RoomObstacle* obstacle = room-> int airdrop_id = a8::Low32(param.param1.GetInt());
CreateObstacle(param.param1.GetInt(), int box_id = a8::High32(param.param1.GetInt());
RoomObstacle* obstacle = room->CreateObstacle
(
box_id,
param.param2.GetDouble(), param.param2.GetDouble(),
param.param3.GetDouble()); param.param3.GetDouble()
);
obstacle->is_treasure_box = true; obstacle->is_treasure_box = true;
if (room->GetRoomMode() == kZombieMode) {
obstacle->is_terminator_airdrop_box =
airdrop_id == room->map_meta_->i->terminator_airdrop();
if (obstacle->is_terminator_airdrop_box) {
room->NotifySysPiao
(
"终结者补给箱已送达",
a8::MkRgb(0, 255, 0),
3
);
}
}
} }
}, },
&xtimer_attacher_.timer_list_); &xtimer_attacher_.timer_list_);
@ -3155,6 +3172,20 @@ void Room::RemoveRescue(Human* hum)
} }
} }
void Room::NotifyCountdown(const std::string& msg, int time)
{
for (auto& pair : accountid_hash_) {
pair.second->SendShowCountdown(msg, time);
}
}
void Room::NotifySysPiao(const std::string& msg, int color, int duration)
{
for (auto& pair : accountid_hash_) {
pair.second->SendSysPiaoMsg(msg, color, duration);
}
}
size_t Room::GetRoomMaxPlayerNum() size_t Room::GetRoomMaxPlayerNum()
{ {
if (room_mode_ == kZombieMode) { if (room_mode_ == kZombieMode) {

View File

@ -135,6 +135,8 @@ public:
bool IsMiniRoom(); bool IsMiniRoom();
void FillObjectPositions(Human* hum, cs::SMUpdate& msg); void FillObjectPositions(Human* hum, cs::SMUpdate& msg);
void RemoveRescue(Human* hum); void RemoveRescue(Human* hum);
void NotifyCountdown(const std::string& msg, int time);
void NotifySysPiao(const std::string& msg, int color, int duration);
private: private:
int AllocUniid(); int AllocUniid();
@ -149,7 +151,7 @@ private:
a8::Vec2& out_pos); a8::Vec2& out_pos);
void MatchTeam(Human* hum); void MatchTeam(Human* hum);
void CombineTeam(); void CombineTeam();
void AirDrop(int appear_time, int box_id); void AirDrop(int appear_time, int box_id, int airdrop_id);
void AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos); void AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos);
void ShuaPlane(); void ShuaPlane();
int NewTeam(); int NewTeam();

View File

@ -8,6 +8,7 @@ class RoomObstacle : public Obstacle
Room* room = nullptr; Room* room = nullptr;
a8::XTimerAttacher xtimer_attacher; a8::XTimerAttacher xtimer_attacher;
bool is_treasure_box = false; bool is_treasure_box = false;
bool is_terminator_airdrop_box = false;
virtual ~RoomObstacle() override; virtual ~RoomObstacle() override;
virtual void Initialize() override; virtual void Initialize() override;