添加出生点读取

This commit is contained in:
aozhiwei 2019-07-05 13:58:37 +08:00
parent ce5dcf7ea7
commit a86fbc8990
5 changed files with 32 additions and 7 deletions

View File

@ -199,3 +199,5 @@ const int MAX_INSTANCE_ID = 500;
const int MAX_TEAM_NUM = 4;
const int WEAPON_SLOT = 0;
const int ROOM_MAX_PLAYER_NUM = 8;

View File

@ -56,6 +56,7 @@ public:
std::map<int, MetaData::Drop*> drop_hash;
std::map<std::string, std::list<metatable::MapTplThingJson>> maptpl_meta_hash;
std::map<std::string, std::vector<MetaData::MapTplThing>> maptpl_hash;
std::map<std::string, std::vector<MetaData::MapTplThing>> born_point_hash;
std::map<int, MetaData::Dress*> dress_hash;
std::map<int, MetaData::Tank*> tank_hash;
std::map<int, MetaData::Skill*> skill_hash;
@ -145,12 +146,23 @@ private:
}
for (auto& pair : maptpl_meta_hash) {
std::vector<MetaData::MapTplThing> things;
std::vector<MetaData::MapTplThing> born_point;
for (auto& itr : pair.second) {
auto& thing = a8::FastAppend(things);
thing.i = &itr;
thing.Init();
if (itr.is_born_point()) {
auto& thing = a8::FastAppend(born_point);
thing.i = &itr;
thing.Init();
} else {
auto& thing = a8::FastAppend(things);
thing.i = &itr;
thing.Init();
}
}
maptpl_hash[pair.first] = things;
born_point_hash[pair.first] = born_point;
if (born_point.size() != ROOM_MAX_PLAYER_NUM) {
abort();
}
}
}
#endif
@ -357,12 +369,18 @@ MetaData::SafeArea* MetaMgr::GetSafeArea(int area_id)
return itr != loader_->safearea_hash.end() ? itr->second : nullptr;
}
std::vector<MetaData::MapTplThing>* MetaMgr::GetMapTplThing(std::string& map_name)
std::vector<MetaData::MapTplThing>* MetaMgr::GetMapTplThing(const std::string& map_name)
{
auto itr = loader_->maptpl_hash.find(map_name);
return itr != loader_->maptpl_hash.end() ? &itr->second : nullptr;
}
std::vector<MetaData::MapTplThing>* MetaMgr::GetMapBornPoints(const std::string& map_name)
{
auto itr = loader_->born_point_hash.find(map_name);
return itr != loader_->born_point_hash.end() ? &itr->second : nullptr;
}
MetaData::Skill* MetaMgr::GetSkill(int skill_id)
{
auto itr = loader_->skill_hash.find(skill_id);

View File

@ -28,7 +28,8 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Building* GetBuilding(int building_id);
MetaData::Drop* GetDrop(int drop_id);
MetaData::SafeArea* GetSafeArea(int area_id);
std::vector<MetaData::MapTplThing>* GetMapTplThing(std::string& map_name);
std::vector<MetaData::MapTplThing>* GetMapTplThing(const std::string& map_name);
std::vector<MetaData::MapTplThing>* GetMapBornPoints(const std::string& map_name);
MetaData::Skill* GetSkill(int skill_id);
MetaData::Dress* GetDress(int dress_id);
MetaData::Tank* GetTank(int tank_id);

View File

@ -23,8 +23,6 @@
#include "hero.h"
#include "gamelog.h"
const int ROOM_MAX_PLAYER_NUM = 8;
static long long RoomXGetTickCount(void* context)
{
Room* room = (Room*)context;
@ -38,6 +36,10 @@ Room::~Room()
void Room::Init()
{
born_points_ = MetaMgr::Instance()->GetMapBornPoints(map_tpl_name);
if (!born_points_ || born_points_->size() != ROOM_MAX_PLAYER_NUM) {
abort();
}
xtimer.Init(RoomXGetTickCount, this, 100, 100);
xtimer_attacher.xtimer = &xtimer;
grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH * 8);

View File

@ -7,6 +7,7 @@
#include "framemaker.h"
#include "gridservice.h"
#include "mapservice.h"
#include "metadata.h"
namespace MetaData
{
@ -116,6 +117,7 @@ private:
int current_teamid = 0;
int current_uniid = 0;
std::vector<MetaData::MapTplThing>* born_points_ = nullptr;
xtimer_list* battle_report_timer_ = nullptr;
std::set<int> refreshed_robot_set_;