// Use this for initialization    
	void Start ()
	{
		if (null == levelController)
		{
			levelController = new LevelLogic();
			levelController.createEmptyLevel(16, 16);
		}
		playerController = GetComponent<PlayerMan>();

        if(LevelManager.isActive()){
            levelDescription = LevelManager.getCurrentLevel();
        }

		/* Windows-proofing the text. We assume no OS9 or earlier. *crosses fingers* */
		string csvText = levelDescription.text.Replace("\r", "");

		var lineNumber = 0;
		var columnNumber = 0;
		foreach (string line in csvText.Split('\n'))
		{
		columnNumber = 0;
		foreach (string column in line.Split(','))
		{
		addTile(columnNumber, lineNumber, column);
		++columnNumber;
		}
		++lineNumber;
		}
		GameObject.FindGameObjectWithTag("MainCamera").transform.position = new Vector3(columnNumber / 2 * gridSize, -lineNumber / 2 * gridSize, -3);
		GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().orthographicSize = Math.Max((float)columnNumber / 2 * gridSize / 16 * 9, (float)lineNumber / 2 * gridSize);
	}