private void OnTriggerEnter(Collider other) { IDying idying = other.GetComponent <IDying>(); if (idying != null) { idying.Healing(); Destroy(gameObject); } }
/// <summary> /// Called when the selected dies. /// </summary> /// <param name="died">The died.</param> /// <exception cref="ArgumentNullException">died - The nothing can't die.</exception> private void OnDieSelected(IDying died) { if (died == null) { throw new ArgumentNullException(nameof(died), "The nothing can't die."); } if (lastSelected == died) { ClearSelected(); } }
private void OnCollisionEnter(Collision collision) { IDying idying = collision.transform.gameObject.GetComponent <IDying>(); if (idying != null) { if (GetComponent <Rigidbody>().velocity.y < -2) { idying.TakeDamage(damage); } } }
// Start is called before the first frame update private void OnTriggerEnter(Collider other) { IDying idying = other.GetComponent <IDying>(); if (idying != null) { Invoke("SpawnObj", 0); Invoke("SpawnObj", 0.2f); Invoke("SpawnObj", 0.4f); //StartCoroutine(SpawnObj(0.2f)); //StartCoroutine(SpawnObj(0.4f)); gameObject.SetActive(false); } }
/// <summary> /// Called when any unit has died. /// </summary> /// <param name="died">The died unit.</param> /// <exception cref="ArgumentNullException">died</exception> private void OnUnitDieHandler(IDying died) { if (died == null) { throw new ArgumentNullException(nameof(died)); } died.OnDie -= OnUnitDieHandler; if (died is Unit unit) { GetUnitsOfTeam(unit.Team)?.RemoveAll(unitKeeped => unitKeeped == unit); } }
private void OnTriggerEnter(Collider other) { IDying idying = other.GetComponent <IDying>(); if (idying != null) { idying.TakeDamage(damage); } if (isStatic) { return; } gameObject.SetActive(false); }
/// <summary> /// Heroes the died handler. Starts a hero resurrection timer. /// </summary> /// <param name="diedHero">The died hero.</param> /// <exception cref="ArgumentNullException">diedHero</exception> private void HeroDiedHandler(IDying diedHero) { if (diedHero.IsNullOrMissing()) { throw new ArgumentNullException(nameof(diedHero)); } if (!(diedHero is Hero hero)) { return; } var timer = new TimerCountdown(hero, $"{hero.UnitName} will reborn after", hero.RebornDelay); reviveTimers.Add(timer); timer.OnFinish += ReviveHero; OnHeroReviveTimerStart?.Invoke(timer); }
/// <summary> /// Called when any squad unit has died. /// </summary> /// <param name="died">The died.</param> private void OnUnitDieHandler(IDying died) { died.OnDie -= OnUnitDieHandler; if (died is Unit unit) { unit.OnHealthChanges -= OnUnitHealthChangesHandler; units.Remove(unit); if (units.Count > 0) { var changedHealth = GetChangedHealthArgs(); OnHealthChanges?.Invoke(changedHealth); } else { OnStopShowing?.Invoke(this); OnDie?.Invoke(this); } } }