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