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

    Constructors 
    Constructor Description
    Level()  
    Level​(java.lang.String fileName)  
  • Method Summary

    Modifier and Type Method Description
    void generatePath​(org.w3c.dom.NodeList coordinateList)  
    int getAeroplaneHP()  
    int getAeroplaneSpeed()  
    CrossroadRegion getCrossroad()  
    int getCurrentIndex()  
    Region[][] getGrid()
    For testing.
    int getLevelCount()  
    org.w3c.dom.Document getLevelsDoc()  
    Position getNextPathPosition​(org.w3c.dom.NodeList coordinateList, int index)
    getNextRegion() - Gets the position (x and y coordinates) of next region.
    int getSoldierHP()  
    int getSoldierSpeed()  
    java.util.ArrayList getTeleportList()  
    java.util.ArrayList getTowerList()  
    int getWinCondition()
    getWinCondition - Reads and retrieves the specified win condition from xml.
    java.lang.String imageName()
    imageName() - Loads path source from current level in XML file and saves the image.
    void initGrid()
    initGrid() - Initiates grid with regions with specified rows and columns as its dimensions.
    void levelIncrement()
    levelIncrement() - Sets the new level.
    static void main​(java.lang.String[] args)  
    void readCrossroadList()
    readCrossroadList() - Reads crossroad regions from XML file, instantiates those accordingly and puts them in the Region grid.
    org.w3c.dom.Document readLevels​(java.lang.String fileName)
    readLevels() - Reads levels and puts them in
    int readNrColumns​(org.w3c.dom.Document doc, int index)
    getNrRows() - Reads column tag from xml.
    int readNrRows​(org.w3c.dom.Document doc, int index)
    readNrRows() - Reads row tag from xml.
    void readPathList()
    readPathList() - Reads path positions from XML file, creates instances of path regions and sets path regions next position.
    void readTeleportList()
    readTeleportList() - Reads teleport regions from XML file and instantiates those accordingly.
    void readTowerList()
    readTowerList() - Reads possible tower regions and number of towers from XML file and randomly chooses positions to place towers on.
    void readTroopSpecs()
    readTroopSpecs() - Reads the specifics, i.e.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.ParserConfigurationException
      java.io.IOException
      org.xml.sax.SAXException
    • Level

      public Level() throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
      Throws:
      javax.xml.parsers.ParserConfigurationException
      java.io.IOException
      org.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.SAXException
      readLevels() - Reads levels and puts them in
      Returns:
      Throws:
      javax.xml.parsers.ParserConfigurationException
      java.io.IOException
      org.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

      public Position getNextPathPosition​(org.w3c.dom.NodeList coordinateList, int index)
      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

      public CrossroadRegion getCrossroad()
    • getTeleportList

      public java.util.ArrayList getTeleportList()
    • getGrid

      public Region[][] 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.IOException
      org.xml.sax.SAXException
      javax.xml.parsers.ParserConfigurationException