开始后组队玩家跳到统一的出生点
This commit is contained in:
parent
2c06f591c9
commit
ddd77d25d2
@ -1635,23 +1635,7 @@ BornPoint* Room::AllocBornPoint(Human* hum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pre_point) {
|
if (pre_point) {
|
||||||
switch (hum->entity_subtype) {
|
DecBornPointHumanNum(pre_point, hum);
|
||||||
case EST_Player:
|
|
||||||
{
|
|
||||||
--pre_point->player_num;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EST_Android:
|
|
||||||
{
|
|
||||||
--pre_point->android_num;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!free_point_list.empty()) {
|
if (!free_point_list.empty()) {
|
||||||
born_point = free_point_list[rand() % free_point_list.size()];
|
born_point = free_point_list[rand() % free_point_list.size()];
|
||||||
@ -1667,22 +1651,7 @@ BornPoint* Room::AllocBornPoint(Human* hum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (born_point) {
|
if (born_point) {
|
||||||
switch (hum->entity_subtype) {
|
DecBornPointHumanNum(born_point, hum);
|
||||||
case EST_Player:
|
|
||||||
{
|
|
||||||
++born_point->player_num;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EST_Android:
|
|
||||||
{
|
|
||||||
++born_point->android_num;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return born_point;
|
return born_point;
|
||||||
}
|
}
|
||||||
@ -1731,20 +1700,80 @@ void Room::CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl)
|
|||||||
born_point_hash_[AllocUniid()] = born_point;
|
born_point_hash_[AllocUniid()] = born_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
||||||
|
{
|
||||||
|
switch (hum->entity_subtype) {
|
||||||
|
case EST_Player:
|
||||||
|
{
|
||||||
|
++point->player_num;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EST_Android:
|
||||||
|
{
|
||||||
|
++point->android_num;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::DecBornPointHumanNum(BornPoint* point, Human* hum)
|
||||||
|
{
|
||||||
|
switch (hum->entity_subtype) {
|
||||||
|
case EST_Player:
|
||||||
|
{
|
||||||
|
--point->player_num;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EST_Android:
|
||||||
|
{
|
||||||
|
--point->android_num;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Room::SecondRandPoint()
|
void Room::SecondRandPoint()
|
||||||
{
|
{
|
||||||
for (auto& pair : accountid_hash_) {
|
for (auto& pair : accountid_hash_) {
|
||||||
Human* hum = pair.second;
|
Human* hum = pair.second;
|
||||||
hum->born_point = AllocBornPoint(hum);
|
hum->born_point = AllocBornPoint(hum);
|
||||||
if (!hum->born_point) {
|
}
|
||||||
hum->SetX(DEFAULT_BORN_POINT_X + rand() % 100);
|
for (auto& pair : team_hash_) {
|
||||||
hum->SetY(DEFAULT_BORN_POINT_Y + rand() % 200);
|
if (pair.second.size() < 2) {
|
||||||
} else {
|
continue;
|
||||||
hum->SetPos(hum->born_point->RandPoint());
|
}
|
||||||
|
Human* target = nullptr;
|
||||||
|
for (Human* hum : pair.second) {
|
||||||
|
if (!target) {
|
||||||
|
target = hum;
|
||||||
|
} else {
|
||||||
|
if (target->born_point) {
|
||||||
|
if (hum->born_point) {
|
||||||
|
DecBornPointHumanNum(hum->born_point, hum);
|
||||||
|
}
|
||||||
|
hum->born_point = target->born_point;
|
||||||
|
if (!hum->born_point) {
|
||||||
|
hum->SetX(DEFAULT_BORN_POINT_X + rand() % 100);
|
||||||
|
hum->SetY(DEFAULT_BORN_POINT_Y + rand() % 200);
|
||||||
|
} else {
|
||||||
|
IncBornPointHumanNum(hum->born_point, hum);
|
||||||
|
hum->SetPos(hum->born_point->RandPoint());
|
||||||
|
}
|
||||||
|
hum->FindLocation();
|
||||||
|
hum->RefreshView();
|
||||||
|
grid_service.MoveHuman(hum);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
hum->FindLocation();
|
|
||||||
hum->RefreshView();
|
|
||||||
grid_service.MoveHuman(hum);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,8 @@ private:
|
|||||||
BornPoint* AllocBornPoint(Human* hum);
|
BornPoint* AllocBornPoint(Human* hum);
|
||||||
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
|
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
|
||||||
void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl);
|
void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl);
|
||||||
|
void IncBornPointHumanNum(BornPoint* point, Human* hum);
|
||||||
|
void DecBornPointHumanNum(BornPoint* point, Human* hum);
|
||||||
void SecondRandPoint();
|
void SecondRandPoint();
|
||||||
void NotifyGameStart();
|
void NotifyGameStart();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user