public void OnMonsterSelected(string monsterName) { if (monsterName != null && monsterName != string.Empty) { Debug.Log("Monster " + monsterName + " was selected."); guiOpen = false; MonsterInformation info = entityFactory.GetMonsterInfo(monsterName); if (playerStatusManager.Gold >= info.goldCost) { playerStatusManager.RemoveGold(info.goldCost); if (spawnerCallback != null) spawnerCallback(entityFactory.GetMonsterInfo(monsterName)); } else { Debug.Log("Could not afford monster."); spawnerCallback(null); } } else { spawnerCallback(null); Debug.Log("No monster was selected."); guiOpen = false; } spawnerCallback = null; }
/// <summary> /// Launches the monster GUI and returns the chosen monster to the last caller of this /// method at any given moment in time. /// </summary> /// <returns> /// The chosen monster. /// </returns> /// <param name='spawner'> /// The MonsterSpawner requesting that the user be allowed to choose a monster to spawn. /// </param> public void LaunchMonsterGUI1(MonsterSpawner spawner, MonsterSelectedForSpawner monsterChosenCallback) { //If we already have an active spawner set then deactivate it if (spawnerCallback != null) spawnerCallback(null); spawnerCallback = monsterChosenCallback; if (!guiOpen) { StartCoroutine(monsterGUIManager.coLaunchGUI(spawner)); guiOpen = true; } }