Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 private void Start()
 {
     characterCooldowns = new Cooldowns();
     Health             = UnitStats.GetStat(EStats.Health);
     originalPostion    = transform.position;
 }
Ejemplo n.º 4
0
 public void ResetHealth()
 {
     Health = UnitStats.GetStat(EStats.Health);
 }