Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cause"></param>
        /// <param name="damage"></param>
        public void TakeDamage(Damager cause, int damage)
        {
            if (!CanBeHit(cause))
            {
                return;
            }

            CurrentHealth = Mathf.Max(0, CurrentHealth - damage);

            if (CurrentHealth > 0)
            {
                Hit();
            }
            else
            {
                Die();
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cause"></param>
        /// <returns></returns>
        protected bool CanBeHit(Damager cause)
        {
            if (Invulnerable)
            {
                return(false);
            }

            if (Immune(cause))
            {
                return(false);
            }

            if (cause.Dodgeable && Dodging)
            {
                return(false);
            }

            if (CurrentHitTimeout > 0)
            {
                return(false);
            }

            return(true);
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cause"></param>
 /// <returns></returns>
 protected override bool Immune(Damager cause)
 {
     return(!cause.GetComponent <Explosion>());
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cause"></param>
 /// <returns></returns>
 protected virtual bool Immune(Damager cause)
 {
     return(false);
 }