예제 #1
0
    /// <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);
    }
예제 #2
0
    /// <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);
        }
    }
예제 #3
0
 public void TriggerUnitDied(Unit unit)
 {
     UnitDied?.Invoke(unit);
 }
예제 #4
0
 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);
 }
예제 #6
0
 public void UnitHasDied(SPoint position)
 {
     UnitDied?.Invoke(this, position);
 }
 public void InvokeUnitDied()
 {
     UnitDied?.Invoke();
 }