Example #1
0
        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);
            }
        }
Example #2
0
        // 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);
            }
        }
Example #3
0
        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);
        }
Example #4
0
 private void Start()
 {
     characterCooldowns = new Cooldowns();
     Health             = UnitStats.GetStat(EStats.Health);
     originalPostion    = transform.position;
 }
Example #5
0
 public void ResetHealth()
 {
     Health = UnitStats.GetStat(EStats.Health);
 }
Example #6
0
 private void Start()
 {
     heightOfFill = healthFillImage.sprite.rect.height;
     maxHealth    = unitStats.GetStat(EStats.Health);
     UpdateHealthBar(maxHealth);
 }