This commit is contained in:
aozhiwei 2019-09-10 14:32:38 +08:00
parent 9a97c30fe8
commit 60a274d2c0
4 changed files with 24 additions and 1 deletions

View File

@ -367,6 +367,12 @@ void Room::CreateThings()
CreateObstacle(thing_id, thing_tpl.i->x(), thing_tpl.i->y());
}
} else if (thing_id == BORN_POINT_THINGID) {
CreateBornPoint(thing_tpl.i->x(),
thing_tpl.i->y(),
thing_tpl.i->width(),
thing_tpl.i->height(),
thing_tpl.i->param1()
);
} else {
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
if (equip_meta) {
@ -1484,11 +1490,21 @@ void Room::NotifyWxVoip()
&xtimer_attacher.timer_list_);
}
void Room::CreateBornPoint(int x, int y, int width, int height, int hum_limit)
{
BornPoint born_point;
born_point.born_point_id = AllocUniid();
born_point.pos = a8::Vec2(x, y);
born_point.rad = std::min(width, height);
born_point.hum_limit = hum_limit;
born_point_hash_[born_point.born_point_id] = born_point;
}
BornPoint* Room::AllocBornPoint(Human* hum)
{
BornPoint* born_point = nullptr;
for (auto& pair : born_point_hash_) {
if (pair.second.player_num + pair.second.android_num < 6) {
if (pair.second.player_num + pair.second.android_num < pair.second.hum_limit) {
born_point = &pair.second;
break;
}

View File

@ -120,6 +120,7 @@ private:
void OnGameOver();
void RandRemoveAndroid();
void NotifyWxVoip();
void CreateBornPoint(int x, int y, int width, int height, int hum_limit);
BornPoint* AllocBornPoint(Human* hum);
private:

View File

@ -128,5 +128,6 @@ struct BornPoint
int player_num = 0;
int android_num = 0;
int hum_limit = 0;
a8::Vec2 RandPoint() const;
};

View File

@ -248,4 +248,9 @@ message MapTplThingJson
optional int32 weight = 4;
optional float x = 5;
optional float y = 6;
optional float height = 7;
optional float width = 8;
optional float param1 = 9;
optional float param2 = 10;
optional float param3 = 11;
}