public void Heal(float delta, GameObject localSource, GameObject overallSource = null) { if (DEBUGFLAGS.HEALTH) { Debug.Log("healing"); } HealthChangeEventData data = new HealthChangeEventData(overallSource, localSource, gameObject, delta); preHealEvent(data); if (data.cancelled) { return; } currentHealth += data.delta; float aggroValue = overallSource?.GetComponent <StatBlock>()?.GetStat(StatName.AggroPercentage)?.value ?? 1; HealthChangeNotificationData notifData = new HealthChangeNotificationData(overallSource, localSource, gameObject, delta, aggroValue); postHealEvent(notifData); healthChangeEvent(notifData); overallSource?.GetComponent <IHealthCallbacks>()?.DamageHealedCallback(notifData); if (currentHealth > maxHealth) { currentHealth = maxHealth; } }
public void Damage(float delta, GameObject localSource, GameObject overallSource = null) { if (DEBUGFLAGS.HEALTH) { Debug.Log("taking damage"); } HealthChangeEventData data = new HealthChangeEventData(overallSource, localSource, gameObject, delta); if (DEBUGFLAGS.HEALTH) { Debug.Log("pre damage"); } preDamageEvent(data); if (data.cancelled) { if (DEBUGFLAGS.HEALTH) { Debug.Log("cancelled"); } return; } if (DEBUGFLAGS.HEALTH) { Debug.Log("not cancelled"); } currentHealth -= data.delta; float aggroValue = overallSource?.GetComponent <StatBlock>()?.GetStat(StatName.AggroPercentage)?.value ?? 1; HealthChangeNotificationData notifData = new HealthChangeNotificationData(overallSource, localSource, gameObject, data.delta, aggroValue); postDamageEvent(notifData); overallSource?.GetComponent <IHealthCallbacks>()?.DamageDealtCallback(notifData); notifData = new HealthChangeNotificationData(overallSource, localSource, gameObject, -data.delta, aggroValue); healthChangeEvent(notifData); if (currentHealth <= 0) { Die(); } }
void CheckIfBlocked(HealthChangeEventData hced) { float angle = Vector3.Angle(transform.up, hced.localSource.transform.position - hced.target.transform.position); if (DEBUGFLAGS.ENEMYHEALTH) { Debug.Log(angle); } if (angle < blockAngle) { if (DEBUGFLAGS.ENEMYHEALTH) { Debug.Log("cancelling"); } hced.cancelled = true; ShieldClankEffect(hced.localSource); } else { DamageEffect(hced.localSource); } }