添加 游戏开始消息

This commit is contained in:
aozhiwei 2020-02-28 15:48:08 +08:00
parent bd9ca4877e
commit f1997b657a
4 changed files with 44 additions and 1 deletions

View File

@ -982,6 +982,8 @@ void Room::UpdateGasInactive()
NotifyUiUpdate();
}
CombineTeam();
NotifyGameStart();
SecondRandPoint();
#else
gas_data.gas_mode = GasJump;
gas_data.gas_start_frameno = frame_no;
@ -1505,6 +1507,15 @@ void Room::NotifyWxVoip()
BornPoint* Room::AllocBornPoint(Human* hum)
{
if (hum->born_point) {
std::vector<BornPoint*> point_list;
for (auto& pair : born_point_hash_) {
if (&pair.second != hum->born_point) {
point_list.push_back(&pair.second);
}
}
return !point_list.empty() ? point_list[rand() % point_list.size()] : nullptr;
}
BornPoint* born_point = nullptr;
for (auto& pair : born_point_hash_) {
if (pair.second.player_num + pair.second.android_num < pair.second.thing_tpl->i->param1()) {
@ -1576,3 +1587,27 @@ void Room::CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl)
born_point.thing_tpl = &thing_tpl;
born_point_hash_[AllocUniid()] = born_point;
}
void Room::SecondRandPoint()
{
for (auto& pair : accountid_hash_) {
Human* hum = pair.second;
hum->born_point = AllocBornPoint(hum);
if (!hum->born_point) {
hum->pos.x = DEFAULT_BORN_POINT_X + rand() % 100;
hum->pos.y = DEFAULT_BORN_POINT_Y + rand() % 200;
} else {
hum->pos = hum->born_point->RandPoint();
}
hum->FindLocation();
hum->RefreshView();
}
}
void Room::NotifyGameStart()
{
cs::SMGameStart msg;
for (auto& pair : accountid_hash_) {
pair.second->SendNotifyMsg(msg);
}
}

View File

@ -130,6 +130,8 @@ private:
BornPoint* AllocBornPoint(Human* hum);
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl);
void SecondRandPoint();
void NotifyGameStart();
private:
int elapsed_time_ = 0;

View File

@ -36,4 +36,5 @@ enum SMMessageId_e
_SMDebugMsg = 1010;
_SMWxVoip = 1011;
_SMUiUpdate = 1012;
_SMGameStart = 1013;
}

View File

@ -869,4 +869,9 @@ message SMUiUpdate
optional int32 alive_count = 1; //
optional int32 kill_count = 2; //
repeated MFCar car_list = 3; //
}
}
//
message SMGameStart
{
}