/// <summary> /// Initialization for all event-related things /// </summary> void InitializeEvents() { reachedFinish = new UnitReachedFinish(); deathEvent = new UnitDied(); EventManager.AddTimeChangeListener(GoToTime); EventManager.AddPauseTimeListener(Pause); EventManager.AddReachedFinishInvoker(this); EventManager.AddUnitDeadInvoker(this); }
/// <summary> /// Like SetActive(), but script is responsive to Events /// </summary> void EnableObject(bool state) { enabled = state; transform.GetChild(0).gameObject.SetActive(state); //thisCollider.enabled = paused == state ? state : paused; thisCollider.enabled = state; if (state) { if (reachedFinish == null) { reachedFinish = new UnitReachedFinish(); } if (deathEvent == null) { deathEvent = new UnitDied(); } } if (!state) { deathEvent.Invoke(transform); } }
public void TriggerUnitDied(Unit unit) { UnitDied?.Invoke(unit); }
public static void InvokeUnitDied(Unit unit, Unit killer) { UnitDied?.Invoke(unit, killer); }
/// <summary> /// When the unit dies, stop the attack timer, unubscribe from the timer event and /// fires the death event. /// </summary> public void Dead() { _timer.Stop(); _timer.Tick -= _attack_timer_Tick; UnitDied?.Invoke(this, Team); }
public void UnitHasDied(SPoint position) { UnitDied?.Invoke(this, position); }
public void InvokeUnitDied() { UnitDied?.Invoke(); }