edu.gatech.cs2335.lemmings.file
Class LevelReader

java.lang.Object
  extended byedu.gatech.cs2335.lemmings.file.LevelReader

public class LevelReader
extends java.lang.Object

Allows us to read level data, maps and other nice stuff. The string passed in to any of the "load" methods is basically the id of the level. The loader then tests if there is a directory with the same name in the levels list. If there is one, then it loads the level from it. If there is no such directory, then is appends a .lmf extension to it and checks wether there is a file with that name. If there is, it extracts the file and then loads the level from that. If there is no such file, then the loading fails and null is returned.

Version:
1.0
Author:
Vladimir Urazov

Method Summary
 java.lang.String findNextLevel(java.lang.String id)
          Given the id of a level, finds the next level.
static LevelReader getInstance()
          Access method for the INSTANCE property.
 java.lang.String[] getLevelList()
          Returns the list of all levels available.
 Level loadLevel(java.lang.String name)
          Loads the level with the name specified if possible.
 LevelData loadLevelData(java.lang.String name)
          Loads the data for the level with the specified name.
 Map loadMap(java.lang.String name)
          Loads the map for the level with the specified name.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LevelReader getInstance()
Access method for the INSTANCE property.

Returns:
the current value of the INSTANCE property

getLevelList

public java.lang.String[] getLevelList()
Returns the list of all levels available. The elements in the list returned are String ids of the available levels.

Returns:
The array of ids of the levels.

findNextLevel

public java.lang.String findNextLevel(java.lang.String id)
Given the id of a level, finds the next level. Basically, if the level id cannot be found in the list, returns the first element of the list. If the level id is the last level, returns null.

Parameters:
id - a String value
Returns:
a String value

loadLevel

public Level loadLevel(java.lang.String name)
Loads the level with the name specified if possible. Otherwise, returns null.

Parameters:
name - The name of the level to load.
Returns:
Level

loadMap

public Map loadMap(java.lang.String name)
Loads the map for the level with the specified name.

Parameters:
name - a String value
Returns:
a Map value

loadLevelData

public LevelData loadLevelData(java.lang.String name)
Loads the data for the level with the specified name.

Parameters:
name - The name of the level to load the data for.
Returns:
LevelData

main

public static void main(java.lang.String[] args)
Parameters:
args - args