Exemplo n.º 1
0
 protected virtual void OnOnTookDamage()
 {
     if (hurtClip.Length > 0)
     {
         GetComponent <AudioSource>().PlayOneShot(hurtClip[UnityEngine.Random.Range(0, hurtClip.Length)]);
     }
     OnTookDamage?.Invoke();
 }
Exemplo n.º 2
0
        public virtual void TakeDamage(float damageAmount)
        {
            if (IsAlive)
            {
                OnTookDamage?.Invoke();
                return;
            }

            Die();
        }
Exemplo n.º 3
0
        // --------------------------------------------------------------------------------------------
        private void TakeDamage(Unit sourceUnit, int amount)
        {
            int previousHealth = Health;

            Health = Mathf.Clamp(Health - amount, 0, Health);

            OnTookDamage?.Invoke(this, new DamageEventArgs(sourceUnit, this, previousHealth, Health, Health <= 0));

            if (Health <= 0)
            {
                Destroy();
            }
        }
Exemplo n.º 4
0
    //public enum Lane //deprecated
    //{
    //    Median,
    //    Lateral
    //}


    // Start is called before the first frame update
    void Start()
    {
        ReachedTheEnd = false;
        OnTookDamage  = new OnTookDamage();
    }