void LateUpdate() { if (show) { foreach (KeyValuePair <EnemySpawner, EnemySpawnerUI> pair in uiDictionary) { EnemySpawner spawner = pair.Key; EnemySpawnerUI spawnerUI = pair.Value; Vector3 pos = LevelManager.Instance.Camera.WorldToScreenPoint(spawner.transform.position + Vector3.up * uiOffset); if (pos.z > 0 && pos.z < 15) { spawnerUI.ToggleVisibility(true); spawnerUI.transform.position = pos; float value = Util.Utilities.Remap(pos.z, 15, 5, 0, 1); spawnerUI.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one * 0.5f, value); } else { spawnerUI.ToggleVisibility(false); } } } }
public void Show() { uiDictionary.Clear(); Wave wave = LevelManager.Instance.GetWave(); foreach (EnemySpawner spawner in wave.Spawners) { EnemySpawnerUI instance = Instantiate(spawnerUI, transform); foreach (KeyValuePair <string, int> pair in spawner.GetEnemies()) { instance.AddEnemy(pair.Key, pair.Value); } uiDictionary.Add(spawner, instance); } show = true; }