diff --git a/3D blobici/Assets/Scripts/Enemy/EnemyAttack.cs b/3D blobici/Assets/Scripts/Enemy/EnemyAttack.cs index eaaf0db..544184f 100644 --- a/3D blobici/Assets/Scripts/Enemy/EnemyAttack.cs +++ b/3D blobici/Assets/Scripts/Enemy/EnemyAttack.cs @@ -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(); + if (animator == null) animator = GetComponent(); if (agent == null) agent = GetComponent(); @@ -88,7 +92,6 @@ public class EnemyAttack : MonoBehaviour float angle = Vector3.Angle(forward, directionToPlayer); - // Větší tolerance úhlu (zvýšeno z 22.5° na 60°) return angle <= attackAngle; // Používáme celý attackAngle, ne polovinu } @@ -125,8 +128,9 @@ public class EnemyAttack : MonoBehaviour // Počkej chvíli před aplikováním poškození yield return new WaitForSeconds(0.3f); + bool playerDashing = skillHandler.IsDashing(); // Aplikuj poškození, pokud je hráč stá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(); if (health != null) diff --git a/3D blobici/Assets/Scripts/Enemy/EnemyMovement.cs b/3D blobici/Assets/Scripts/Enemy/EnemyMovement.cs index 1d826b6..d3caea9 100644 --- a/3D blobici/Assets/Scripts/Enemy/EnemyMovement.cs +++ b/3D blobici/Assets/Scripts/Enemy/EnemyMovement.cs @@ -236,6 +236,7 @@ public class EnemyMovement : MonoBehaviour } } + /* ========= PATROLLING IN CASE PLAYER IS FAR ========== */ private void GenerateNewPatrolTarget() { Vector2 randomCircle = Random.insideUnitCircle * patrolRange; @@ -266,6 +267,8 @@ public class EnemyMovement : MonoBehaviour Destroy(gameObject, 2f); } + + /*====== FOR DEBUGGING PURPOSES ONLY ========== */ private void OnDrawGizmosSelected() { Gizmos.color = Color.red; diff --git a/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs index 17f02da..17ba381 100644 --- a/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs +++ b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs @@ -72,6 +72,7 @@ public class PlayerSkillHandler: MonoBehaviour yield return null; // wait one frame } handleCooldownTimer(PlayerSkillTree.Skills.Dash); + yield return new WaitForSeconds(0.5f); isDashing = false; // just for now. maybe will be removed Physics.IgnoreLayerCollision(6, 7, false); // enable collisions between player and enemies }