コード例 #1
0
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);
    }
}
コード例 #2
0
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;
}
コード例 #3
0
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;
}
コード例 #4
0
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;
}
コード例 #5
0
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
0
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);
		}
	}
}
コード例 #7
0
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;
}
コード例 #8
0
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;
}
コード例 #9
0
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;
}
コード例 #10
0
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;
}
コード例 #11
0
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++)
		{
			int index = y * mapsize + x;
			char datapathtemp[64];
			sprintf_s(datapathtemp, 64, "GameData/BattleData/MapData/Map/M%d", MapDataManager::getSingleton().getGridId(x, y));
			std::string datapath = datapathtemp;
			if(str1[index * 2] == 'l')
			{
				bool iscliff = false;
				for(int i = y - 1; i < y + 2; i ++)
				{
					for(int j =  x - 1; j < x + 2; j++)
					{
						int u = (i<0)?0:i;
						u = (u >= mapsize)?mapsize-1:u;
						int v = (j<0)?0:j;
						v = (v >= mapsize)?mapsize-1:v;
						int tempindex = u * mapsize + v;
						if(str1[tempindex * 2] == 'h' )
						{	
							iscliff = true;
						}
					}
				}
				if(iscliff)
					datalibrary->setData(datapath + "/TerrainType", Cliff);
				else
					datalibrary->setData(datapath + "/TerrainType", LowGround);
			}
			else if(str1[index * 2] == 'w')
			{
				datalibrary->setData(datapath + "/TerrainType", Water);
			}
			else if(str1[index * 2] == 'h')
			{
				datalibrary->setData(datapath + "/TerrainType", HighGround);
			}
			else if(str1[index * 2] == 'r')
			{
				datalibrary->setData(datapath + "/TerrainType", Ramp);
			}

			if(str1[index * 2+1] == 'g')
			{
				datalibrary->setData(datapath + "/GroundType", GreenLand);
			}
			else if(str1[index * 2+1] == 'd')
			{
				datalibrary->setData(datapath + "/GroundType", Desert);
			}
			else if(str1[index * 2+1] == 'w')
			{
				datalibrary->setData(datapath + "/GroundType", Swamp);
			}
			else if(str1[index * 2+1] == 's')
			{
				datalibrary->setData(datapath + "/GroundType", Snow);
			}
		}
	}
	//delete element;

	//element = doc.FirstChildElement("MapObject");
	element = doc.first_node("MapObject");
	//for(child = child.begin(element); child != child.end(); child++)
	for(child = element->first_node(); child; child =child->next_sibling())
	{
		std::string objname;
		//child->GetValue(&objname);
		objname = child->name();
		datapath = std::string("GameData/BattleData/MapData/MapObjModleInfo/") + objname;
		int objx,objy, objdir;
		std::string meshname,objtype;
		//child->GetAttribute("GridX",&objx);
		rapidxml::xml_attribute<> *attr = child->first_attribute("GridX");
		objx = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("GridY",&objy);
		attr = child->first_attribute("GridY");
		objy = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("Mesh",&meshname);
		attr=child->first_attribute("Mesh");
		meshname = attr->value();
		//child->GetAttribute("Type",&objtype);
		attr=child->first_attribute("Type");
		objtype = attr->value();
		attr=child->first_attribute("Direction");
		objdir = Ogre::StringConverter::parseInt(attr->value());
		datalibrary->setData(datapath + "/GridX", objx);
		datalibrary->setData(datapath + "/GridY", objy);
		datalibrary->setData(datapath + "/Mesh", meshname);
		datalibrary->setData(datapath + "/Direction", objdir);
		//物品类型脚本
		std::string mapobjscript("none");
		datalibrary->getData(str(boost::format("StaticData/MapObjType/%1%/Script")%objtype), mapobjscript);
		datapath = std::string("GameData/BattleData/MapData/Map/M") + Ogre::StringConverter::toString(MapDataManager::getSingleton().getGridId(objx, objy)) + std::string("/MapObjType");
		if(mapobjscript != "none")
		{
			MapObjScriptInfo scriptinfo;
			scriptinfo.x = objx;
			scriptinfo.y = objy;
			scriptinfo.script = mapobjscript;
			scriptinfo.path = datapath + "/ScriptContext";
			mMapObjScriptInfo.push(scriptinfo);
		}
		datalibrary->setData(datapath, objtype);
		datalibrary->setData(datapath + "/MapObjModuleId", objname);
	}
	//delete element;

	//element = doc.FirstChildElement("MapEffect");
	element = doc.first_node("MapEffect");
	//for(child = child.begin(element); child != child.end(); child++)
	for(child = element->first_node(); child; child =child->next_sibling())
	{
		std::string particlename;
		//child->GetValue(&particlename);
		particlename = child->name();
		datapath = std::string("GameData/BattleData/MapData/MapParticleInfo/") + particlename;
		int particlex,particley;
		std::string name;
		//child->GetAttribute("GridX",&particlex);
		rapidxml::xml_attribute<> *attr = child->first_attribute("GridX");
		particlex = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("GridY",&particley);
		attr = child->first_attribute("GridY");
		particley = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("Type",&name);
		attr = child->first_attribute("Type");
		name = attr->value();
		datalibrary->setData(datapath + "/GridX", particlex);
		datalibrary->setData(datapath + "/GridY", particley);
		datalibrary->setData(datapath + "/Type", name);
	}

	terrain->createTerrain();
	//delete element;

	//载入区域信息
	//element = doc.FirstChildElement("MapArea");
	element = doc.first_node("MapArea");
	//for(child = child.begin(element); child != child.end(); child++)
	for(child = element->first_node(); child; child =child->next_sibling())
	{
		std::string areaname;
		//child->GetValue(&areaname);
		areaname = child->name();
		datapath = std::string("GameData/BattleData/MapData/Area/") + areaname;
		Area area(datapath + "/CoordList");
		std::vector<Crood> croodVec;
		//ticpp::Iterator<ticpp::Element> childchild;
		rapidxml::xml_node<> *childchild = child->first_node();
		//for(childchild = childchild.begin(child.Get()); childchild != childchild.end(); childchild++)
		for(; childchild; childchild=childchild->next_sibling())
		{
			std::string coordname;
			//childchild->GetValue(&coordname);
			coordname = childchild->name();
			int x;
			int y;
			//childchild->GetAttribute("X",&x);
			rapidxml::xml_attribute<> *attr = childchild->first_attribute("X");
			x = Ogre::StringConverter::parseInt(attr->value());
			//childchild->GetAttribute("Y",&y);
			attr = childchild->first_attribute("Y");
			y = Ogre::StringConverter::parseInt(attr->value());
			croodVec.push_back(Crood(x, y));
		}
		area.setCroodVec(croodVec);
		MapDataManager::getSingleton().mMapArea.insert(std::make_pair(areaname, area));

	}
	//delete element;

	//载入队伍信息
	//element = doc.FirstChildElement("MapTeam");
	element = doc.first_node("MapTeam");
	for(int n = 2; n < 5; n++)
	{
		std::string name = std::string("Team") + Ogre::StringConverter::toString(n);
		std::string factionid;
		//ticpp::Element* subelement = element->FirstChildElement(name);
		child = element->first_node(name.c_str());
		//subelement->GetAttribute("TeamFaction",&factionid);
		rapidxml::xml_attribute<> *attr = child->first_attribute("TeamFaction");
		factionid = attr->value();
		datalibrary->setData(std::string("GameData/BattleData/Team/")+ name+ "/FactionId", factionid);
		if(factionid != "none")
		{
			//subelement->GetAttribute("TeamType",&factionid);
			attr = child->first_attribute("TeamType");
			factionid = attr->value();
			datalibrary->setData(std::string("GameData/BattleData/Team/")+ name+ "/Relation", factionid);
		}
		//delete subelement;
	}
	std::string playerfactionid;
	datalibrary->getData("GameData/StoryData/Faction",playerfactionid);
	datalibrary->setData("GameData/BattleData/Team/Team1/FactionId",playerfactionid);
	datalibrary->setData("GameData/BattleData/Team/Team1/Relation","player");
	//delete element;

	//载入部队信息
	//element = doc.FirstChildElement("MapSquad");
	element = doc.first_node("MapSquad");
	MapSquadInfo mapsquadinfo;
	//for(child = child.begin(element); child != child.end(); child++)
	for(child = element->first_node(); child;child = child->next_sibling())
	{
		std::string teamid;
		//child->GetValue(&teamid);
		teamid = child->name();
		if(teamid == "Team1")
			mapsquadinfo.team = 1;
		else if(teamid == "Team2")
			mapsquadinfo.team = 2;
		else if(teamid == "Team3")
			mapsquadinfo.team = 3;
		else
			mapsquadinfo.team = 4;
		datapath = std::string("GameData/BattleData/SquadList");
		//ticpp::Iterator<ticpp::Element> childchild;
		rapidxml::xml_node<> *childchild = child->first_node();
		//for(childchild = childchild.begin(child.Get()); childchild != childchild.end(); childchild++)
		for(; childchild; childchild =childchild->next_sibling())
		{
// 			std::string squadid;
// 			std::string squadtype;
			//childchild->GetValue(&mapsquadinfo.squadId);
			mapsquadinfo.squadId = childchild->name();
// 			int x;
// 			int y;
// 			Direction d;
// 			int unitnum;
// 			int morale;
			//childchild->GetAttribute("Type",&mapsquadinfo.squadTempId);
			rapidxml::xml_attribute<> *attr = childchild->first_attribute("Type");
			mapsquadinfo.squadTempId = attr->value();
			//childchild->GetAttribute("GridX",&mapsquadinfo.x);
			attr = childchild->first_attribute("GridX");
			mapsquadinfo.x = Ogre::StringConverter::parseInt(attr->value());
			//childchild->GetAttribute("GridY",&mapsquadinfo.y);
			attr = childchild->first_attribute("GridY");
			mapsquadinfo.y = Ogre::StringConverter::parseInt(attr->value());
			//childchild->GetAttribute("UnitNum",&mapsquadinfo.unitNum);
			attr = childchild->first_attribute("UnitNum");
			mapsquadinfo.unitNum = Ogre::StringConverter::parseInt(attr->value());
			//childchild->GetAttribute("Direction",&mapsquadinfo.dir);
			attr = childchild->first_attribute("Direction");
			mapsquadinfo.dir = Ogre::StringConverter::parseInt(attr->value());
			mMapSquadInfo.push(mapsquadinfo);
// 			AVGSquadManager::getSingleton().addSquad(squadid,squadtype, datapath);
// 			int type;
// 			Formation f;
// 			datalibrary->getData(datapath + std::string("/") + squadid + std::string("/Type"), type );
// 			if(type == SQUAD_NORMAL)
// 				f = Line;
// 			else
// 				f = Loose;
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/GridX"), x, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/GridY"), y, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/UnitNumber"), unitnum, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/Direction"), d, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/Formation"), f, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/TeamId"), teamid, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/CreateType"), MapSquad, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/ActionPoint"), 0.0f, true );
// 			datalibrary->setData(datapath + std::string("/") + squadid + std::string("/Morale"), morale, true );
		}
	}
	//delete element;
	delete []s;
	return true;
}
コード例 #12
0
bool BattleSquad::init(std::string srcpath, int team, int unitnum, int x, int y, int d)
{
	if(!Squad::init(srcpath))
		return false;
	DataLibrary *datalib = DataLibrary::getSingletonPtr();
	setTeam(team);
	setGridX(x);
	setGridY(y);
	setDirection(d);

	setUnitNum(unitnum);
	int squadtype2;
	datalib->getData(srcpath + std::string("/Type"), squadtype2);
	if(squadtype2 == SQUAD_NORMAL)
	{
		setUnitMaxNum(unitnum);
		setFormation(Line);
	}
	else
	{
		setUnitMaxNum(20);
		setFormation(Loose);
	}

	float covert;
	covert = getAttr(ATTR_COVERT, ATTRCALC_FULL);
	if(covert > 0.0f)
	{
		switch(getFaction())
		{
		case 0:
			setViewbyPlayer(1);
			setViewbyEnemy1(0);
			setViewbyEnemy2(0);
			setViewbyEnemy3(0);
			break;
		case 1:
			setViewbyPlayer(0);
			setViewbyEnemy1(1);
			setViewbyEnemy2(0);
			setViewbyEnemy3(0);
			break;
		case 2:
			setViewbyPlayer(0);
			setViewbyEnemy1(0);
			setViewbyEnemy2(1);
			setViewbyEnemy3(0);

			break;
		case 3:
			setViewbyPlayer(0);
			setViewbyEnemy1(0);
			setViewbyEnemy2(0);
			setViewbyEnemy3(1);
			break;
		}
	}
	else
	{
		setViewbyPlayer(1);
		setViewbyEnemy1(1);
		setViewbyEnemy2(1);
		setViewbyEnemy3(1);
	}

	setAmbushPlayer(0);
	setAmbushEnemy1(0);
	setAmbushEnemy2(0);
	setAmbushEnemy3(0);

	setActionPoint(0.0f);
	setAPSetup(0.0f);
	setAPBattle(0.0f);
	return true;
}
コード例 #13
0
float BattleSquad::getAttr(int attrtype , int calctype)
{
	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	std::vector<std::string> modifierlist = datalib->getChildList(mPath + std::string("/ModifierList"));
	if(modifierlist.size() == 0)
		return 0.0f;
	if(attrtype == ATTR_RANGEDDEFENCE )
		attrtype = ATTR_DEFENCE;
	float base = 0.0f;
	float mbouse = 0.0f;
	float mbane = 0.0f;
	float resist = 0.0f;
	float cbouse = 0.0f;
	float cbane = 0.0f;
	std::vector<std::string>::iterator ite;
	for(ite = modifierlist.begin(); ite != modifierlist.end(); ite++)
	{
		int type = ATTRMODIFIER_BASE;
		float attrval = 0.0f;
		std::string datapath = mPath + std::string("/ModifierList/") + (*ite);
		datalib->getData(datapath + std::string("/Type"), type);
		switch(attrtype)
		{
		case ATTR_ATTACK:
			datalib->getData(datapath + std::string("/Attack"), attrval);
			break;
		case ATTR_RANGEDATTACK:
			datalib->getData(datapath + std::string("/RangedAttack"), attrval);
			break;
		case ATTR_DEFENCE:
			datalib->getData(datapath + std::string("/Defence"), attrval);
			break;
		case ATTR_FORM:
			datalib->getData(datapath + std::string("/Formation"), attrval);
			break;
		case ATTR_INITIATIVE:
			datalib->getData(datapath + std::string("/Initiative"), attrval);
			break;
		case ATTR_ACTIONPOINT:
			datalib->getData(datapath + std::string("/ActionPoint"), attrval);
			break;
		case ATTR_DETECTION:
			datalib->getData(datapath + std::string("/Detection"), attrval);
			break;
		case ATTR_COVERT:
			datalib->getData(datapath + std::string("/Covert"), attrval);
			break;
		case ATTR_TOUGHNESS:
			datalib->getData(datapath + std::string("/Toughness"), attrval);
			break;
		case ATTR_CONTER:
			datalib->getData(datapath + std::string("/Conter"), attrval);
			break;
		}
		switch(type)
		{
		case ATTRMODIFIER_BASE:
			base += attrval;
			break;
		case ATTRMODIFIER_MAGIC:
			if(attrval > mbouse)
				mbouse = attrval;
			if(attrval < mbane)
				mbane = attrval;
			break;
		case ATTRMODIFIER_COMMAND:
			if(attrval > cbouse)
				cbouse = attrval;
			if(attrval < cbane)
				cbane = attrval;
			break;
		case ATTRMODIFIER_RESISTANCE:
			if(attrval > resist)
				resist = attrval;
			break;
		}
	}
	float bouse = cbouse + mbouse;
	float bane = cbane + mbane;
	float terrainbouse = 0.0f;
	switch(attrtype)
	{
		case ATTR_DEFENCE:
			terrainbouse = MapDataManager::getSingleton().getDefModify(getGridX(), getGridY(), getTeam());
			break;
		case ATTR_COVERT:
			terrainbouse = MapDataManager::getSingleton().getCovert(getGridX(), getGridY(), getTeam());
			break;
	}
	if(terrainbouse > 0.0f)
		bouse += terrainbouse;
	else
		bane += terrainbouse;
	if(bane < -resist)
	{
		bane += resist;
		resist = 0.0f;
	}
	else
	{
		bane = 0.0f;
		resist += bane;
	}

	bouse = bouse + bane;
	switch(calctype)
	{
	case ATTRCALC_FULL:
		return base + bouse;
		break;
	case ATTRCALC_ONLYBASE:
		return base;
		break;
	case ATTRCALC_ONLYBONUS:
		return bouse;
		break;
	}
	return 0.0f;
}
コード例 #14
0
ファイル: Terrain.cpp プロジェクト: weimingtom/fdux-slg-game
bool Terrain::createTerrain()
{

	if(mMainViewport == NULL) 
		mMainViewport = Core::getSingleton().mCamera->getViewport();
	Ogre::CompositorManager::getSingleton().addCompositor(mMainViewport, "DemoCompositor");
	Ogre::CompositorManager::getSingleton().setCompositorEnabled(mMainViewport, "DemoCompositor", true);

	mMapData = MapDataManager::getSingletonPtr();
	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	int terrainszie = mMapData->getMapSize() + 2 * MAPBOLDER + 1;

	Core::getSingleton().mSceneMgr->setSkyBox(true, "SkyBox",200);

	Ogre::GpuSharedParametersPtr sharedparams = Ogre::GpuProgramManager::getSingleton().getSharedParameters("TestSharedParamsName");
	float border = mMapData->getMapSize() * 12.0f;
	sharedparams->setNamedConstant("border", border);

	//创建灯光
	Core::getSingleton().mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
	mLight = Core::getSingleton().mSceneMgr->createLight("TerrainLight");
	mLight->setType(Ogre::Light::LT_DIRECTIONAL);
	mLight->setPosition(-500.0f,500.0f, 500.0f);
	mLight->setDirection(1.0f, -1.0f, -1.0f);
	mLight->setDiffuseColour(Ogre::ColourValue(0.5f, 0.5f,0.5f));
	mLight->setSpecularColour(Ogre::ColourValue(0.8f, 0.8f,0.8f));

	//设置深度图投影
	Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName("shadowdepthmap");
	if(tex.isNull())
		tex = Ogre::TextureManager::getSingleton().createManual("shadowdepthmap",
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 2048, 2048, 0, Ogre::PF_FLOAT16_R, Ogre::TU_RENDERTARGET);
	mShadowDepthMapTarget = tex->getBuffer()->getRenderTarget();
	Ogre::Viewport* vp = mShadowDepthMapTarget->addViewport(CameraContral::getSingleton().getShadowMapCamera());
	vp->setSkiesEnabled(false);
	vp->setOverlaysEnabled(false);
	vp->setVisibilityMask(VISMASK_OPAQUE);
	vp->setMaterialScheme("WriteDepthMap");
	vp->setBackgroundColour(Ogre::ColourValue(1.0f,1.0f,1.0f));
	mShadowDepthMapTarget->addListener(this);
	//弱爆了……
	Ogre::MaterialPtr mat;
	mat = Ogre::MaterialManager::getSingleton().getByName("TerrainTile");
	Ogre::AliasTextureNamePairList texAliasList;
	std::string texname;
	datalib->getData("GameData/BattleData/MapData/Ground/G0Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	datalib->getData("GameData/BattleData/MapData/Ground/G1Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse1",texname));
	datalib->getData("GameData/BattleData/MapData/Ground/G2Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse2",texname));
	datalib->getData("GameData/BattleData/MapData/Ground/G3Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse3",texname));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat1");
	datalib->getData("GameData/BattleData/MapData/Ground/G0Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat2");
	datalib->getData("GameData/BattleData/MapData/Ground/G1Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat3");
	datalib->getData("GameData/BattleData/MapData/Ground/G2Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat4");
	datalib->getData("GameData/BattleData/MapData/Ground/G3Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat1");
	datalib->getData("GameData/BattleData/MapData/Ground/G0Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat2");
	datalib->getData("GameData/BattleData/MapData/Ground/G1Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat3");
	datalib->getData("GameData/BattleData/MapData/Ground/G2Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat4");
	datalib->getData("GameData/BattleData/MapData/Ground/G3Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	//创建地面Mesh
	mTerrainNode = Core::getSingleton().mSceneMgr->getRootSceneNode()->createChildSceneNode("TerrainNode");

	int numVertices = terrainszie * terrainszie * VERTEX_QUAD;
	int numIndex = terrainszie * terrainszie * VERTEX_PREQUAD;
	Ogre::MeshPtr mTerrainMesh = Ogre::MeshManager::getSingleton().createManual("TerrianMesh",
		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	Ogre::SubMesh* subMesh  = mTerrainMesh->createSubMesh();
	subMesh->useSharedVertices=false;
	subMesh->setMaterialName("TerrainTile");

	// 创建顶点数据结构
	subMesh->vertexData = new Ogre::VertexData();
	subMesh->vertexData->vertexStart = 0;
	subMesh->vertexData->vertexCount = numVertices;

	//顶点声明与缓冲区绑定
	Ogre::VertexDeclaration* vdecl = subMesh->vertexData->vertexDeclaration;
	Ogre::VertexBufferBinding* vbind = subMesh->vertexData->vertexBufferBinding;

	//设置顶点数据结构
	size_t offsetUV = 0;
	vdecl->addElement(VERTEX_POS_BINDING, 0, Ogre::VET_FLOAT3,Ogre::VES_POSITION);//向顶点添加一个位置元素
	vdecl->addElement(VERTEX_NOM_BINDING, 0, Ogre::VET_FLOAT3,Ogre::VES_NORMAL);
	for(int i = 0 ; i < TEXTURE_COUNT ; i ++)
	{
		offsetUV += vdecl->addElement (VERTEX_UV_BINDING, offsetUV, Ogre::VET_FLOAT2,  Ogre::VES_TEXTURE_COORDINATES , i).getSize();
	}

	// 创建世界坐标顶点缓冲区
	Ogre::HardwareVertexBufferSharedPtr vbufPos =
		Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
		vdecl->getVertexSize(VERTEX_POS_BINDING),
		numVertices,
		Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
	vbind->setBinding(VERTEX_POS_BINDING, vbufPos);

	Ogre::HardwareVertexBufferSharedPtr vbufNOM =
		Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
		vdecl->getVertexSize(VERTEX_NOM_BINDING),
		numVertices,
		Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
	vbind->setBinding(VERTEX_NOM_BINDING, vbufNOM);

	// 创建纹理坐标顶点缓冲区
	Ogre::HardwareVertexBufferSharedPtr vbufUV =
		Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
		vdecl->getVertexSize(VERTEX_UV_BINDING),
		numVertices,
		Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
	vbind->setBinding(VERTEX_UV_BINDING, vbufUV);

	// 创建索引缓冲区
	Ogre::HardwareIndexBufferSharedPtr indexBuffer =
		Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
		Ogre::HardwareIndexBuffer::IT_16BIT ,
		numIndex,
		Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);

	//创建地形
	float* pBufferPos = (float*)vbufPos->lock(Ogre::HardwareBuffer::HBL_DISCARD);
	float* pBufferUV = (float*)vbufUV->lock(Ogre::HardwareBuffer::HBL_DISCARD);
	float* pBufferNom = (float*)vbufNOM->lock(Ogre::HardwareBuffer::HBL_DISCARD);

	float startpos = - terrainszie * TILESIZE / 2;
	for(int y = 0 ; y < terrainszie; y ++)
	{
		for(int x = 0 ; x < terrainszie; x ++)
		{
			createTile(x, y, startpos + x * TILESIZE, startpos + y * TILESIZE, pBufferPos, pBufferUV, pBufferNom);
			pBufferPos += 3 * VERTEX_QUAD ;
			pBufferNom += 3 * VERTEX_QUAD ;
			pBufferUV += 2 * VERTEX_QUAD * 4;
		}
	}

	vbufNOM->unlock();
	vbufUV->unlock();
	vbufPos->unlock();

	//写入索引信息
	// 锁定索引缓冲区
	Ogre::ushort* pIdx = (Ogre::ushort*)indexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
	for(int y = 0 ; y < terrainszie ; y ++)
	{
		for(int x = 0 ; x < terrainszie ; x ++)
		{
			Ogre::ushort iIndexTopLeft = (x + y * terrainszie) * VERTEX_QUAD;
			Ogre::ushort iIndexTopRight = iIndexTopLeft + 1;
			Ogre::ushort iIndexBottomLeft = iIndexTopLeft + 2;
			Ogre::ushort iIndexBottomRight = iIndexTopLeft + 3;
			*pIdx++ = iIndexBottomLeft;
			*pIdx++ = iIndexBottomRight;
			*pIdx++ = iIndexTopLeft;

			*pIdx++ = iIndexBottomRight;
			*pIdx++ = iIndexTopRight;
			*pIdx++ = iIndexTopLeft;
		}
	}
	indexBuffer->unlock();
	//设置模型的的索引数据
	subMesh->indexData->indexBuffer = indexBuffer;
	subMesh->indexData->indexStart = 0;
	subMesh->indexData->indexCount =numIndex;

	Ogre::AxisAlignedBox meshBounds(startpos,0,startpos,
		-startpos,5,-startpos);
	mTerrainMesh->_setBounds(meshBounds);

	mTerrainEntity = Core::getSingleton().mSceneMgr->createEntity("TerrianMesh");
	mTerrainNode->attachObject(mTerrainEntity);
	mTerrainEntity->setQueryFlags(QUERYMASK_TERRAIN);
	mTerrainNode->setPosition(0,0,0);

	//创建水面
	tex = Ogre::TextureManager::getSingleton().getByName("reflection");
	if(tex.isNull())
		tex = Ogre::TextureManager::getSingleton().createManual("reflection",
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
	mReflectionTarget = tex->getBuffer()->getRenderTarget();
	mReflectionTarget->addViewport(Core::getSingleton().mCamera)->setOverlaysEnabled(false);
	mReflectionTarget->addListener(this);
// 	mat = Ogre::MaterialManager::getSingleton().getByName("ReflectionWater");
// 	tech = mat->getTechnique(0);
// 	pass = tech->getPass(0);
// 	tu =  pass->getTextureUnitState(1);
// 	tu->setTextureName(tex->getName());

	mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, WATERHEIGHT);

	mWaterNode = Core::getSingleton().mSceneMgr->getRootSceneNode()->createChildSceneNode("WaterNode");
	mWaterObject = Core::getSingleton().mSceneMgr->createManualObject("WaterObject");

	mWaterObject->begin("DemoWater",Ogre::RenderOperation::OT_TRIANGLE_LIST);
	startpos += TILESIZE/2;
	for(int y = 0; y < terrainszie; y++)
		for(int x = 0; x < terrainszie; x++)
		{
			if(mMapData->getTerrainType(x -MAPBOLDER, y -MAPBOLDER ) == Water)
			{
				mWaterObject->position(startpos + x * TILESIZE, 0.0f, startpos + y * TILESIZE);
				mWaterObject->colour(1.0f,1.0f,1.0f);
				mWaterObject->normal(0.0f,1.0f,0.0f);
				mWaterObject->textureCoord(0.0f,0.0f);
				mWaterObject->position(startpos + (x+1) * TILESIZE, 0.0f, startpos + (y+1) * TILESIZE);
				mWaterObject->colour(1.0f,1.0f,1.0f);
				mWaterObject->normal(0.0f,1.0f,0.0f);
				mWaterObject->textureCoord(1.0f,1.0f);
				mWaterObject->position(startpos + (x+1) * TILESIZE, 0.0f, startpos + y * TILESIZE);
				mWaterObject->colour(1.0f,1.0f,1.0f);
				mWaterObject->normal(0.0f,1.0f,0.0f);
				mWaterObject->textureCoord(1.0f,0.0f);
				mWaterObject->position(startpos + (x+1) * TILESIZE, 0.0f, startpos + (y+1) * TILESIZE);
				mWaterObject->colour(1.0f,1.0f,1.0f);
				mWaterObject->normal(0.0f,1.0f,0.0f);
				mWaterObject->textureCoord(1.0f,1.0f);
				mWaterObject->position(startpos + x * TILESIZE, 0.0f, startpos + y * TILESIZE);
				mWaterObject->colour(1.0f,1.0f,1.0f);
				mWaterObject->normal(0.0f,1.0f,0.0f);
				mWaterObject->textureCoord(0.0f,0.0f);
				mWaterObject->position(startpos + x * TILESIZE, 0.0f, startpos + (y+1) * TILESIZE);
				mWaterObject->colour(1.0f,1.0f,1.0f);
				mWaterObject->normal(0.0f,1.0f,0.0f);
				mWaterObject->textureCoord(0.0f,1.0f);
			}
		}
	mWaterObject->end();

	mWaterNode->attachObject(mWaterObject);
	mWaterNode->setPosition(0,WATERHEIGHT,0);


	//设置摄像机移动范围
	
	float minx = 0.0f;// = ( - (float)(terrainszie - 2 * MAPBOLDER) / 2.0f - 1.0f) * TILESIZE ;
	getWorldCoords(0,0,minx,minx);
	minx -= TILESIZE/2;
	CameraContral::getSingleton().setMoveRect(minx, minx);
	CameraContral::getSingleton().resetCamera();

	//深度投影测试
// 	Ogre::MeshManager::getSingleton().createPlane("testplane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
// 		mWaterPlane, 64, 64, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z);
// 	Ogre::Entity* testent = Core::getSingleton().mSceneMgr->createEntity("testplaneent", "testplane");
// 	testent->setMaterialName("DepthTest");
// 	Ogre::SceneNode* testnode = Core::getSingleton().mSceneMgr->getRootSceneNode()->createChildSceneNode();
// 	testnode->attachObject(testent);
// 	testnode->setPosition(0.0f,10.0f,0.0f);
	return true;
}