protected bool Apply(Collision collision) { if (collision.gameObject != null) { var health = collision.gameObject.GetComponentInParent <Health>(); if (health != null) { Debug.LogError("Point: " + collision.GetContact(0).point + "Normal: " + collision.GetContact(0).normal); GameManager.Instance. ConnectionManager. ActiveConnection. SendMessage <PlayerEffectMessage>( new PlayerEffectMessage() { Effect = Effects.Effect.Damage, Point = collision.GetContact(0).point, Normal = collision.GetContact(0).normal }); Damager damager = Creator == null ? new Damager(this.gameObject) : new Damager(Creator); var args = health.Modify(-DamageAmount, damager); OnDamage?.Invoke(this, EventArgs.Empty); return(args != null); } } return(false); }
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); }
public HealthEventArgs(Damager causee, Damager causer, float modification) { Modification = modification; Causee = causee; Causer = causer; }