Package model
Class Level
java.lang.Object
model.Level
public class Level
extends java.lang.Object
***** CURRENTLY NOT IN USE. USE XMLPARSER.JAVA INSTEAD. *****
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidgeneratePath(org.w3c.dom.NodeList coordinateList)intgetAeroplaneHP()intgetAeroplaneSpeed()CrossroadRegiongetCrossroad()intgetCurrentIndex()Region[][]getGrid()For testing.intgetLevelCount()org.w3c.dom.DocumentgetLevelsDoc()PositiongetNextPathPosition(org.w3c.dom.NodeList coordinateList, int index)getNextRegion() - Gets the position (x and y coordinates) of next region.intgetSoldierHP()intgetSoldierSpeed()java.util.ArrayListgetTeleportList()java.util.ArrayListgetTowerList()intgetWinCondition()getWinCondition - Reads and retrieves the specified win condition from xml.java.lang.StringimageName()imageName() - Loads path source from current level in XML file and saves the image.voidinitGrid()initGrid() - Initiates grid with regions with specified rows and columns as its dimensions.voidlevelIncrement()levelIncrement() - Sets the new level.static voidmain(java.lang.String[] args)voidreadCrossroadList()readCrossroadList() - Reads crossroad regions from XML file, instantiates those accordingly and puts them in the Region grid.org.w3c.dom.DocumentreadLevels(java.lang.String fileName)readLevels() - Reads levels and puts them inintreadNrColumns(org.w3c.dom.Document doc, int index)getNrRows() - Reads column tag from xml.intreadNrRows(org.w3c.dom.Document doc, int index)readNrRows() - Reads row tag from xml.voidreadPathList()readPathList() - Reads path positions from XML file, creates instances of path regions and sets path regions next position.voidreadTeleportList()readTeleportList() - Reads teleport regions from XML file and instantiates those accordingly.voidreadTowerList()readTowerList() - Reads possible tower regions and number of towers from XML file and randomly chooses positions to place towers on.voidreadTroopSpecs()readTroopSpecs() - Reads the specifics, i.e.
-
Constructor Details
-
Level
public Level(java.lang.String fileName) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException- Throws:
javax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException
-
Level
public Level() throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException- Throws:
javax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException
-
-
Method Details
-
readLevels
public org.w3c.dom.Document readLevels(java.lang.String fileName) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXExceptionreadLevels() - Reads levels and puts them in- Returns:
- Throws:
javax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException
-
getWinCondition
public int getWinCondition()getWinCondition - Reads and retrieves the specified win condition from xml.- Returns:
- win condition as an int.
-
readNrRows
public int readNrRows(org.w3c.dom.Document doc, int index)readNrRows() - Reads row tag from xml.- Parameters:
doc- is the xml document to be read from.index- is the index that corresponds to the current level.
-
readNrColumns
public int readNrColumns(org.w3c.dom.Document doc, int index)getNrRows() - Reads column tag from xml.- Parameters:
doc- is the xml document to be read from.index- is the index that corresponds to the current level.
-
readPathList
public void readPathList()readPathList() - Reads path positions from XML file, creates instances of path regions and sets path regions next position. Saves start and goal region to Level attributes. If the region does not have a next region, i.e. is the goal, Position next will be set to null. -
generatePath
public void generatePath(org.w3c.dom.NodeList coordinateList) -
readTowerList
public void readTowerList()readTowerList() - Reads possible tower regions and number of towers from XML file and randomly chooses positions to place towers on. The specified number of towers are instantiated and put into towerList. -
readCrossroadList
public void readCrossroadList()readCrossroadList() - Reads crossroad regions from XML file, instantiates those accordingly and puts them in the Region grid. -
readTeleportList
public void readTeleportList()readTeleportList() - Reads teleport regions from XML file and instantiates those accordingly. The teleport regions are then put into the teleportList. -
imageName
public java.lang.String imageName()imageName() - Loads path source from current level in XML file and saves the image.- Returns:
- opened image.
-
initGrid
public void initGrid()initGrid() - Initiates grid with regions with specified rows and columns as its dimensions. Method is to be called before any read-method of Level class is called. -
getNextPathPosition
getNextRegion() - Gets the position (x and y coordinates) of next region.- Parameters:
coordinateList- is the list that contains the list with containing all coordinate nodes in xml.index- is the index of next coordinate.
-
levelIncrement
public void levelIncrement()levelIncrement() - Sets the new level. -
readTroopSpecs
public void readTroopSpecs()readTroopSpecs() - Reads the specifics, i.e. health points and speed for the troop types soldier and aeroplane respectively. -
getSoldierHP
public int getSoldierHP() -
getSoldierSpeed
public int getSoldierSpeed() -
getAeroplaneHP
public int getAeroplaneHP() -
getAeroplaneSpeed
public int getAeroplaneSpeed() -
getTowerList
public java.util.ArrayList getTowerList() -
getCrossroad
-
getTeleportList
public java.util.ArrayList getTeleportList() -
getGrid
For testing. -
getLevelsDoc
public org.w3c.dom.Document getLevelsDoc() -
getCurrentIndex
public int getCurrentIndex() -
getLevelCount
public int getLevelCount() -
main
public static void main(java.lang.String[] args) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException- Throws:
java.io.IOExceptionorg.xml.sax.SAXExceptionjavax.xml.parsers.ParserConfigurationException
-