gameover ok
This commit is contained in:
parent
feef53a8b8
commit
0c2d2fe0bf
@ -78,7 +78,10 @@ void Bullet::OnHit(std::vector<Entity*>& objects)
|
||||
switch (target->entity_type) {
|
||||
case ET_Player:
|
||||
{
|
||||
|
||||
Human* hum = (Human*)target;
|
||||
if (!hum->dead) {
|
||||
hum->DecHP(10, 0, "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ET_Obstacle:
|
||||
|
@ -264,7 +264,7 @@ void Human::UpdatePoisoning()
|
||||
health = std::max(0.0f, health - room->gas_data.old_area_meta->i->hurt());
|
||||
}
|
||||
if (health <= 0.0f) {
|
||||
dead = true;
|
||||
BeKill(-1, "安全区");
|
||||
downed = true;
|
||||
poisoning_time = 0;
|
||||
break;
|
||||
@ -376,8 +376,22 @@ void Human::FillSMGameOver(cs::SMGameOver& msg)
|
||||
|
||||
void Human::BeKill(int killer_id, const std::string& killer_name)
|
||||
{
|
||||
stats.killer_id = killer_id;
|
||||
stats.killer_name = killer_name;
|
||||
dead = true;
|
||||
health = 0.0f;
|
||||
if (!dead) {
|
||||
stats.killer_id = killer_id;
|
||||
stats.killer_name = killer_name;
|
||||
dead = true;
|
||||
health = 0.0f;
|
||||
dead_frameno = room->frame_no;
|
||||
send_gameover = true;
|
||||
--room->alive_count_;
|
||||
SyncAroundPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name)
|
||||
{
|
||||
health = std::min(0.0f, health - dec_hp);
|
||||
if (health <= 0.0001f) {
|
||||
BeKill(killer_id, killer_name);
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,8 @@ class Human : public Entity
|
||||
HumanFrameData frame_data;
|
||||
PlayerStats stats;
|
||||
|
||||
bool send_gameover = false;
|
||||
|
||||
std::set<Entity*> new_objects;
|
||||
std::set<Entity*> part_objects;
|
||||
|
||||
@ -112,6 +114,7 @@ class Human : public Entity
|
||||
void ResetAction();
|
||||
void FillSMGameOver(cs::SMGameOver& msg);
|
||||
void BeKill(int killer_id, const std::string& killer_name);
|
||||
void DecHP(float dec_hp, int killer_id, const std::string& killer_name);
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
|
@ -77,6 +77,9 @@ void Player::Update(int delta_time)
|
||||
}
|
||||
MakeUpdateMsg();
|
||||
SendNotifyMsg(*update_msg);
|
||||
if (send_gameover) {
|
||||
UpdateGameOver();
|
||||
}
|
||||
{
|
||||
if (!new_objects.empty()) {
|
||||
new_objects.clear();
|
||||
@ -254,13 +257,18 @@ void Player::UpdateUseItemIdx()
|
||||
|
||||
void Player::UpdateSpectate()
|
||||
{
|
||||
stats.killer_id = entity_uniid;
|
||||
stats.killer_name = name;
|
||||
dead = true;
|
||||
health = 0.0f;
|
||||
BeKill(entity_uniid, name);
|
||||
spectate = false;
|
||||
}
|
||||
|
||||
void Player::UpdateGameOver()
|
||||
{
|
||||
cs::SMGameOver msg;
|
||||
FillSMGameOver(msg);
|
||||
SendNotifyMsg(msg);
|
||||
send_gameover = false;
|
||||
}
|
||||
|
||||
void Player::Shot()
|
||||
{
|
||||
if (!curr_weapon->meta) {
|
||||
|
@ -77,6 +77,7 @@ class Player : public Human
|
||||
void UpdateCancelAction();
|
||||
void UpdateUseItemIdx();
|
||||
void UpdateSpectate();
|
||||
void UpdateGameOver();
|
||||
void Shot();
|
||||
void ProcInteraction();
|
||||
void ObstacleInteraction(Obstacle* entity);
|
||||
|
@ -24,4 +24,5 @@ enum SMMessageId_e
|
||||
_SMPickup = 1006;
|
||||
_SMVoiceNotify = 1007;
|
||||
_SMDisconnectNotify = 1008;
|
||||
_SMGameOver = 1009;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ message MFPlayerStats
|
||||
optional int32 score = 11; //积分
|
||||
|
||||
optional bool dead = 5; //是否已死亡
|
||||
optional int32 killer_id = 7; //杀手id(自杀时为自己)
|
||||
optional int32 killer_id = 7; //杀手id(自杀时为自己) 特殊id: -1:倒在安全区
|
||||
optional string killer_name = 40; //杀手名称
|
||||
|
||||
optional string account_id = 21; //账号id
|
||||
|
Loading…
x
Reference in New Issue
Block a user