// Use this for initialization
	void Start()
	{
		instance = this;

		LevelFinishedController.instance.setDecoyFixed (false);
		sizeX = LevelFinishedController.instance.getMazeSizeX();
		sizeZ = LevelFinishedController.instance.getMazeSizeZ();
		spaceX = planeSizeX / (sizeX * 2f);
		spaceZ = planeSizeZ / (sizeZ * 2f);

		string[,] grid = null;
		Puzzle puzzle = null;
		if (LevelFinishedController.instance.getPuzzleName() != null)
		{
			System.Type type = System.Type.GetType (LevelFinishedController.instance.getPuzzleName());
			puzzle = (Puzzle) ScriptableObject.CreateInstance(type);
			grid = puzzle.getGrid();
			puzzle.create();
		}

		labirynth = new Labirynth (sizeX, sizeZ, grid);
		labirynth.generate ();
		drawMachines ();
		drawDevice ();
		if (LevelFinishedController.instance.getPuzzleName() == null)
		{
			drawKeys (labirynth.getKeys ());
		}
		drawJumps ();
		drawSmallWalls (labirynth, 0);
		drawHorisontalWalls (labirynth, 0);
		drawVerticalWalls (labirynth, 0);
		hidePlayers (); // must be called before A*
		createNodes ();

		if (LevelFinishedController.instance.getPuzzleName() != null)
		{
			puzzle.finish();
		}
	}	
	public List<GameObject> createNewWalls()
	{
		labirynth = new Labirynth (sizeX, sizeZ, null);
		labirynth.generate ();

		List<GameObject> walls = new List<GameObject> ();
		walls.AddRange (drawHorisontalWalls (labirynth, -2.5f));
		walls.AddRange (drawVerticalWalls (labirynth, -2.5f));
		walls.AddRange (drawSmallWalls (labirynth, -2.5f));
								
		return walls;
	}