Dash tweaks, quality of code
This commit is contained in:
@@ -15,10 +15,12 @@ public class EnemyAttack : MonoBehaviour
|
|||||||
[SerializeField] private Animator animator;
|
[SerializeField] private Animator animator;
|
||||||
[SerializeField] private NavMeshAgent agent;
|
[SerializeField] private NavMeshAgent agent;
|
||||||
|
|
||||||
|
|
||||||
private float lastAttackTime = 0f;
|
private float lastAttackTime = 0f;
|
||||||
private bool canAttack = true;
|
private bool canAttack = true;
|
||||||
private bool isAttacking = false;
|
private bool isAttacking = false;
|
||||||
private float attackCooldownTimer = 0f;
|
private float attackCooldownTimer = 0f;
|
||||||
|
private PlayerSkillHandler skillHandler;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -29,6 +31,8 @@ public class EnemyAttack : MonoBehaviour
|
|||||||
player = playerObject.transform;
|
player = playerObject.transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skillHandler = player.GetComponent<PlayerSkillHandler>();
|
||||||
|
|
||||||
if (animator == null) animator = GetComponent<Animator>();
|
if (animator == null) animator = GetComponent<Animator>();
|
||||||
if (agent == null) agent = GetComponent<NavMeshAgent>();
|
if (agent == null) agent = GetComponent<NavMeshAgent>();
|
||||||
|
|
||||||
@@ -88,7 +92,6 @@ public class EnemyAttack : MonoBehaviour
|
|||||||
|
|
||||||
float angle = Vector3.Angle(forward, directionToPlayer);
|
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
|
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>
|
// 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.3f);
|
||||||
|
|
||||||
|
bool playerDashing = skillHandler.IsDashing();
|
||||||
// Aplikuj po<70>kozen<65>, pokud je hr<68><72> st<73>le v dosahu
|
// 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>();
|
var health = player.GetComponent<HealthManager>();
|
||||||
if (health != null)
|
if (health != null)
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ public class EnemyMovement : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========= PATROLLING IN CASE PLAYER IS FAR ========== */
|
||||||
private void GenerateNewPatrolTarget()
|
private void GenerateNewPatrolTarget()
|
||||||
{
|
{
|
||||||
Vector2 randomCircle = Random.insideUnitCircle * patrolRange;
|
Vector2 randomCircle = Random.insideUnitCircle * patrolRange;
|
||||||
@@ -266,6 +267,8 @@ public class EnemyMovement : MonoBehaviour
|
|||||||
Destroy(gameObject, 2f);
|
Destroy(gameObject, 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*====== FOR DEBUGGING PURPOSES ONLY ========== */
|
||||||
private void OnDrawGizmosSelected()
|
private void OnDrawGizmosSelected()
|
||||||
{
|
{
|
||||||
Gizmos.color = Color.red;
|
Gizmos.color = Color.red;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class PlayerSkillHandler: MonoBehaviour
|
|||||||
yield return null; // wait one frame
|
yield return null; // wait one frame
|
||||||
}
|
}
|
||||||
handleCooldownTimer(PlayerSkillTree.Skills.Dash);
|
handleCooldownTimer(PlayerSkillTree.Skills.Dash);
|
||||||
|
yield return new WaitForSeconds(0.5f);
|
||||||
isDashing = false; // just for now. maybe will be removed
|
isDashing = false; // just for now. maybe will be removed
|
||||||
Physics.IgnoreLayerCollision(6, 7, false); // enable collisions between player and enemies
|
Physics.IgnoreLayerCollision(6, 7, false); // enable collisions between player and enemies
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user