/*
 * JVirus is a PacMan clone, written in Java.
 *
 * Please read "http://jvirus.sourceforge.net/jvirus_licence.txt" for copyrights.
 * 
 * The sourcecode is designed and created with
 * Sun J2SDK 1.3 and Microsoft Visual J++ 6.0
 *
 * JVirus homepage: http://jvirus.sourceforge.net
 *
 * autor: Slawa Weis
 * email: slawaweis@animatronik.net
 *
 */

package org.game.JVirus;

import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.*;

import javax.swing.*;

import org.game.JVirus.res.*;

/**
 * static class for level loading. Only static methods here.
 *
 * @see org.game.JVirus.res.Resource
 */
public final class Levels
{
 /**
  * container for loaded levels
  */
 protected static Vector vecLevels = null;

 /**
  * if call first time load the levels, if second time only get vecLevels back.
  */
 public static Vector getLevels()
  {
  if(vecLevels != null)
    return vecLevels;

  vecLevels = new Vector();
  try
     {
     LineNumberReader lnr = new LineNumberReader(new InputStreamReader(Resource.class.getResourceAsStream("levelList.txt")));
     String line = null;
     int i = 0;
     while((line = lnr.readLine()) != null)
          {
          Matrix matrix = new Matrix(Resource.class.getResourceAsStream(line));
          matrix.levelNumber = i++;
          vecLevels.addElement(matrix);
          }
        }
  catch(IOException e)
       {
       e.printStackTrace();
       }

  return vecLevels;
  }

 /**
  * get the level count back
  */
 public static int getLevelCount()
  {
  return getLevels().size();
  }
}