This commit is contained in:
aozhiwei 2019-05-21 11:38:16 +08:00
parent 1059c468eb
commit e5a55e7703
2 changed files with 20 additions and 13 deletions

View File

@ -178,6 +178,7 @@ void Room::AddPlayer(Player* hum)
while (human_hash_.size() > ROOM_MAX_PLAYER_NUM) { while (human_hash_.size() > ROOM_MAX_PLAYER_NUM) {
RandRemoveAndroid(); RandRemoveAndroid();
} }
NotifyUiUpdate();
} }
unsigned short Room::AllocUniid() unsigned short Room::AllocUniid()
@ -588,19 +589,7 @@ void Room::OnHumanDie(Human* hum)
frame_event.AddExplosionEx(hum, 0, hum->pos, 1); frame_event.AddExplosionEx(hum, 0, hum->pos, 1);
} }
--alive_count_; --alive_count_;
xtimer.AddDeadLineTimerAndAttach(0, NotifyUiUpdate();
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->TouchPlayerList(a8::XParams(),
[] (Player * hum, a8::XParams & param)
{
hum->SendUIUpdate();
});
},
&xtimer_attacher.timer_list_);
} }
bool Room::OverBorder(const Vector2D pos, float radius) bool Room::OverBorder(const Vector2D pos, float radius)
@ -1185,3 +1174,20 @@ void Room::RandRemoveAndroid()
--alive_count_; --alive_count_;
} }
} }
void Room::NotifyUiUpdate()
{
xtimer.AddDeadLineTimerAndAttach(0,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->TouchPlayerList(a8::XParams(),
[] (Player * hum, a8::XParams & param)
{
hum->SendUIUpdate();
});
},
&xtimer_attacher.timer_list_);
}

View File

@ -110,6 +110,7 @@ private:
void AddObjectLater(Entity* entity); void AddObjectLater(Entity* entity);
void OnGameOver(); void OnGameOver();
void RandRemoveAndroid(); void RandRemoveAndroid();
void NotifyUiUpdate();
private: private:
timer_list* stats_timer_ = nullptr; timer_list* stats_timer_ = nullptr;