Collisions, AI tweaks

This commit is contained in:
2025-09-06 00:44:27 +02:00
parent a11c5a8dd7
commit e397d13f41
5 changed files with 78 additions and 107 deletions

View File

@@ -52,6 +52,8 @@ public class EnemyAttack : MonoBehaviour
}
}
public float GetAttackRange() => attackRange;
// Metoda pro pokus o <20>tok - vol<6F>na z EnemyMovement
public bool TryAttack()
{
@@ -63,19 +65,17 @@ public class EnemyAttack : MonoBehaviour
// Kontrola vzd<7A>lenosti a <20>hlu k hr<68><72>i
float distanceToPlayer = Vector3.Distance(transform.position, player.position);
bool inRange = distanceToPlayer <= attackRange;
bool inRange = IsPlayerInAttackRange();
bool inAngle = IsPlayerInAttackAngle();
bool cooldownReady = Time.time - lastAttackTime >= attackRate;
Debug.Log($"TryAttack: range={inRange}, angle={inAngle}, cooldown={cooldownReady}, distance={distanceToPlayer}");
if (inRange && cooldownReady)
{
StartCoroutine(PerformAttack());
return true;
}
Debug.Log("Attack conditions not met");
Debug.Log("Attack conditions not met. Conditions: range: " + inRange + "angle: " + inAngle + "cooldown: " + cooldownReady);
return false;
}
@@ -100,10 +100,9 @@ public class EnemyAttack : MonoBehaviour
if (player == null) return false;
float distance = Vector3.Distance(transform.position, player.position);
bool inRange = distance <= attackRange * 1.1f;
bool inAngle = IsPlayerInAttackAngle();
bool inRange = distance <= attackRange * 1.2f;
return inRange && inAngle;
return inRange;
}
private IEnumerator PerformAttack()
@@ -126,7 +125,7 @@ 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);
yield return new WaitForSeconds(0.1f);
bool playerDashing = skillHandler.IsDashing();
// Aplikuj po<70>kozen<65>, pokud je hr<68><72> st<73>le v dosahu
@@ -141,7 +140,7 @@ public class EnemyAttack : MonoBehaviour
}
// Po<50>kej na dokon<6F>en<65> animace
yield return new WaitForSeconds(0.7f);
yield return new WaitForSeconds(0.3f);
// Obnov pohyb pouze pokud nebyl p<>vodn<64> zastaven<65>
if (!wasStopped)
@@ -173,7 +172,7 @@ public class EnemyAttack : MonoBehaviour
// Public metody pro komunikaci s EnemyMovement
public bool CanAttack()
{
return canAttack && !isAttacking;
return canAttack && !isAttacking && IsPlayerInAttackRange();
}