SHARE
TWEET

Untitled

a guest Jul 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using UnityEngine;
  3.  
  4. public class Character : MonoBehaviour, IDamagable {
  5.  
  6.     #region
  7.    
  8.     public event Action<IDamagable> OnKillTarget;
  9.     public event Action<float> OnHit;
  10.  
  11.     #endregion
  12.  
  13.     private CharacterStatus status;
  14.  
  15.     private void Awake () {
  16.         status = new Status ();
  17.     }
  18.  
  19.     public void Attack (IDamagable target) {
  20.         target.OnTakeDamage (status.TotalAttack);
  21.         if (target.IsDead) {
  22.             OnKillTarget?.Invoke (target);
  23.         }
  24.     }
  25.  
  26.     public void OnTakeDamage (float damage) {
  27.         status.HP -= damage;
  28.         OnHit?.Invoke (damage);
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top