private void Awake() { if (engine == null) { engine = new Engine(); initEngine(engine); } if (seeEvent == null) { seeEvent = new GameEvent(); seeEvent.AddListener(obstacle => { engine.SetValue("obstacle", obstacle) .Execute(onSee); }); } if (onEvent == null) { onEvent = new GameEvent(); onEvent.AddListener(obstacle => { engine.SetValue("obstacle", obstacle) .Execute(onNear); }); } if (startEvent == null) { startEvent = new StartEvent(); startEvent.AddListener(() => { engine.Execute(onStart); }); } }
public void Initialize(Transform _home, List <EnemySpawner> spawners) { uiController = GetComponent <UIController>(); home = _home; numspawners = spawners.Count; foreach (EnemySpawner spawner in spawners) { onWaveStart.AddListener(spawner.StartSpawning); onWaveEnd.AddListener(spawner.StopSpawning); } numWaves = waves.Length; waveIdx = -1; gameEnd = false; }