添加击杀统计

This commit is contained in:
aozhiwei 2019-07-22 17:30:34 +08:00
parent 50cbf2f3e9
commit 807b8d79d7
5 changed files with 35 additions and 5 deletions

View File

@ -463,7 +463,8 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
Entity* entity = room->GetEntityByUniId(killer_id);
if (entity && entity->entity_type == kET_Player) {
Human* killer = (Human*)entity;
killer->stats.dead_times++;
killer->stats.kills++;
killer->stats.last_kill_timeseq = ++room->last_kill_timeseq;
}
}
++stats.dead_times;
@ -1033,8 +1034,7 @@ void Human::DirectReload()
void Human::SendUIUpdate()
{
cs::SMUiUpdate notifymsg;
notifymsg.set_alive_count(room->AliveCount());
notifymsg.set_kill_count(stats.kills);
room->FillSMUiUpdate(notifymsg);
SendNotifyMsg(notifymsg);
}

View File

@ -484,6 +484,17 @@ bool Room::IsGameOver()
return game_over;
}
void Room::FillSMUiUpdate(cs::SMUiUpdate& msg)
{
for (auto& pair : human_hash_) {
cs::MFPlayerBattlingStats* p = msg.add_player_stats();
p->set_player_id(pair.second->entity_uniid);
p->set_name(pair.second->name);
p->set_kills(pair.second->stats.kills);
p->set_last_kill_timeseq(pair.second->stats.last_kill_timeseq);
}
}
Hero* Room::CreateHero(Human* hum)
{
a8::Vec2 pos = hum->pos;

View File

@ -9,6 +9,11 @@
#include "mapservice.h"
#include "metadata.h"
namespace cs
{
class SMUiUpdate;
}
namespace MetaData
{
struct Map;
@ -46,6 +51,7 @@ public:
MapService map_service;
long long battle_start_frameno_ = 0;
long long pending_request = 0;
int last_kill_timeseq = 0;
~Room();
void Init();
@ -92,6 +98,7 @@ public:
void OnPlayerOffline(Player* hum);
Obstacle* CreateObstacle(int id, float x, float y);
bool IsGameOver();
void FillSMUiUpdate(cs::SMUiUpdate& msg);
private:
int AllocUniid();

View File

@ -85,6 +85,7 @@ struct Driver
struct PlayerStats
{
int kills = 0;
int last_kill_timeseq = 0;
int dead_times = 0;
int damage_amount_in = 0;
int damage_amount_out = 0;

View File

@ -540,6 +540,18 @@ message MFPlayerStats
optional int32 dead_times = 6; //
}
//
message MFPlayerBattlingStats
{
optional int32 player_id = 1; //id
optional string name = 2; //undefined
optional int32 kills = 3; //
/*
(, , timeseq也相同则player_id小的排前面
*/
optional int32 last_kill_timeseq = 4;
}
//
message MFAirDrop
{
@ -797,6 +809,5 @@ message SMWxVoip
//ui界面更新
message SMUiUpdate
{
optional int32 alive_count = 1; //
optional int32 kill_count = 2; //
repeated MFPlayerBattlingStats player_stats = 1; //
}