예제 #1
0
        public HealthEventArgs Modify(float amount, Damager causer)
        {
            if (IsDead)
            {
                return(null);
            }

            Current += amount;

            HealthEventArgs args = new HealthEventArgs(new Damager(Player), causer, amount);

            if (Current <= 0)
            {
                IsDead = true;
                OnDeath?.Invoke(this, args);
                return(args);
            }

            OnModified?.Invoke(this, new HealthEventArgs(new Damager(Player), causer, amount));
            return(args);
        }
예제 #2
0
 private void HandleDeath(object sender, HealthEventArgs e)
 {
     OnDeath();
     e.Causer.GameObject.GetComponent <PlayerScore>()?.OnKill();
 }
예제 #3
0
 private void OnHealthModified(object sender, HealthEventArgs e)
 {
     Debug.LogErrorFormat("Player {0} took some damage from {1}.", e.Causee.GetName(), e.Causer.GetName());
 }
예제 #4
0
 private void HandleDamage(object sender, HealthEventArgs e)
 {
     OnDamageTaken(e.Modification);
     e.Causer.GameObject.GetComponent <PlayerScore>()?.OnDamageDealt(e.Modification);
 }
예제 #5
0
 private void OnDeath(object sender, HealthEventArgs e)
 {
     Debug.LogErrorFormat("Player {0} died thanks to {1}.", e.Causee.GetName(), e.Causer.GetName());
 }