public bool TryCritical() { float ratingForSinglePercent = GetSinglePercentRatingValue(); float criticalRating = UnitStats.GetStat(EStats.Critical); float criticalStrikePercentage = criticalRating / ratingForSinglePercent; criticalStrikePercentage = Mathf.Clamp(criticalStrikePercentage, 0, 75); float criticalRoll = UnityEngine.Random.Range(0, 100); if (criticalRoll < criticalStrikePercentage) { return(true); } else { return(false); } }
// Tries to evade an attack // Compares evasion rating with opponent accuracy rating // Evasion rating to percentage is dynamic, based on progression. More progression into the game, requires more rating to achieve // same evasion percent. public bool TryEvade(float opponentAccuracyRating) { float ratingForSinglePercent = GetSinglePercentRatingValue(); float accuracyBalanceRatio = 0.7f; float difference = UnitStats.GetStat(EStats.Evasion) - (opponentAccuracyRating * accuracyBalanceRatio); float evadePercentage = difference / ratingForSinglePercent; Debug.Log($"Accuracy rating: {opponentAccuracyRating}, evasionPercentage: {evadePercentage}"); evadePercentage = Mathf.Clamp(evadePercentage, 0, 75); float evadeRoll = UnityEngine.Random.Range(0, 100); if (evadeRoll < evadePercentage) { return(true); } else { return(false); } }
public void TakeDamage(float damage) { float maxHealth = UnitStats.GetStat(EStats.Health); float damageVariation = UnityEngine.Random.Range(0, damage * 0.2f); damage += damage * 0.2f; damage -= damageVariation * 2; Health -= damage; if (Health <= 0) { Health = 0; Die(); } if (Health > maxHealth) { Health = maxHealth; } healthBar.UpdateHealthBar(Health); }
private void Start() { characterCooldowns = new Cooldowns(); Health = UnitStats.GetStat(EStats.Health); originalPostion = transform.position; }
public void ResetHealth() { Health = UnitStats.GetStat(EStats.Health); }
private void Start() { heightOfFill = healthFillImage.sprite.rect.height; maxHealth = unitStats.GetStat(EStats.Health); UpdateHealthBar(maxHealth); }