public void FirePlayerHit(GameObject damageSource, int damage, DamageReason damageReason) { if (onPlayerHit != null) { onPlayerHit(damageSource, damage, damageReason); } }
public void FireEnemyHit(Enemy enemy, int damage, DamageReason damageSource) { if (onEnemyHit != null) { onEnemyHit(enemy, damage, damageSource); } }
private void OnEnemyHitByMelee(Enemy enemy, int damage, DamageReason reason) { // Sanity check if (!parentItem.equipped) { return; } if (reason != DamageReason.Melee) { return; } if (!canHitBoss && enemy.isBoss) { return; } int val = Random.Range(0, 100); int luck = Game.instance.avatar.GetComponent <CharacterStatistics>().ModifiedStatValue(CharacterStatType.Luck, Game.instance.avatar.gameObject); // Guarantee status effect if we're testing items if (Cheats.forceTestItemGeneration >= 0) { val = 0; } if (val - luck / 4 < chance) { ApplyStatus(enemy); } }
private void OnPlayerHit(GameObject damageSource, int damage, DamageReason damageReason) { if (damageReason == DamageReason.Melee && damageSource != null) { Killable killable = damageSource.GetComponent <Killable>(); killable.TakeDamage(gameObject, 5, DamageReason.StatusEffect); } }
public void TakeDamage(GameObject damageSource, int damage, DamageReason damageReason) { if (!CanTakeDamage()) { return; } // No attack can ever do less than 1 damage, no matter strength/defense equations if (allowZeroDamage) { damage = Mathf.Max(damage, 0); } else { damage = Mathf.Max(damage, 1); } CreateHitVFX(); // If we're talking about the player, use their info that's stashed away in a saveable place // Also if they're dancing, they take less damage PlayerController playerController = GetComponent <PlayerController>(); if (playerController != null) { if (playerController.IsDancing()) { damage /= 2; } Game.instance.playerData.health -= damage; Game.instance.centralEvents.FirePlayerHit(damageSource, damage, damageReason); } health -= damage; if (mEnemy != null) { Game.instance.centralEvents.FireEnemyHit(mEnemy, damage, damageReason); } if (showNumberPopups) { NumberPopupGenerator.instance.GeneratePopup(gameObject, damage, NumberPopupReason.Bad); } if (onHit != null) { onHit(this); } if (health <= 0f) { HandleDeath(); } }
public static void WriteJson(this DamageReason value, JsonWriter writer, JsonSerializer serializer) { switch (value) { case DamageReason.ArmShot: serializer.Serialize(writer, "ArmShot"); break; case DamageReason.HeadShot: serializer.Serialize(writer, "HeadShot"); break; case DamageReason.LegShot: serializer.Serialize(writer, "LegShot"); break; case DamageReason.NonSpecific: serializer.Serialize(writer, "NonSpecific"); break; case DamageReason.None: serializer.Serialize(writer, "None"); break; case DamageReason.PelvisShot: serializer.Serialize(writer, "PelvisShot"); break; case DamageReason.TorsoShot: serializer.Serialize(writer, "TorsoShot"); break; } }
private void OnEnemyHit(Enemy enemy, int damage, DamageReason damageReason) { float multiplier = 0.05f + (strength / 200f); multiplier = Mathf.Min(multiplier, 0.3f); int amount = Mathf.RoundToInt(damage * multiplier); amount = Mathf.Max(amount, 1); // Cap vampirism at 10 to prevent it getting too powerful & to fix an insta-kill bug amount = Mathf.Min(amount, 10); Game.instance.playerData.health += amount; Game.instance.playerData.health = Mathf.Min(Game.instance.playerData.health, Game.instance.avatar.GetComponent <CharacterStatistics>().ModifiedStatValue(CharacterStatType.MaxHealth, Game.instance.avatar.gameObject)); Game.instance.avatar.GetComponent <Killable>().health = Game.instance.playerData.health; NumberPopupGenerator.instance.GeneratePopup(Game.instance.avatar.gameObject, amount, NumberPopupReason.Good); }