public override void Reason(BleddynController bleddynController) { if (bleddynController.playerInFOV()) { float distanceToPlayer = Vector3.Distance(bleddynController.playerTransform.position, bleddynController.transform.position); if (distanceToPlayer > bleddynController.bleddynConfig.attackRange) { if (!bleddynController.animator.GetCurrentAnimatorStateInfo(0).IsName("Attack") && !bleddynController.animator.IsInTransition(0)) { Debug.Log("SawPlayer"); bleddynController.SetTransition(Transition.SawPlayer); bleddynController.animator.SetBool("isAttacking", false); } } if (distanceToPlayer > bleddynController.bleddynConfig.chaseSpottingDistance) { if (!bleddynController.animator.GetCurrentAnimatorStateInfo(0).IsName("Attack") && !bleddynController.animator.IsInTransition(0)) { Debug.Log("LostPlayer"); bleddynController.SetTransition(Transition.LostPlayer); bleddynController.animator.SetBool("isAttacking", false); } } } else { Debug.Log("PlayerOutOfSight"); bleddynController.SetTransition(Transition.LostPlayer); bleddynController.animator.SetBool("isAttacking", false); } }
public override void Reason(BleddynController bleddynController) { bool canSeePlayer = bleddynController.GetComponent <FieldOfView>().CanSeePlayer(); float distanceToPlayer = Vector3.Distance(bleddynController.transform.position, bleddynController.playerTransform.position); if (distanceToPlayer < bleddynController.bleddynConfig.attackRange) { Debug.Log("AttackPlayer"); bleddynController.SetTransition(Transition.ReachedPlayer); } if (!canSeePlayer) { bleddynController.lastKnownPlayerPosition = bleddynController.playerTransform.position; bleddynController.SetTransition(Transition.LostPlayer); } }
public override void Reason(BleddynController bleddynController) { bool canSeePlayer = bleddynController.GetComponent <FieldOfView>().CanSeePlayer(); if (canSeePlayer) { bleddynController.SetTransition(Transition.SawPlayer); } }
public override void Reason(BleddynController bleddynController) { timer -= Time.deltaTime; if (timer <= 0) { Debug.Log("GiveUpSearching"); timer = bleddynController.bleddynConfig.seekingTime; bleddynController.SetTransition(Transition.GiveUpSearching); moveToClosestPoint(bleddynController); } if (bleddynController.playerInFOV()) { if (Vector3.Distance(bleddynController.transform.position, bleddynController.playerTransform.position) <= bleddynController.bleddynConfig.seekingSpottingDistance) { Debug.Log("SawPlayer"); bleddynController.SetTransition(Transition.SawPlayer); } } }