Exemple #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);
        }
 private void HandleDeath(object sender, HealthEventArgs e)
 {
     OnDeath();
     e.Causer.GameObject.GetComponent <PlayerScore>()?.OnKill();
 }
Exemple #3
0
 private void OnHealthModified(object sender, HealthEventArgs e)
 {
     Debug.LogErrorFormat("Player {0} took some damage from {1}.", e.Causee.GetName(), e.Causer.GetName());
 }
 private void HandleDamage(object sender, HealthEventArgs e)
 {
     OnDamageTaken(e.Modification);
     e.Causer.GameObject.GetComponent <PlayerScore>()?.OnDamageDealt(e.Modification);
 }
Exemple #5
0
 private void OnDeath(object sender, HealthEventArgs e)
 {
     Debug.LogErrorFormat("Player {0} died thanks to {1}.", e.Causee.GetName(), e.Causer.GetName());
 }