package { import flash.geom.Point; import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; public class DBMaps { private var main:Main; private var xml:XML; public function DBMaps($main:Main) { main = $main; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, loadXML); loader.load(new URLRequest("xml/dbMaps.xml")); } private function loadXML($e:Event):void { xml = new XML($e.target.data); main.xmlFileLoaded(); } //--------------------------------------------set/get-------------------------------------------- public function mapWidth($mapID:int):int { return xml.map[$mapID].width; } public function mapHeight($mapID:int):int { return xml.map[$mapID].height; } public function PlayerStart($mapID:int):Object { var temp:Object = new Object(); temp.coords = new Point(xml.map[$mapID].playerstart.x, xml.map[$mapID].playerstart.y); temp.rotation = xml.map[$mapID].playerstart.rot; return temp; } public function noOfAsteroids($mapID:int):int { return xml.map[$mapID].asteroid.length(); } public function getAsteroid($mapID:int, $asteroidID:int):Object { var temp:Object = new Object(); temp.coords = new Point(xml.map[$mapID].asteroid[$asteroidID].x, xml.map[$mapID].asteroid[$asteroidID].y); temp.rotation = xml.map[$mapID].asteroid[$asteroidID].rot; temp.type = xml.map[$mapID].asteroid[$asteroidID].type; return temp; } public function noOfAIShips($mapID:int):int { return xml.map[$mapID].aiship.length(); } public function getAIShip($mapID:int, $aishipID:int):Object { var temp:Object = new Object(); temp.coords = new Point(xml.map[$mapID].aiship[$aishipID].x, xml.map[$mapID].aiship[$aishipID].y); temp.rotation = xml.map[$mapID].aiship[$aishipID].rot; temp.allegiance = xml.map[$mapID].aiship[$aishipID].allegiance; temp.type = xml.map[$mapID].aiship[$aishipID].type; temp.weapon = xml.map[$mapID].aiship[$aishipID].weapon; return temp; } } }