Exemplo n.º 1
0
 private void Update()
 {
     coinAmount.SetText($"{_player.GoldCoinAmount}");
     skillPointsAmount.SetText($"{_playerAbilities.skillPoints}");
     playerLevel.SetText($"{_playerAbilities.curLevel}");
     playerIntelligence.SetText($"{_playerAbilities.intelligence}");
     playerStrength.SetText($"{_playerAbilities.strength}");
     physicalResistanceAmount.SetText($"{_playerAbilities.strengthPhysicalDamageIncreaseAmount}%");
     elementalResistanceAmount.SetText($"{_playerAbilities.intelligenceElementalDamageIncreaseAmount}%");
     manaRegenerationAmount.SetText($"{_playerAbilities.manaRegenerationPercentage}%");
     physicalDamageAmount.SetText($"{_playerAbilities.CalculatePhysicalDamage()}");
     elementalDamageAmount.SetText($"{_playerAbilities.CalculateElementalDamage()}");
 }
Exemplo n.º 2
0
        private void OnTriggerEnter(Collider other)
        {
            // If the enemy is hit with a projectile that IS NOT tagged enemy
            if (other.GetComponent <SkillProjectile>() && !other.gameObject.CompareTag("Enemy"))
            {
                TakeDamage(other.GetComponent <SkillProjectile>().Skill.amountOfDamage + _playerAbilitySystem.CalculateElementalDamage());
                transform.LookAt(other.transform);
                Destroy(other.gameObject);
            }

            // If the enemy is hit by a player weapon
            if (other.CompareTag("EquippedWeapon"))
            {
                var enemyHitDetection = other.GetComponent <EnemyHitDetection>();
                if (enemyHitDetection != null)
                {
                    // Perform a range check
                    if (Vector3.Distance(transform.position, _player.gameObject.transform.position) <=
                        _player.GetComponent <PlayerEquipmentManager>().weaponItem.weaponRange)
                    {
                        TakeDamage(enemyHitDetection.playerAbilitySystem.CalculatePhysicalDamage());

                        // ## Health-on-Hit
                        _player.CurrentHp += _playerAbilitySystem.healthOnHitAmount / 100 * _player.maxHp;
                    }
                }
            }
        }