Dash tweaks, quality of code

This commit is contained in:
2025-09-05 17:47:06 +02:00
parent 38704518b0
commit a11c5a8dd7
3 changed files with 10 additions and 2 deletions

View File

@@ -15,10 +15,12 @@ public class EnemyAttack : MonoBehaviour
[SerializeField] private Animator animator;
[SerializeField] private NavMeshAgent agent;
private float lastAttackTime = 0f;
private bool canAttack = true;
private bool isAttacking = false;
private float attackCooldownTimer = 0f;
private PlayerSkillHandler skillHandler;
void Start()
{
@@ -29,6 +31,8 @@ public class EnemyAttack : MonoBehaviour
player = playerObject.transform;
}
skillHandler = player.GetComponent<PlayerSkillHandler>();
if (animator == null) animator = GetComponent<Animator>();
if (agent == null) agent = GetComponent<NavMeshAgent>();
@@ -88,7 +92,6 @@ public class EnemyAttack : MonoBehaviour
float angle = Vector3.Angle(forward, directionToPlayer);
// V<>t<EFBFBD><74> tolerance <20>hlu (zv<7A><76>eno z 22.5<EFBFBD> na 60<36>)
return angle <= attackAngle; // Pou<6F><75>v<EFBFBD>me cel<65> attackAngle, ne polovinu
}
@@ -125,8 +128,9 @@ public class EnemyAttack : MonoBehaviour
// Po<50>kej chv<68>li p<>ed aplikov<6F>n<EFBFBD>m po<70>kozen<65>
yield return new WaitForSeconds(0.3f);
bool playerDashing = skillHandler.IsDashing();
// Aplikuj po<70>kozen<65>, pokud je hr<68><72> st<73>le v dosahu
if (player != null && Vector3.Distance(transform.position, player.position) <= attackRange * 1.2f)
if (player != null && Vector3.Distance(transform.position, player.position) <= attackRange * 1.2f && !playerDashing)
{
var health = player.GetComponent<HealthManager>();
if (health != null)