添加新手房特殊物件
This commit is contained in:
parent
8f72dc6a99
commit
31356be871
@ -62,6 +62,7 @@ void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info)
|
|||||||
init_info.newbie_born_point_meta = newbie_born_point_;
|
init_info.newbie_born_point_meta = newbie_born_point_;
|
||||||
init_info.loots = &loots_;
|
init_info.loots = &loots_;
|
||||||
init_info.buildings = &buildings_;
|
init_info.buildings = &buildings_;
|
||||||
|
init_info.level0room_spec_things = &level0room_spec_things_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapMgr::CreateThings()
|
void MapMgr::CreateThings()
|
||||||
@ -74,6 +75,14 @@ void MapMgr::CreateThings()
|
|||||||
switch (thing_tpl.i->_object_type()) {
|
switch (thing_tpl.i->_object_type()) {
|
||||||
case kMOT_Object:
|
case kMOT_Object:
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
int thing_id = thing_tpl.RandThing();
|
||||||
|
if (MetaMgr::Instance()->level0room_spec_things_set.find(thing_id) !=
|
||||||
|
MetaMgr::Instance()->level0room_spec_things_set.end()) {
|
||||||
|
level0room_spec_things_.push_back(&thing_tpl);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (thing_tpl.i->weight() >= rand() % 10000) {
|
if (thing_tpl.i->weight() >= rand() % 10000) {
|
||||||
CreateMapObject(thing_tpl);
|
CreateMapObject(thing_tpl);
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,5 @@ class MapMgr : public a8::Singleton<MapMgr>
|
|||||||
MetaData::MapTplThing* newbie_born_point_ = nullptr;
|
MetaData::MapTplThing* newbie_born_point_ = nullptr;
|
||||||
std::vector<MetaData::MapTplThing*> loots_;
|
std::vector<MetaData::MapTplThing*> loots_;
|
||||||
std::vector<Building*> buildings_;
|
std::vector<Building*> buildings_;
|
||||||
|
std::vector<MetaData::MapTplThing*> level0room_spec_things_;
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
#define METAMGR_READ(field_name, def_val) MetaMgr::Instance()->field_name = \
|
#define METAMGR_READ(field_name, def_val) MetaMgr::Instance()->field_name = \
|
||||||
a8::XValue(MetaMgr::Instance()->GetSysParamAsString(#field_name, #def_val));
|
a8::XValue(MetaMgr::Instance()->GetSysParamAsString(#field_name, #def_val));
|
||||||
|
|
||||||
|
#define METAMGR_READ_STR(field_name, def_val) MetaMgr::Instance()->field_name = \
|
||||||
|
a8::XValue(MetaMgr::Instance()->GetSysParamAsString(#field_name, def_val)).GetString();
|
||||||
|
|
||||||
class MetaDataLoader
|
class MetaDataLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -200,6 +203,19 @@ public:
|
|||||||
METAMGR_READ(level0room_robot_protect_time, 60);
|
METAMGR_READ(level0room_robot_protect_time, 60);
|
||||||
METAMGR_READ(level0room_robot_autodie_time, 10);
|
METAMGR_READ(level0room_robot_autodie_time, 10);
|
||||||
METAMGR_READ(level0room_robot_autodie_distance, 500);
|
METAMGR_READ(level0room_robot_autodie_distance, 500);
|
||||||
|
{
|
||||||
|
METAMGR_READ_STR(level0room_spec_things, "");
|
||||||
|
std::vector<std::string> tmpstrings;
|
||||||
|
a8::Split(MetaMgr::Instance()->level0room_spec_things, tmpstrings, ':');
|
||||||
|
for (auto& str : tmpstrings) {
|
||||||
|
if (!!str.empty()) {
|
||||||
|
MetaMgr::Instance()->level0room_spec_things_set.insert
|
||||||
|
(
|
||||||
|
a8::XValue(str).GetInt()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
METAMGR_READ(level1room_shua_robot_min_time, 5);
|
METAMGR_READ(level1room_shua_robot_min_time, 5);
|
||||||
METAMGR_READ(level1room_shua_robot_max_time, 7);
|
METAMGR_READ(level1room_shua_robot_max_time, 7);
|
||||||
|
@ -87,6 +87,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
int level0room_robot_protect_time = 0;
|
int level0room_robot_protect_time = 0;
|
||||||
int level0room_robot_autodie_time = 0;
|
int level0room_robot_autodie_time = 0;
|
||||||
int level0room_robot_autodie_distance = 0;
|
int level0room_robot_autodie_distance = 0;
|
||||||
|
std::set<int> level0room_spec_things_set;
|
||||||
|
|
||||||
int level1room_shua_robot_min_time = 0;
|
int level1room_shua_robot_min_time = 0;
|
||||||
int level1room_shua_robot_max_time = 0;
|
int level1room_shua_robot_max_time = 0;
|
||||||
@ -115,4 +116,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MetaDataLoader* loader_ = nullptr;
|
MetaDataLoader* loader_ = nullptr;
|
||||||
|
|
||||||
|
std::string level0room_spec_things;
|
||||||
|
friend class MetaDataLoader;
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,7 @@ void Room::InitData(RoomInitInfo& init_info)
|
|||||||
newbie_born_point_meta_ = init_info.newbie_born_point_meta;
|
newbie_born_point_meta_ = init_info.newbie_born_point_meta;
|
||||||
loots_ = init_info.loots;
|
loots_ = init_info.loots;
|
||||||
buildings_ = init_info.buildings;
|
buildings_ = init_info.buildings;
|
||||||
|
level0room_spec_things_ = init_info.level0room_spec_things;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::Init()
|
void Room::Init()
|
||||||
@ -64,6 +65,9 @@ void Room::Init()
|
|||||||
CreateDropObjs();
|
CreateDropObjs();
|
||||||
InitObstacleDatas();
|
InitObstacleDatas();
|
||||||
ShuaAndroid();
|
ShuaAndroid();
|
||||||
|
if (room_type_ == RT_NewBrid) {
|
||||||
|
CreateLevel0RoomSpecThings();
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
InitDebugInfo();
|
InitDebugInfo();
|
||||||
#endif
|
#endif
|
||||||
@ -2459,3 +2463,19 @@ int Room::GetCanShuaNum(int shua_num)
|
|||||||
}
|
}
|
||||||
return real_shua_num;
|
return real_shua_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::CreateLevel0RoomSpecThings()
|
||||||
|
{
|
||||||
|
if (level0room_spec_things_) {
|
||||||
|
for (auto& thing_tpl : *level0room_spec_things_) {
|
||||||
|
int thing_id = thing_tpl->RandThing();
|
||||||
|
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(thing_id);
|
||||||
|
if (thing_meta) {
|
||||||
|
InternalCreateObstacle(thing_id, thing_tpl->i->x(), thing_tpl->i->y(),
|
||||||
|
[] (Obstacle* entity)
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -186,6 +186,7 @@ private:
|
|||||||
void CombineTeamBornPoint();
|
void CombineTeamBornPoint();
|
||||||
void ForceSetBornPoint(Human* hum, BornPoint* born_point);
|
void ForceSetBornPoint(Human* hum, BornPoint* born_point);
|
||||||
void NewBieRoomStart();
|
void NewBieRoomStart();
|
||||||
|
void CreateLevel0RoomSpecThings();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void InitDebugInfo();
|
void InitDebugInfo();
|
||||||
@ -202,6 +203,7 @@ private:
|
|||||||
const MetaData::MapTplThing* newbie_born_point_meta_ = nullptr;
|
const MetaData::MapTplThing* newbie_born_point_meta_ = nullptr;
|
||||||
const std::vector<MetaData::MapTplThing*>* loots_ = nullptr;
|
const std::vector<MetaData::MapTplThing*>* loots_ = nullptr;
|
||||||
const std::vector<Building*>* buildings_ = nullptr;
|
const std::vector<Building*>* buildings_ = nullptr;
|
||||||
|
const std::vector<MetaData::MapTplThing*>* level0room_spec_things_ = nullptr;
|
||||||
Human* first_newbie_ = nullptr;
|
Human* first_newbie_ = nullptr;
|
||||||
|
|
||||||
bool waiting_start_ = false;
|
bool waiting_start_ = false;
|
||||||
|
@ -170,4 +170,5 @@ struct RoomInitInfo
|
|||||||
const MetaData::MapTplThing* newbie_born_point_meta = nullptr;
|
const MetaData::MapTplThing* newbie_born_point_meta = nullptr;
|
||||||
const std::vector<MetaData::MapTplThing*>* loots = nullptr;
|
const std::vector<MetaData::MapTplThing*>* loots = nullptr;
|
||||||
const std::vector<Building*>* buildings = nullptr;
|
const std::vector<Building*>* buildings = nullptr;
|
||||||
|
const std::vector<MetaData::MapTplThing*>* level0room_spec_things = nullptr;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user