修改gameover问题

This commit is contained in:
aozhiwei 2019-05-06 19:06:45 +08:00
parent 537a7cab4e
commit baedbcfc51
3 changed files with 18 additions and 4 deletions

View File

@ -525,7 +525,13 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
}
}
if (!HasLiveTeammate()) {
SendGameOver();
if (team_members) {
for (auto& member : *team_members) {
member->SendGameOver();
}
} else {
SendGameOver();
}
}
}
}

View File

@ -820,14 +820,12 @@ void Room::UpdateGas()
if (!game_over && alive_count_ <= 1) {
game_over = true;
game_over_frameno = frame_no;
OnGameOver();
}
for (auto& pair : human_hash_) {
if (pair.second->dead) {
continue;
}
if (game_over && game_over_frameno == frame_no) {
pair.second->SendGameOver();
}
bool b1 = CircleContainCircle(gas_data.pos_old,
gas_data.gas_progress,
pair.second->pos,
@ -1055,3 +1053,12 @@ void Room::AddObjectLater(Entity* entity)
add_func,
&entity->xtimer_attacher.timer_list_);
}
void Room::OnGameOver()
{
for (auto& pair : human_hash_) {
if (game_over && game_over_frameno == frame_no) {
pair.second->SendGameOver();
}
}
}

View File

@ -103,6 +103,7 @@ private:
Obstacle* InternalCreateObstacle(int id, float x, float y,
std::function<void (Obstacle*)> on_precreate);
void AddObjectLater(Entity* entity);
void OnGameOver();
private:
timer_list* stats_timer_ = nullptr;