22.单人机甲,地图上多个位置刷新X个
This commit is contained in:
parent
ce41c8a051
commit
1655c7f443
@ -45,6 +45,15 @@ namespace MetaData
|
|||||||
airraids.push_back(a8::XValue(str).GetInt());
|
airraids.push_back(a8::XValue(str).GetInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->car_num_limit(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
std::vector<std::string> strings2;
|
||||||
|
a8::Split(str, strings2, ':');
|
||||||
|
car_num_limit[a8::XValue(strings2[0]).GetInt()] = a8::XValue(strings2[1]).GetInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
a8::Split(i->game_start_buff_list(), strings, ':');
|
a8::Split(i->game_start_buff_list(), strings, ':');
|
||||||
@ -117,6 +126,12 @@ namespace MetaData
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Map::GetCarLimit(int car_id)
|
||||||
|
{
|
||||||
|
auto itr = car_num_limit.find(car_id);
|
||||||
|
return itr != car_num_limit.end() ? itr->second : 666;
|
||||||
|
}
|
||||||
|
|
||||||
void MapThing::Init()
|
void MapThing::Init()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -30,9 +30,11 @@ namespace MetaData
|
|||||||
int refresh_robot_max_time = 0;
|
int refresh_robot_max_time = 0;
|
||||||
std::vector<int> buff_list;
|
std::vector<int> buff_list;
|
||||||
a8::Vec2 first_safearea_center;
|
a8::Vec2 first_safearea_center;
|
||||||
|
std::map<int, int> car_num_limit;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
std::string RandTemplate();
|
std::string RandTemplate();
|
||||||
|
int GetCarLimit(int car_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Attr
|
struct Attr
|
||||||
|
@ -2147,27 +2147,13 @@ void Room::CreateMonsterSpawnPoints()
|
|||||||
|
|
||||||
void Room::CreateLoots()
|
void Room::CreateLoots()
|
||||||
{
|
{
|
||||||
|
std::vector<std::tuple<MetaData::Equip*, MetaData::MapTplThing*>> car_equips;
|
||||||
for (auto& thing_tpl : *loots_) {
|
for (auto& thing_tpl : *loots_) {
|
||||||
int thing_id = thing_tpl->RandThing();
|
int thing_id = thing_tpl->RandThing();
|
||||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
|
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
|
||||||
if (equip_meta) {
|
if (equip_meta) {
|
||||||
if (equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
|
if (equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
|
||||||
int car_uniid = AllocUniid();
|
car_equips.push_back(std::make_tuple(equip_meta, thing_tpl));
|
||||||
Car* c = CreateCar(nullptr,
|
|
||||||
car_uniid,
|
|
||||||
equip_meta,
|
|
||||||
a8::Vec2
|
|
||||||
(
|
|
||||||
thing_tpl->i->x(),
|
|
||||||
thing_tpl->i->y()
|
|
||||||
),
|
|
||||||
0);
|
|
||||||
if (c) {
|
|
||||||
CarObject car;
|
|
||||||
car.car_id = equip_meta->i->id();
|
|
||||||
car.pos = c->GetPos();
|
|
||||||
car_hash_[c->GetUniId()] = car;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int loot_uniid = CreateLoot(
|
int loot_uniid = CreateLoot(
|
||||||
equip_meta->i->id(),
|
equip_meta->i->id(),
|
||||||
@ -2196,6 +2182,36 @@ void Room::CreateLoots()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<int, int> car_nums;
|
||||||
|
std::random_shuffle(car_equips.begin(), car_equips.end());
|
||||||
|
for (size_t i = 0; i < car_equips.size(); ++i) {
|
||||||
|
MetaData::Equip* equip_meta = std::get<0>(car_equips[i]);
|
||||||
|
MetaData::MapTplThing* thing_tpl = std::get<1>(car_equips[i]);
|
||||||
|
|
||||||
|
if (car_nums.find(equip_meta->i->id()) == car_nums.end()) {
|
||||||
|
car_nums[equip_meta->i->id()] = 0;
|
||||||
|
}
|
||||||
|
car_nums[equip_meta->i->id()] += 1;
|
||||||
|
if (car_nums[equip_meta->i->id()] <= ((MetaData::Map*)map_meta_)->GetCarLimit(equip_meta->i->id())) {
|
||||||
|
int car_uniid = AllocUniid();
|
||||||
|
Car* c = CreateCar(nullptr,
|
||||||
|
car_uniid,
|
||||||
|
equip_meta,
|
||||||
|
a8::Vec2
|
||||||
|
(
|
||||||
|
thing_tpl->i->x(),
|
||||||
|
thing_tpl->i->y()
|
||||||
|
),
|
||||||
|
0);
|
||||||
|
if (c) {
|
||||||
|
CarObject car;
|
||||||
|
car.car_id = equip_meta->i->id();
|
||||||
|
car.pos = c->GetPos();
|
||||||
|
car_hash_[c->GetUniId()] = car;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::CreateDropObjs()
|
void Room::CreateDropObjs()
|
||||||
|
@ -37,6 +37,7 @@ message Map
|
|||||||
optional string first_safearea_center = 14;
|
optional string first_safearea_center = 14;
|
||||||
optional int32 init_gas_ring = 15;
|
optional int32 init_gas_ring = 15;
|
||||||
optional string airraids = 16;
|
optional string airraids = 16;
|
||||||
|
optional string car_num_limit = 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
message MapThing
|
message MapThing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user