添加击杀统计
This commit is contained in:
parent
50cbf2f3e9
commit
807b8d79d7
@ -463,7 +463,8 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
Entity* entity = room->GetEntityByUniId(killer_id);
|
Entity* entity = room->GetEntityByUniId(killer_id);
|
||||||
if (entity && entity->entity_type == kET_Player) {
|
if (entity && entity->entity_type == kET_Player) {
|
||||||
Human* killer = (Human*)entity;
|
Human* killer = (Human*)entity;
|
||||||
killer->stats.dead_times++;
|
killer->stats.kills++;
|
||||||
|
killer->stats.last_kill_timeseq = ++room->last_kill_timeseq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++stats.dead_times;
|
++stats.dead_times;
|
||||||
@ -1033,8 +1034,7 @@ void Human::DirectReload()
|
|||||||
void Human::SendUIUpdate()
|
void Human::SendUIUpdate()
|
||||||
{
|
{
|
||||||
cs::SMUiUpdate notifymsg;
|
cs::SMUiUpdate notifymsg;
|
||||||
notifymsg.set_alive_count(room->AliveCount());
|
room->FillSMUiUpdate(notifymsg);
|
||||||
notifymsg.set_kill_count(stats.kills);
|
|
||||||
SendNotifyMsg(notifymsg);
|
SendNotifyMsg(notifymsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,6 +484,17 @@ bool Room::IsGameOver()
|
|||||||
return game_over;
|
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)
|
Hero* Room::CreateHero(Human* hum)
|
||||||
{
|
{
|
||||||
a8::Vec2 pos = hum->pos;
|
a8::Vec2 pos = hum->pos;
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
#include "mapservice.h"
|
#include "mapservice.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
|
|
||||||
|
namespace cs
|
||||||
|
{
|
||||||
|
class SMUiUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
struct Map;
|
struct Map;
|
||||||
@ -46,6 +51,7 @@ public:
|
|||||||
MapService map_service;
|
MapService map_service;
|
||||||
long long battle_start_frameno_ = 0;
|
long long battle_start_frameno_ = 0;
|
||||||
long long pending_request = 0;
|
long long pending_request = 0;
|
||||||
|
int last_kill_timeseq = 0;
|
||||||
|
|
||||||
~Room();
|
~Room();
|
||||||
void Init();
|
void Init();
|
||||||
@ -92,6 +98,7 @@ public:
|
|||||||
void OnPlayerOffline(Player* hum);
|
void OnPlayerOffline(Player* hum);
|
||||||
Obstacle* CreateObstacle(int id, float x, float y);
|
Obstacle* CreateObstacle(int id, float x, float y);
|
||||||
bool IsGameOver();
|
bool IsGameOver();
|
||||||
|
void FillSMUiUpdate(cs::SMUiUpdate& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
|
@ -85,6 +85,7 @@ struct Driver
|
|||||||
struct PlayerStats
|
struct PlayerStats
|
||||||
{
|
{
|
||||||
int kills = 0;
|
int kills = 0;
|
||||||
|
int last_kill_timeseq = 0;
|
||||||
int dead_times = 0;
|
int dead_times = 0;
|
||||||
int damage_amount_in = 0;
|
int damage_amount_in = 0;
|
||||||
int damage_amount_out = 0;
|
int damage_amount_out = 0;
|
||||||
|
@ -540,6 +540,18 @@ message MFPlayerStats
|
|||||||
optional int32 dead_times = 6; //死亡次数
|
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
|
message MFAirDrop
|
||||||
{
|
{
|
||||||
@ -797,6 +809,5 @@ message SMWxVoip
|
|||||||
//ui界面更新,一些不需要实时更新的数据
|
//ui界面更新,一些不需要实时更新的数据
|
||||||
message SMUiUpdate
|
message SMUiUpdate
|
||||||
{
|
{
|
||||||
optional int32 alive_count = 1; //存活数量
|
repeated MFPlayerBattlingStats player_stats = 1; //玩家战斗中统计信息
|
||||||
optional int32 kill_count = 2; //击杀数
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user