Exemplo n.º 1
0
        private void OnTriggerEnter(Collider other)
        {
            IDying idying = other.GetComponent <IDying>();

            if (idying != null)
            {
                idying.Healing();
                Destroy(gameObject);
            }
        }
Exemplo n.º 2
0
        /// <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();
            }
        }
Exemplo n.º 3
0
        private void OnCollisionEnter(Collision collision)
        {
            IDying idying = collision.transform.gameObject.GetComponent <IDying>();

            if (idying != null)
            {
                if (GetComponent <Rigidbody>().velocity.y < -2)
                {
                    idying.TakeDamage(damage);
                }
            }
        }
Exemplo n.º 4
0
        // 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);
            }
        }
Exemplo n.º 5
0
        /// <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);
            }
        }
Exemplo n.º 6
0
        private void OnTriggerEnter(Collider other)
        {
            IDying idying = other.GetComponent <IDying>();

            if (idying != null)
            {
                idying.TakeDamage(damage);
            }
            if (isStatic)
            {
                return;
            }

            gameObject.SetActive(false);
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
        /// <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);
                }
            }
        }