// Use this for initialization
	void Start () 
	{
		waveManager = GameObject.Find("WaveManager").GetComponent<HeroWaveManager>();
		waveGUIManager = GameObject.Find("WaveGUIManager").GetComponent<WaveGUIManager>();
		
		monsterSpawners = GameObject.FindGameObjectsWithTag("MonsterSpawner");
		
		particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleManager>();
		
		pausedSpawners = new List<MonsterSpawner>(8);
		
		pauseSprite = GameObject.Find("PauseToggleButton").GetComponent<tk2dSprite>();
	}
	void Awake()
	{
		startWavePanel = GameObject.Find("WavePanel").GetComponent<UIInteractivePanel>();
		startWaveButton = GameObject.Find("startWaveButton").GetComponent<UIButton>();	
		
		waveInfoPanel = GameObject.Find("WaveInfoPanel").GetComponent<UIPanel>();
		waveInfoScrollList = GameObject.Find("WaveInfoScrollList").GetComponent<UIScrollList>();
		waveInfoPanel.BringIn();
		
		heroWaveManager = GameObject.Find("WaveManager").GetComponent<HeroWaveManager>();
		heroWaveManager.onAllWaveEnemiesDefeated += HandleAllWaveEnemiesDefeated;
		heroWaveManager.onNextWaveReady += HandleOnNextWaveReady;
		heroWaveManager.onSpawnNewHero += HandleOnSpawnNewHero;
		
		waveButton = GameObject.Find("startWaveButton").GetComponent<tk2dSprite>();
		waveButton.spriteId = waveButton.GetSpriteIdByName(waveStartButtonName);
	}
	void Awake () 
	{		
		TextAsset XMLTextAsset = (TextAsset) Resources.Load(levelPath + levelName);
		xmlDoc = new XmlDocument();
		xmlDoc.LoadXml(XMLTextAsset.text);		
		
		startingGold = int.Parse(xmlDoc.SelectSingleNode("/level/startingGold").InnerText);
		
		entityFactory = EntityFactory.GetInstance();
		monsterGUIManager = GameObject.Find("MonsterGUIManager").GetComponent<MonsterGUIManager>();
		
		waveManager = GameObject.Find("WaveManager").GetComponent<HeroWaveManager>();
		
		if (playerStatusManager == null)
			playerStatusManager = GameObject.Find("PlayerStatusManager").GetComponent<PlayerStatusManager>();
				
		//waveManager.onSpawnNewHero += HandleOnSpawnNewHero;
		waveManager.onWaveCompletedSpawning += HandleOnWaveCompletedSpawning;	
		waveManager.onAllWaveEnemiesDefeated += HandleOnWaveEnemiesDefeated;	
		waveManager.onNextWaveStarted += HandleOnNextWaveStarted;		
	}