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

            Die();
        }
예제 #3
0
파일: Unit.cs 프로젝트: njelly/GridStrategy
        // --------------------------------------------------------------------------------------------
        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();
            }
        }
예제 #4
0
파일: Enemy.cs 프로젝트: Rekoshe/TD-demo
    //public enum Lane //deprecated
    //{
    //    Median,
    //    Lateral
    //}


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