This commit is contained in:
aozhiwei 2019-07-05 13:25:55 +08:00
parent 65303f049c
commit ce5dcf7ea7
6 changed files with 27 additions and 12 deletions

View File

@ -4,6 +4,7 @@
#include "human.h" #include "human.h"
#include "room.h" #include "room.h"
#include "typeconvert.h" #include "typeconvert.h"
#include "metamgr.h"
cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum) cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
{ {
@ -73,6 +74,16 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
if (room->frame_event.airdrops_.size() > 0) { if (room->frame_event.airdrops_.size() > 0) {
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0); *msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
} }
{
if (room->BattleStarted()) {
int game_left_time = MetaMgr::Instance()->game_duration * 1000 -
(room->frame_no - room->battle_start_frameno_) * FRAME_RATE_MS;
game_left_time = std::max(0, game_left_time);
msg->set_game_left_time(game_left_time);
} else {
msg->set_game_left_time(MetaMgr::Instance()->game_duration * 1000);
}
}
} }
return msg; return msg;
} }

View File

@ -515,11 +515,12 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Human* hum = (Human*)param.sender.GetUserData(); Human* hum = (Human*)param.sender.GetUserData();
hum->Relive(); hum->Revive();
}, },
&xtimer_attacher.timer_list_ &xtimer_attacher.timer_list_
); );
room->frame_event.AddDead(this); room->frame_event.AddDead(this);
room->OnHumanDie(this);
SyncAroundPlayers(); SyncAroundPlayers();
} }
} }
@ -1703,10 +1704,11 @@ void Human::DeadDrop()
} }
} }
void Human::Relive() void Human::Revive()
{ {
dead = false; dead = false;
health = GetMaxHP(); health = GetMaxHP();
room->frame_event.AddRevive(this); room->frame_event.AddRevive(this);
room->OnHumanRevive(this);
SyncAroundPlayers(); SyncAroundPlayers();
} }

View File

@ -197,7 +197,7 @@ private:
void ClearFrameData(); void ClearFrameData();
void GenBattleReportData(a8::MutableXObject* params); void GenBattleReportData(a8::MutableXObject* params);
void DeadDrop(); void DeadDrop();
void Relive(); void Revive();
protected: protected:
long long last_shot_frameno_ = 0; long long last_shot_frameno_ = 0;

View File

@ -40,7 +40,7 @@ void Room::Init()
{ {
xtimer.Init(RoomXGetTickCount, this, 100, 100); xtimer.Init(RoomXGetTickCount, this, 100, 100);
xtimer_attacher.xtimer = &xtimer; xtimer_attacher.xtimer = &xtimer;
grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH); grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH * 8);
map_service.Init(MAP_WIDTH / MAP_GRID_WIDTH, MAP_HEIGHT / MAP_GRID_WIDTH, MAP_GRID_WIDTH); map_service.Init(MAP_WIDTH / MAP_GRID_WIDTH, MAP_HEIGHT / MAP_GRID_WIDTH, MAP_GRID_WIDTH);
CreateThings(); CreateThings();
@ -603,6 +603,7 @@ void Room::FetchBuilding(Human* hum)
void Room::OnHumanDie(Human* hum) void Room::OnHumanDie(Human* hum)
{ {
#if 0
if (hum->skill_meta && hum->skill_meta->i->type() == ST_SelfDetonate) { if (hum->skill_meta && hum->skill_meta->i->type() == ST_SelfDetonate) {
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
if (pair.second != hum && (pair.second->team_id == 0 || pair.second->team_id != hum->team_id)) { if (pair.second != hum && (pair.second->team_id == 0 || pair.second->team_id != hum->team_id)) {
@ -617,10 +618,17 @@ void Room::OnHumanDie(Human* hum)
} }
frame_event.AddExplosionEx(hum, 0, hum->pos, 1); frame_event.AddExplosionEx(hum, 0, hum->pos, 1);
} }
#endif
--alive_count_; --alive_count_;
NotifyUiUpdate(); NotifyUiUpdate();
} }
void Room::OnHumanRevive(Human* hum)
{
++alive_count_;
NotifyUiUpdate();
}
bool Room::OverBorder(const a8::Vec2 pos, float radius) bool Room::OverBorder(const a8::Vec2 pos, float radius)
{ {
//检查x轴 //检查x轴

View File

@ -78,6 +78,7 @@ public:
a8::Vec2 pos, a8::Vec2 dir, float fly_distance); a8::Vec2 pos, a8::Vec2 dir, float fly_distance);
void OnHumanDie(Human* hum); void OnHumanDie(Human* hum);
void OnHumanRevive(Human* hum);
bool OverBorder(const a8::Vec2 pos, float radius); bool OverBorder(const a8::Vec2 pos, float radius);
Human* GetWatchWarTarget(Human* hum); Human* GetWatchWarTarget(Human* hum);
bool BattleStarted(); bool BattleStarted();

View File

@ -551,13 +551,6 @@ message MFBuff
optional float lasting_time = 3; //() optional float lasting_time = 3; //()
} }
//
message MFPlane
{
optional MFVector2D start_point = 1; //
optional MFVector2D end_point = 2; //
}
//end mfmsg //end mfmsg
// //
@ -699,7 +692,7 @@ message SMUpdate
repeated MFObjectPart part_objects = 4; //-() repeated MFObjectPart part_objects = 4; //-()
optional int32 active_player_id = 5; //id(id) optional int32 active_player_id = 5; //id(id)
optional MFActivePlayerData active_player_data = 6; //() optional MFActivePlayerData active_player_data = 6; //()
optional int32 alive_count = 15; // optional int32 game_left_time = 15; //(, )
optional int32 gas_progress = 16; //,(gas_data.mode == moving时才会发进度) optional int32 gas_progress = 16; //,(gas_data.mode == moving时才会发进度)
optional MFVector2D gas_pos_old = 30; // optional MFVector2D gas_pos_old = 30; //
optional MFGasData gas_data = 17; // optional MFGasData gas_data = 17; //