本文整理汇总了C++中DataLibrary类的典型用法代码示例。如果您正苦于以下问题:C++ DataLibrary类的具体用法?C++ DataLibrary怎么用?C++ DataLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: turnStart
void BattleSquad::turnStart()
{
if (this->getUnitNum()==0)
{
return;
}
DataLibrary* datalib = DataLibrary::getSingletonPtr();
float ap = getAttr(ATTR_ACTIONPOINT,ATTRCALC_FULL);
setActionPoint(ap);
setAPSetup(0.0f);
setAPBattle(0.0f);
std::vector<std::string> activeskills;
activeskills = datalib->getChildList(mPath + "/Skill");
std::vector<std::string>::iterator ite;
for(ite = activeskills.begin(); ite != activeskills.end(); ite++)
{
int cooldown = 0;
datalib->getData(mPath + "/Skill/" + (*ite) + "/CoolDown", cooldown);
if(cooldown > 0)
cooldown -= 1;
datalib->setData(mPath + "/Skill/" + (*ite) + "/CoolDown", cooldown);
}
LuaTempContext* luatempcontext = new LuaTempContext();
luatempcontext->strMap["squadid"] = getSquadId();
Trigger("TurnStart", luatempcontext);
delete luatempcontext;
}
示例2: getSkillApCost
float BattleSquad::getSkillApCost(std::string skillid)
{
DataLibrary* datalib = DataLibrary::getSingletonPtr();
std::vector<std::string> skilllist;
skilllist = datalib->getChildList("StaticData/SkillData");
std::vector<std::string>::iterator ite;
ite = std::find(skilllist.begin(), skilllist.end(), skillid);
if(ite == skilllist.end())
return 0.0f;
int skillaptype;
float skillapcost;
datalib->getData(str(boost::format("StaticData/SkillData/%1%/APType")%skillid),skillaptype);
datalib->getData(str(boost::format("StaticData/SkillData/%1%/APCost")%skillid),skillapcost);
switch(skillaptype)
{
case SKILLAPTYPE_SETUP:
case SKILLAPTYPE_BATTLE:
return getAPTypeCostModify(skillaptype) + skillapcost;
case SKILLAPTYPE_DEFENCE:
{
float ap = getActionPoint();
return (ap > skillapcost)?ap:skillapcost;
}
}
return 0.0f;
}
示例3: onRefreshList
void GUIDebugWindow::onRefreshList(MyGUI::Widget* _sender)
{
DataLibrary* datalib = DataLibrary::getSingletonPtr();
mSquadList->removeAllItems();
std::string path = "GameData/StoryData/SquadData";
std::vector<std::string> squadlist = datalib->getChildList(path);
for (std::vector<std::string>::iterator it=squadlist.begin();it!=squadlist.end();it++)
{
mSquadList->addItem((*it));
}
}
示例4: canUseSkill
BattleSquad::SkillState BattleSquad::canUseSkill(std::string skillid)
{
DataLibrary* datalib = DataLibrary::getSingletonPtr();
std::vector<std::string> activeskills;
activeskills = datalib->getChildList(mPath + "/Skill");
std::vector<std::string>::iterator ite;
ite = std::find(activeskills.begin(), activeskills.end(), skillid);
if(ite == activeskills.end())
return SKILLSTATE_NOSKILL;
if(getActionPoint() < getSkillApCost(skillid))
return SKILLSTATE_NOTAVAILABLE;
int cooldown = 0;
datalib->getData(mPath + "/Skill/" + skillid + "/CoolDown", cooldown);
if(cooldown > 0)
return SKILLSTATE_NOTAVAILABLE;
return SKILLSTATE_AVAILABLE;
}
示例5: getPassable
bool MapDataManager::getPassable(int x, int y, int faction)
{
//PROFILE_FUNC();
if(x < 0 || x >= mMapSize || y < 0 || y >= mMapSize)
return false;
DataLibrary* datalib = DataLibrary::getSingletonPtr();
int maxpassable;
int minpassable;
int passable;
int id;
std::string path = std::string("GameData/BattleData/MapData/Map/M") + Ogre::StringConverter::toString(getGridId(x, y));
bool re = datalib->getData(path + std::string("/GroundType"), id);
std::string ground;
datalib->getData(str(boost::format("GameData/BattleData/MapData/Ground/G%1%")%id),ground);
re = datalib->getData(str(boost::format("StaticData/GroundData/%1%/GroundModifier/Passable")%ground), passable);
maxpassable = passable;
minpassable = passable;
re = datalib->getData(path + std::string("/TerrainType"), id);
re = datalib->getData(std::string("StaticData/TerrainData/Terrain") + Ogre::StringConverter::toString(id) + std::string("/GroundModifier/Passable"), passable);
maxpassable = (maxpassable > passable)? maxpassable:passable;
minpassable = (minpassable < passable)? minpassable:passable;
std::string groundobj;
re = datalib->getData(path + std::string("/MapObjType"), groundobj,true);
if(re)
{
path = str(boost::format("StaticData/MapObjType/%1%/GroundModifier/Passable")%groundobj);
re = datalib->getData(path, passable);
maxpassable = (maxpassable > passable)? maxpassable:passable;
minpassable = (minpassable < passable)? minpassable:passable;
}
//¶îÍâÐÞÕý
//С¶Ó×èµ²
if(faction >= 0)
{
BattleSquadManager* battlesquadmanager = BattleSquadManager::getSingletonPtr();
// BattleSquadManager::BattleSquadIte ite;
// for(ite = battlesquadmanager->mSquadList.begin(); ite != battlesquadmanager->mSquadList.end(); ite++)
// {
// int xx = ite->second->getGridX();
// int yy = ite->second->getGridY();
// if(xx ==x && yy == y)
// return false;
// }
BattleSquad* squad = battlesquadmanager->getBattleSquadAt(x, y, faction, true);
if(squad)
return false;
}
if(maxpassable == 2)
return true;
if(minpassable == 0)
return false;
return true;
}
示例6: addParticle
bool BattleSquad::addParticle(std::string particlename, int object, std::string &particleid)
{
DataLibrary* datalib = DataLibrary::getSingletonPtr();
std::string distpath = mPath + std::string("/ParticleList");
std::vector<std::string> particlelist = datalib->getChildList(distpath);
int x = 0;
particleid = std::string("p") + Ogre::StringConverter::toString(x);
std::vector<std::string>::iterator ite = std::find(particlelist.begin(), particlelist.end(),particleid);
while(ite != particlelist.end())
{
x = x + 1;
particleid = std::string("p") + Ogre::StringConverter::toString(x);
ite = std::find(particlelist.begin(), particlelist.end(),particleid);
}
distpath = distpath + std::string("/") + particleid;
datalib->setData(distpath + std::string("/ParticleName"), particlename, true);
datalib->setData(distpath + std::string("/AffectUnit"), object, true);
return true;
}
示例7: setUnitNum
void BattleSquad::setUnitNum(int val)
{
DataLibrary* datalib = DataLibrary::getSingletonPtr();
datalib->setData(getPath() + "/UnitNum", val);
LuaTempContext* luatempcontext = new LuaTempContext();
luatempcontext->strMap["squadid"] = getSquadId();
Trigger("UnitNumChange", luatempcontext);
delete luatempcontext;
if(getUnitNum() <= 0)
{
LuaTempContext* luatempcontext = new LuaTempContext();
luatempcontext->strMap["squadid"] = getSquadId();
MapDataManager::getSingleton().Trigger("SquadAnnihilated", luatempcontext);
delete luatempcontext;
}
}
示例8: loadMapFormSave
bool MapLoader::loadMapFormSave()
{
DataLibrary* datalibrary = DataLibrary::getSingletonPtr();
int mapsize;
datalibrary->getData("GameData/BattleData/MapData/MapSize", mapsize);
MapDataManager::getSingleton().mMapSize = mapsize;
std::vector<std::string> arealist = datalibrary->getChildList("GameData/BattleData/MapData/Area");
std::vector<std::string>::iterator ite = arealist.begin();
for( ; ite != arealist.end(); ite++)
{
Area area(str(boost::format("GameData/BattleData/MapData/Area/%1%/CoordList")%(*ite)));
MapDataManager::getSingleton().mMapArea.insert(std::make_pair(*ite, area));
}
Terrain::getSingleton().createTerrain();
std::string music;
datalibrary->getData("GameData/StoryData/MusicName", music);
AudioSystem::getSingleton().playStream(music,true,2000);
return true;
}
示例9: getAttackRolls
AttackInfo BattleSquad::getAttackRolls(bool rangedattack,bool asdefender, int d)
{
DataLibrary *datalib = DataLibrary::getSingletonPtr();
AttackInfo attackinfo;
int soildernum = getUnitNum();
int atktime = floor((-0.010907f) * soildernum * soildernum + 1.37256f * soildernum+ 8.638347f + 0.5f);
if(asdefender)
{
attackinfo.AtkTime = atktime * getAttr(ATTR_CONTER,ATTRCALC_FULL) / 10.0f;
}
else
{
attackinfo.AtkTime = atktime;
}
float atkf;
if(rangedattack)
{
atkf = getAttr(ATTR_RANGEDATTACK, ATTRCALC_FULL);
}
else
{
atkf = getAttr(ATTR_ATTACK, ATTRCALC_FULL);
float formation;
formation = getAttr(ATTR_FORM, ATTRCALC_FULL);
formation = (formation < 0.0f)?0.0f:formation;
formation = formation * soildernum / 50.0f;
int formtype = getFormation();
int mydir = getDirection();
int side = GetSide(mydir,d);
formation *= GetFormationBonus(side, formtype);
atkf += formation;
}
attackinfo.Atk = atkf;
std::string soilderid = getSoilderId();
float randomness;
datalib->getData(std::string("StaticData/SoilderData/") + soilderid + std::string("/Randomness"),randomness);
attackinfo.Randomness = randomness;
return attackinfo;
}
示例10: Trigger
void MapDataManager::Trigger(std::string triggertype, LuaTempContext * tempcontext)
{
if(tempcontext == NULL)
return;
DataLibrary* datalib = DataLibrary::getSingletonPtr();
std::vector<std::string> triggerlist;
triggerlist = datalib->getChildList("GameData/BattleData/Trigger");
std::vector<std::string>::iterator ite;
for(ite = triggerlist.begin(); ite != triggerlist.end(); ite++)
{
std::string datapath = std::string("GameData/BattleData/Trigger/") + (*ite);
int active;
datalib->getData(datapath,active);
if(!active)
continue;
std::string type;
datalib->getData(datapath + std::string("/type"),type);
if(type != triggertype)
continue;
std::string context,filename,funcname;
datalib->getData(datapath + std::string("/file"),filename);
datalib->getData(datapath + std::string("/func"),funcname);
datalib->getData(datapath + std::string("/context"),context);
LuaSystem::getSingleton().executeFunction(filename,funcname,context,tempcontext);
}
}
示例11: getTerrainType
float MapDataManager::getCovert(int x, int y, int faction)
{
TerrainType t = getTerrainType(x,y);
GroundType g = getGroundType(x,y);
float terraincost;
float groundcost;
std::string ground;
DataLibrary::getSingleton().getData(str(boost::format("GameData/BattleData/MapData/Ground/G%1%")%g),ground);
bool re = DataLibrary::getSingleton().getData(str(boost::format("StaticData/GroundData/%1%/GroundModifier/Covert")%ground), groundcost);
re = DataLibrary::getSingleton().getData(std::string("StaticData/TerrainData/Terrain") + Ogre::StringConverter::toString(t) + std::string("/GroundModifier/Covert"), terraincost);
DataLibrary* datalib = DataLibrary::getSingletonPtr();
std::string path = std::string("GameData/BattleData/MapData/Map/M") + Ogre::StringConverter::toString(getGridId(x, y));
std::string groundobj;
float groundobjcost = 0.0f;
re = datalib->getData(path + std::string("/MapObjType"), groundobj, true);
if(re)
{
path = str(boost::format("StaticData/MapObjType/%1%/GroundModifier/Covert")%groundobj);
re = datalib->getData(path, groundobjcost);
}
return groundcost + terraincost + groundobjcost;
}
示例12: loadMapObj
void MapLoader::loadMapObj()
{
DataLibrary* datalibrary = DataLibrary::getSingletonPtr();
Terrain* terrain = Terrain::getSingletonPtr();
std::string datapath("GameData/BattleData/MapData/MapObjModleInfo");
std::vector<std::string> childlist;
childlist = datalibrary->getChildList(datapath);
if(childlist.size()>0)
{
for(unsigned int n = 0; n < childlist.size(); n++)
{
std::string meshname;
int x,y,dir;
datalibrary->getData(datapath + std::string("/") + childlist[n] + std::string("/Mesh"),meshname);
datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridX"),x);
datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridY"),y);
datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/Direction"),dir);
int index;
index = terrain->createMapObj(x,y,meshname, dir);
datalibrary->setData(datapath + std::string("/") + childlist[n] + std::string("/Index"),index);
}
}
datapath = "GameData/BattleData/MapData/MapParticleInfo";
childlist = datalibrary->getChildList(datapath);
if(childlist.size()>0)
{
for(unsigned int n = 0; n < childlist.size(); n++)
{
std::string particlename;
int x,y;
datalibrary->getData(datapath + std::string("/") + childlist[n] + std::string("/Particle"),particlename);
datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridX"),x);
datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridY"),y);
int index;
index = terrain->createMapParticle(x,y,particlename);
datalibrary->setData(datapath + std::string("/") + childlist[n] + std::string("/Index"),index);
}
}
}
示例13: useSkillAt
bool BattleSquad::useSkillAt(int x, int y, std::string skillid)
{
if(canUseSkill(skillid) != SKILLSTATE_AVAILABLE)
return false;
DataLibrary* datalib = DataLibrary::getSingletonPtr();
std::string skillpath = getPath() + std::string("/Skill/") + skillid;
std::string skillinfopath = std::string("StaticData/SkillData/")+ skillid;
std::string skillscript;
datalib->getData(skillinfopath + std::string("/Script"),skillscript);
LuaTempContext* context = new LuaTempContext;
context->strMap.insert(std::make_pair("squadid", getSquadId()));
context->intMap.insert(std::make_pair("targetx", x));
context->intMap.insert(std::make_pair("targety", y));
context->intMap.insert(std::make_pair("castsuccess", 0));
bool re = LuaSystem::getSingleton().executeFunction(skillscript, "useskill" , skillpath + std::string("/ScriptContext"), context);
if(re)
{
if(context->intMap["castsuccess"] == 1)
{
float apcost = getSkillApCost(skillid);
float apleft = getActionPoint() - apcost;
setActionPoint(apleft);
int aptype = SKILLAPTYPE_BATTLE;
datalib->getData(skillinfopath + "/APType", aptype);
if(aptype != SKILLAPTYPE_DEFENCE)
{
apcost = getAPTypeCostModify(aptype);
apcost += 1.0f;
setAPTypeCostModify(aptype, apcost);
}
int cooldown;
datalib->getData(skillinfopath + "/CoolDown", cooldown);
datalib->setData(skillpath + "/CoolDown", cooldown);
}
}
delete context;
return false;
}
示例14: if
std::vector<BattleSquad::ActiveSkillInfo> BattleSquad::GetActiveSkillList()
{
std::vector<ActiveSkillInfo> skilllist;
DataLibrary* datalib = DataLibrary::getSingletonPtr();
ActiveSkillInfo skillinfo;
//ÅжÏÒƶ¯
if(canMove() == SKILLSTATE_AVAILABLE)
{
skillinfo.skillid = "move";
skillinfo.apcost = 0;
skillinfo.available = true;
skilllist.push_back(skillinfo);
skillinfo.skillid = "turn";
skillinfo.apcost = 0;
skillinfo.available = true;
skilllist.push_back(skillinfo);
}
else if(canMove() == SKILLSTATE_NOTAVAILABLE)
{
skillinfo.skillid = "move";
skillinfo.apcost = 0;
skillinfo.available = false;
skilllist.push_back(skillinfo);
}
//ÅжÏÕóÐÍ
switch(canChangeFormation(Loose))
{
case SKILLSTATE_AVAILABLE:
skillinfo.skillid = "looseformation";
skillinfo.apcost = getChangeFormationApCost(Loose);
skillinfo.available = true;
skilllist.push_back(skillinfo);
break;
case SKILLSTATE_NOTAVAILABLE:
skillinfo.skillid = "looseformation";
skillinfo.apcost = getChangeFormationApCost(Loose);
skillinfo.available = false;
skilllist.push_back(skillinfo);
break;
}
switch(canChangeFormation(Line))
{
case SKILLSTATE_AVAILABLE:
skillinfo.skillid = "lineformation";
skillinfo.apcost = getChangeFormationApCost(Line);
skillinfo.available = true;
skilllist.push_back(skillinfo);
break;
case SKILLSTATE_NOTAVAILABLE:
skillinfo.skillid = "lineformation";
skillinfo.apcost = getChangeFormationApCost(Line);
skillinfo.available = false;
skilllist.push_back(skillinfo);
break;
}
switch(canChangeFormation(Circular))
{
case SKILLSTATE_AVAILABLE:
skillinfo.skillid = "circularformation";
skillinfo.apcost = getChangeFormationApCost(Circular);
skillinfo.available = true;
skilllist.push_back(skillinfo);
break;
case SKILLSTATE_NOTAVAILABLE:
skillinfo.skillid = "circularformation";
skillinfo.apcost = getChangeFormationApCost(Circular);
skillinfo.available = false;
skilllist.push_back(skillinfo);
break;
}
//ÅжÏÖ÷¶¯¼¼ÄÜ
std::vector<std::string> activeskills;
activeskills = datalib->getChildList(mPath + "/Skill");
std::vector<std::string>::iterator ite;
for(ite = activeskills.begin(); ite != activeskills.end(); ite++)
{
switch(canUseSkill(*ite))
{
case SKILLSTATE_AVAILABLE:
skillinfo.skillid = (*ite);
skillinfo.apcost = getSkillApCost(*ite);
skillinfo.available = true;
skilllist.push_back(skillinfo);
break;
case SKILLSTATE_NOTAVAILABLE:
skillinfo.skillid = (*ite);
skillinfo.apcost = getSkillApCost(*ite);
skillinfo.available = false;
skilllist.push_back(skillinfo);
break;
}
}
return skilllist;
}
示例15: loadMapFormFile
bool MapLoader::loadMapFormFile(std::string mapname)
{
int mapsize;
Terrain* terrain = Terrain::getSingletonPtr();
DataLibrary* datalibrary = DataLibrary::getSingletonPtr();
std::string path = ".\\..\\Media\\Map\\" + mapname;
//ticpp::Document *doc = new ticpp::Document();
rapidxml::xml_document<> doc;
//doc.LoadFile(path,TIXML_ENCODING_UTF8);
Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(mapname, "Data", true);
char* s=new char[stream->size()+1];
stream->read(s,stream->size());
s[stream->size()]='\0';
doc.parse<0>(s);
std::string str1;
//载入地图名字,介绍和脚本名
//ticpp::Element *element = doc.FirstChildElement("MapName");
rapidxml::xml_node<> * element = doc.first_node("MapName");
//element->GetText(&str1);
str1 = element->value();
datalibrary->setData("GameData/BattleData/MapData/MapName", StringTable::getSingleton().getString(str1));
//delete element;
//element = doc.FirstChildElement("MapScript");
element = doc.first_node("MapScript");
//element->GetText(&str1);
str1 = element->value();
datalibrary->setData("GameData/BattleData/MapData/MapScript", str1);
//delete element;
element = doc.first_node("MapMini");
//element->GetText(&str1);
if (element!=NULL)
{
str1 = element->value();
}
else
{
str1="MiniMap1.png";
}
datalibrary->setData("GameData/BattleData/MapData/MapMini", str1);
//element = doc.FirstChildElement("MapInfo");
element = doc.first_node("MapInfo");
//element->GetText(&str1);
str1 = element->value();
datalibrary->setData("GameData/BattleData/MapData/MapInfo",str1);
//delete element;
//element = doc.FirstChildElement("MapLoadBG");
element = doc.first_node("MapLoadBG");
//element->GetText(&str1);
str1 = element->value();
datalibrary->setData("GameData/BattleData/MapData/MapLoadBG",str1);
//delete element;
//载入地图地形信息
//element = doc.FirstChildElement("MapSize");
element = doc.first_node("MapSize");
//element->GetText(&mapsize);
mapsize = Ogre::StringConverter::parseUnsignedInt(element->value());
MapDataManager::getSingleton().mMapSize = mapsize;
datalibrary->setData("GameData/BattleData/MapData/MapSize", mapsize);
//delete element;
//element= doc.FirstChildElement("MapGround");
element = doc.first_node("MapGround");
//ticpp::Iterator<ticpp::Element> child;
rapidxml::xml_node<> *child = element->first_node();
std::string datapath;
//for(child = child.begin(element); child != child.end(); child++)
for(; child; child =child->next_sibling())
{
std::string layer,type,texture;
//child->GetValue(&layer);
layer = child->name();
//child->GetAttribute("Type",&type);
rapidxml::xml_attribute<> *attr = child->first_attribute("Type");
type = attr->value();
//child->GetAttribute("Texture",&texture);
attr = child->first_attribute("Texture");
texture = attr->value();
datapath = str(boost::format("GameData/BattleData/MapData/Ground/%1%")%layer);
datalibrary->setData(datapath, type);
datapath = str(boost::format("GameData/BattleData/MapData/Ground/%1%Tex")%layer);
datalibrary->setData(datapath, texture);
}
//delete element;
//element = doc.FirstChildElement("MapData");
element = doc.first_node("MapData");
//element->GetText(&str1);
str1 = element->value();
for(int y = 0; y < mapsize; y++)
{
for(int x = 0; x < mapsize; x++)
//.........这里部分代码省略.........