当前位置: 首页>>代码示例>>C++>>正文


C++ DataLibrary::setData方法代码示例

本文整理汇总了C++中DataLibrary::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataLibrary::setData方法的具体用法?C++ DataLibrary::setData怎么用?C++ DataLibrary::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataLibrary的用法示例。


在下文中一共展示了DataLibrary::setData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:30,代码来源:BattleSquad.cpp

示例2: 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;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:19,代码来源:BattleSquad.cpp

示例3: 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);
		}
	}
}
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:39,代码来源:Maploader.cpp

示例4: 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;
	}
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:19,代码来源:BattleSquad.cpp

示例5: 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;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:38,代码来源:BattleSquad.cpp

示例6: 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++)
//.........这里部分代码省略.........
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:101,代码来源:Maploader.cpp


注:本文中的DataLibrary::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。