Ejemplo n.º 1
0
void PlayerDetails::fromXml(XML& xml){
	mMesh = xml.getString("ship", "mesh");
	mDll = xml.getString("ship", "dll");
	mShield = xml.getFloat("ship", "shield");
	mShieldRegen = xml.getFloat("ship", "shield_regen");
	mArmour = xml.getFloat("ship", "armour");
	mEnergy = xml.getFloat("ship", "energy");
	mEnergyRegen = xml.getFloat("ship", "energy_regen");
	mAmmo = xml.getInt("ship", "ammo");
	mSpeed = xml.getFloat("ship", "speed");
	mDeathFX = xml.getString("death_fx");
	if (xml.getError() != XML_OK){
		mDeathFX = "";
	}

	{
		XMLIterator it(&xml);
		it.setElemName("ship>weaponchain");
		it.gotoZero();
		while(it.gotoNext()==true){
			WeaponChain wc(it.getElem());
			mWeaponChain.push_back(wc);
		}
	}{
		XMLIterator it(&xml);
		it.setElemName("ship>reactor");
		it.gotoZero();
		while(it.gotoNext()==true){
			mReactorNodes.push_back(it.getElem().getString("childName"));
		}
	}


/*
	XMLIterator it(&xml);
	it.setElemName("");
	it.gotoZero();
	it.gotoNext();
	XML elem;

	if (it.gotoNext() == false){
		throw("Ship Definition File Missing 3 Weapon Chain");
	}
	elem = it.getElem();

	if (it.gotoNext() == false){
		throw("Ship Definition File Missing 2 Weapon Chain");
	}
	elem = it.getElem();
	mSecondaryWeapon.fromXml(elem);

	if (it.gotoNext() == false){
		throw("Ship Definition File Missing 1 Weapon Chain");
	}
	elem = it.getElem();
	mSuperWeapon.fromXml(elem);*/
	int g=0;
}
Ejemplo n.º 2
0
	void Cell::createFromXml(XML* xml){
		/*mOverlay = mOverlayManager.create(getId());
		mOverlay->setZOrder(xml->getFloat("z"));
		mOverlay->show();*/

		//mZOrder = xml->getFloat("z");

		//mTrack = new RefinedTrack(xml, false);
		mX = new RefinedNumericTrack(xml, "posx");
		mY = new RefinedNumericTrack(xml, "posy");
		mAlpha = new RefinedNumericTrack(xml, "alpha");
		mScaleX = new RefinedNumericTrack(xml, "sclx");
		mScaleY = new RefinedNumericTrack(xml, "scly");

		//mAngle = new RefinedNumericTrack(xml, "angle");

		mPos.x = xml->getFloat("posx");
		mPos.y = xml->getFloat("posy");

		XMLIterator xmlIt(xml);


		/*xmlIt.setElemName("cell");
		xmlIt.gotoZero();
		while(xmlIt.gotoNext()==true){
			mElement.push_back(new Cell(&(xmlIt.getElem())));
		}*/
		xmlIt.setElemName("cell>image");
		xmlIt.gotoZero();
		
		while(xmlIt.gotoNext()==true){
			Image* img = new Image();
			img->init(&(xmlIt.getElem()));
			mElement.push_back(img);
			img->setDelta(Ogre::Vector2(-1, -1));
			img->moveTimes(getTimeOn());
		}
		xmlIt.setElemName("cell>textzone");
		xmlIt.gotoZero();
		while(xmlIt.gotoNext()==true){
			XML xml = xmlIt.getElem();
			string txttype = xml.getString("type");
			Text* txt;
			if (txttype == "rolling"){
				txt = new RollingText();
			}else if (txttype == "static"){
				txt = new StaticText();
			}else{
				txt = new StaticText();
			}
			txt->init(&(xmlIt.getElem()));
			txt->setFontStyle(FontStyleManager::getSingleton()->requestFontStyle(xmlIt.getElem().getString("style")));
			mElement.push_back(txt);
			txt->setDelta(Ogre::Vector2(-1, -1));
			txt->moveTimes(getTimeOn());
		}
	}
Ejemplo n.º 3
0
	WeaponDBE* WeaponDB::get(string id){
		for (list<WeaponDBE*>::iterator it = mEntry.begin();it!=mEntry.end();it++){
			if ((*it)->getId() == id){
				return (*it);
			};
		}
		File f(id+".xml", "media\\weapons\\weapons");
		XML* xml;
		if (f.error() != FILE_OK){
			throw("Error accessing file : "+id+" in context weapons\\weapons");
			xml = NULL;
		}else{
			xml = new XML(f.getStrContent());
		}
		string type = xml->getString("weapon","type");
		if (xml->getError() != XML_OK){
			throw("Error : Weapon requires type");
		}
		
		WeaponDBE* rv;
		if (type == "dll"){
			rv = new DLLWeaponDBE(id, *xml);
		}else if (type == "internal"){
			string subtype = xml->getString("weapon","subtype");
			if (xml->getError() != XML_OK){
				throw("Error : Weapon requires subtype");
			}
			if (subtype == "ammo"){
				rv = new AmmoWeaponDBE(id, *xml);
			}else if (subtype == "beam"){
				rv = new BeamWeaponDBE(id, *xml);
			}else{
				throw("Subtype : "+subtype+" not recognized");
			}
		}else{
			throw("Type : "+type+" not recognized");
		}
		//rv->setMount(launcher, mMount);
		delete xml;
		mEntry.push_back(rv);
		return rv;

	}
Ejemplo n.º 4
0
void DroneDBE::init(XML& dronestatXml, XML& objectMovementXml){
	/*File f(getId()+".xml", "media/drones");
	if (f.error() != FILE_OK){
		throw("Drone without an XML file ("+getId()+")");
	}
	XML* xml;
	xml = new XML();
	xml->setContent((char*)f.content());*/
	
	//XML* xml = new XML(getId()+".xml", "media/drones");

	mMaxTime = dronestatXml.getFloat("maxtime");

	std::string s;
	s = dronestatXml.getString("class");
	if (dronestatXml.getError() != XML_OK){
		throw("Drone class undefined ("+getId()+")");
	}


	/*File file(s+".xml", "media/drones/classes");
	if (file.error() != FILE_OK){
		throw("Drone without an XML class file ("+getId()+")");
	}
	XML* classXml;
	classXml = new XML();
	classXml->setContent((char*)file.content());*/
	XML* classXml = new XML(s+".xml", "media/drones/classes");

	mScale = vector3FromString(classXml->getString("drone", "scale"));
	if (classXml->getError() != XML_OK){
		mScale = Ogre::Vector3(1,1,1);
	}/*else{
		int g=0;
	}*/


	mMaxLife = classXml->getFloat("drone", "life");
	if (classXml->getError() != XML_OK) 
		throw("Class File Missing Argument : "+getId()+" (life)");
	mScore= classXml->getInt("drone", "score");
	if (classXml->getError() != XML_OK) 
		throw("Class File Missing Argument : "+getId()+" (score)");
	
	string dllName= classXml->getString("drone", "dll");
	if (classXml->getError() == XML_OK){
		#ifdef _DEBUG
			string name = dllName+"d";
			mDll = LoadLibrary(name.c_str());
		#else
			mDll = LoadLibrary(dllName.c_str());
		#endif
		//mDllCallback = (DLLCallback)::GetProcAddress(weaponModule, "getInstance");
	}else{
		mDll = NULL;
		//mDllCallback = NULL;
	}
	
	{
	XMLIterator it(classXml);
	it.setElemName("drone>death");
	it.gotoZero();
	while(it.gotoNext() != false){
		DEATH_BEHAVIOUR db;
		
		
		XML dbxml = it.getElem();
		db.mFX = dbxml.getString("fx");
		if (dbxml.getError() != XML_OK) db.mFX = "";
		db.mDLLCustomCode = dbxml.getString("dll");
		if (dbxml.getError() != XML_OK) db.mDLLCustomCode = "";
		db.mTime = dbxml.getFloat("time");
		if (dbxml.getError() != XML_OK) db.mTime = 0;

#if 0
		XMLIterator dit(&dbxml);
		dit.setElemName("death>debris");
		dit.gotoZero();
		while(dit.gotoNext() != false){

			db.mDebris.push_back(dit.getElem());

			/*DEBRIS_DETAIL dd;
			XML ditElem = dit.getElem();
			string dir = ditElem.getString("direction");
			if (dir == "forward"){
				dd.mDirection = DEBRIS_DIRECTION_FORWARD;
			}else if (dir == "random"){
				dd.mDirection = DEBRIS_DIRECTION_RANDOM;
			}else{
				throw("Unsupported debris direction : "+dir);
			}
			dd.mSpinMultiplier = ditElem.getFloat("spin");
			dd.mMesh = ditElem.getString("mesh");
			dd.mPython = ditElem.getString("python");
			if (ditElem.getError() != XML_OK){
				dd.mPython = "";
			}
			



			db.mDebris.push_back(dd);*/
		};
#endif
		mDeath.push_back(db);
	}
	}


	{
	XMLIterator it(classXml);
	it.setElemName("drone>child");
	it.gotoZero();
	while(it.gotoNext() != false){
		DRONE_CHILD dc;
		XML xml = it.getElem();
		dc.mName = xml.getString("drone");
		dc.mBone = xml.getString("bone");
		if (xml.getError() != XML_OK){
			dc.mBone = "";
		}
		dc.mLabel = xml.getString("label");
		int f = xml.getInt("forwardhits");
		if (f == 1){
			dc.mForward = true;
		}else{
			dc.mForward = false;
		}
		Ogre::Vector3 v = vector3FromString(xml.getString("delta"));
		if (xml.getError() != XML_OK){
			dc.mDelta = Ogre::Vector3(0,0,0);
		}else{
			dc.mDelta = v;
		}
		mChild.push_back(dc);

		
	}
	}












	//if (classXml->getError() != XML_OK) throw("Class File Missing Argument : "+getId()+" (deathtime)");

	string resource = classXml->getString("drone", "resource_path");
	/*if (classXml->getError() == XML_OK){
		this->addResourceContext(resource,"models");
	}*/


	string cn = classXml->getString("drone", "children");
	if (classXml->getError() == XML_OK){
		setChildrenName(cn);
	}else{
		setChildrenName(".");
	}
	setMeshName(classXml->getString("drone", "mesh"));
	if (classXml->getError() != XML_OK){
		throw("class without drone mesh");
	}

	mResourceContext = classXml->getString("drone", "resource_path");
	if (classXml->getError() != XML_OK){
		mResourceContext = mMeshName;
	}
	
	{
		XMLIterator it(classXml);
		it.setElemName("drone>weapon");
		it.gotoZero();
		//FIRING_TIME ft;
		while(it.gotoNext() != false){
			addWeaponInfo(&it.getElem());
		};
	}



	XMLIterator it(classXml);
	it.setElemName("drone>resource");
	it.gotoZero();
	//FIRING_TIME ft;
	while(it.gotoNext() != false){
		/*if (it.getElem().getString("type") != "meshmaterial"){
			addResource(it.getElem().getString("name"), it.getElem().getString("type"));
		}else{
			addMeshResources(it.getElem().getString("name"));
		}*/
		if (it.getElem().getError() != XML_OK){
			throw("Class File Resource Missing Argument : "+getId()+" (name)");
		}
	};

	it.setElemName("drone>resourcecontext");
	it.gotoZero();
	while(it.gotoNext() != false){
		string s = it.getElem().getString("path");
		if (it.getElem().getError() != XML_OK){
			throw("Class File Resource Content Missing Argument : "+getId()+" (path)");
		}
		//addResourceContext(s);
	};
}
Ejemplo n.º 5
0
void Level::init(string filename){
	_resetStdVar();
	mViewport= NULL;

	//mProgressBar->draw(Core::getSingleton()->getWindow());
	//File::setLoadCallback(mProgressBar);
	ResourceGroupManager::getSingleton().createResourceGroup("Level");

	//File* lf;
	XML* lx;
	/*lf = new File(filename, "media\\levels");
	if (lf->error() != FILE_OK){
		throw((string)("Level file not found : "+filename));
	}
	lx = new XML(lf->getStrContent());*/
	lx = new XML(filename, "media\\levels");

	string loadingSoundString;
	loadingSoundString = lx->getString("level","loadingsound");
	if (lx->getError() == XML_OK){
		mLoadingSound = SoundManager::getSingleton()->createSound(loadingSoundString+".ogg", true);
		mLoadingSound->play();
	}else{
		mLoadingSound = NULL;
	}
	mTimer = 0;
	
	/*mContainer->setSolid(false);
	mContainer->setType(OBJ_TYPE_CONTAINER);
	mContainer->build();*/

	
	//openLevelFile(filename);
	//Util::Log("Loading World...");

	
	XMLIterator XMLIt(lx);
	XMLIt.setElemName("level>segment");
	XMLIt.gotoZero();
	
	//LevelSegment* seg;


	while(XMLIt.gotoNext()==true){
		XML elem = XMLIt.getElem();
		addSegment(
			elem.getString("name"), 
			"media\\levels", 
			elem.getString("name").substr(0,elem.getString("name").length()-4),
			elem.getFloat("length"), elem.getString("append")=="1");

		
		/*File* f;
		XML elem = XMLIt.getElem();
		f = new File(elem.getString("name"),"levels");
		Util::Log("Loading : "+elem.getString("name"), 4);
		if (f->error() != FILE_OK){
			throw((string)("Level file not found : "+(string)filename));
		}else{
			XML xml;
			xml.setContent(f->getStrContent());
			addSegment(
				xml, 
				elem.getString("name").substr(0,elem.getString("name").length()-4),
				elem.getFloat("length"));
			
			//mCurrentSegment = new LevelSegment();
			//mCurrentSegment->build(&xml, elem.getString("name").substr(0,elem.getString("name").length()-4), elem.getFloat("length"));
			//mSegment.push_back(mCurrentSegment);
		}
		delete f;*/
	}
	if (mSegment.size() == 0) throw ("Your level has 0 segments.");
	delete lx;
	//delete lf;

//	closeLevelFile();
}
Ejemplo n.º 6
0
void DefaultDroneDBE::init(XML& dronestatXml, XML& objectMovementXml){
		string coord = objectMovementXml.getString("transform_c");
		if (objectMovementXml.getError() != XML_OK){
			coord = "macro:zero_transform";
		}else{
			int g=0;
		}
		mTransformCoordinator = dynamic_cast<Coordinator::TransformCoordinator*>(Coordinator::CoordinatorFactory::getSingleton()->get(coord));
			
		mMaxTime = mTransformCoordinator->getLength();

		{
			XMLIterator it(&objectMovementXml);
			it.setElemName("##anything##>goanim");
			it.gotoZero();
		
			while(it.gotoNext() != false){
				XML* goxml = new XML(it.getElem().getContent());
				mGoAnim.push_back(goxml);
			};
		}{
			XMLIterator it(&objectMovementXml);
			it.setElemName("##anything##>anim");
			it.gotoZero();
		
			while(it.gotoNext() != false){
				XML* goxml = new XML(it.getElem().getContent());
				mAnim.push_back(goxml);
			};
		}

		mMaxTime = 9999;

		Parent::init(dronestatXml,objectMovementXml);

		/*XML xml3;
		xml3 = xml->extractElem("level>dronestats");
		if (xml->getError()!=XML_OK){
			throw("WTF?");
		}*/

		{
		XMLIterator it(&dronestatXml);
		it.setElemName("##anything##>fire");
		it.gotoZero();
		FIRING_TIME ft;
		std::string g;

		while(it.gotoNext() != false){
			XML itXml = it.getElem();
			string time = itXml.getString("time");
			string mount = itXml.getString("mount");
			vector<string> t;
			vector<string> m;
			Tokenize(time,t,",");
			Tokenize(mount,m,",");

			vector<string>::iterator ti;
			vector<string>::iterator mi;
			string is = itXml.getString("inertia");
			if (itXml.getError() == XML_OK){
				if (is == "a"){ // as in actual;
					ft.inertia = Ogre::Vector3(FLT_MAX,FLT_MAX,FLT_MAX);
				}else{
					ft.inertia = vector3FromString(is);
				}
			}else{
				ft.inertia = Ogre::Vector3(0,0,0);
			}
			mi = m.begin();
			//for (mi = m.begin();mi!=m.end();mi++){
				for (ti = t.begin();ti!=t.end();ti++){
					//ft.mount = atoi((*m.begin()).c_str());
					if ((*ti).find("-") != string::npos){
						vector<string> i;
						Tokenize((*ti),i,"-");
						if (i.size() != 3){
							i.push_back("0");
							//throw("Invalid drone firing times range, requires 3 arguments ("+(*ti)+")");
						}
						float start, end, step;
						start = atof(i[0].c_str());
						end = atof(i[1].c_str());
						step = atof(i[2].c_str());

						ft.time = start;
						ft.firingOption = FIRING_START;
						for (mi = m.begin();mi!=m.end();mi++){
							ft.mount = atoi((*mi).c_str());
							mFiringTime.push_back(ft);
							ft.time +=step;
						}

						ft.time = end;
						ft.firingOption = FIRING_STOP;
						for (mi = m.begin();mi!=m.end();mi++){
							ft.mount = atoi((*mi).c_str());
							mFiringTime.push_back(ft);
							ft.time +=step;
						}

						
						/*for (float h=start;h<end;h+=step){
							ft.time = h;
							mFiringTime.push_back(ft);
							mi++;
							if (mi == m.end()) mi = m.begin();
							ft.mount = atoi((*mi).c_str());
						}*/
					}else{
						ft.mount = atoi((*m.begin()).c_str());
						ft.time = atof((*ti).c_str());
						ft.firingOption = FIRING_START;
						mFiringTime.push_back(ft);
						ft.time += .07;
						ft.firingOption = FIRING_STOP;
						mFiringTime.push_back(ft);
					}
				}
			//}
			//ft.time = itXml.getFloat("time");
			//ft.mount = itXml.getInt("mount");
			//if (itXml.getError() != XML_OK){
			//	ft.mount = 0;
			//}
			//ft.inertia = vector3FromString(itXml.getString("inertia"));
			//if (itXml.getError() != XML_OK){
				//ft.inertia = Ogre::Vector3(0,0,0);
			//}
		};

		}{

		/*XMLIterator it(xml2);
		it.setElemName("##anything##>anim");
		it.gotoZero();
		DRONE_TIMED_ANIM ft;
		while(it.gotoNext() != false){
			ft.time = it.getElem().getFloat("time");
			ft.label = it.getElem().getString("label");
			ft.loop = (it.getElem().getString("loop")=="true");
			mTimedAnim.push_back(ft);
		};*/
		
		}



}