Пример #1
0
 public override void Enter(EnemyAgent agent)
 {
     agent.SetAnimation(true);
     agent.GetNavMeshAgent().isStopped = true;
     agent.ResetAttack();
     //start attack animation
     agent.Attack();
 }
 public override void Enter(EnemyAgent agent)
 {
     agent.GetRigidbody().velocity     = Vector3.zero;
     agent.GetNavMeshAgent().isStopped = true;
     agent.SetAnimation(true);
     agent.ResetAttack();
     //start attack animation
     agent.Attack();
 }
    public override void Update(EnemyAgent agent)
    {
        //update position of the player
        agent.SetPlayerTarget();

        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange() + 0.5f)
        {
            agent.SetState(AttackState.GetInstance());
        }
        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) > agent.GetFollowRange() + 0.5f)
        {
            if (agent.GetIsWaveEnemy() == false)
            {
                agent.SetState(PatrolState.GetInstance());
            }
            else
            {
                agent.SetState(ChargeBaseState.GetInstance());
            }
        }
    }
Пример #4
0
    public override void Update(EnemyAgent agent)
    {
        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < 2.5f)
        {
            agent.UpdateWaypoint();
        }
        RaycastHit hit;

        if (Physics.SphereCast(agent.transform.position + new Vector3(0.5f, 0f, 0.5f), 1f, agent.transform.forward, out hit, agent.GetFollowRange()))
        {
            if (hit.collider.tag == "Player")
            {
                agent.SetState(FollowPlayerState.GetInstance());
            }
        }
    }
Пример #5
0
    public override void Update(EnemyAgent agent)
    {
        //check if player is in his way if yes follow player
        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange() + 0.5f)
        {
            agent.SetState(AttackBaseState.GetInstance());
        }
        RaycastHit hit;

        if (Physics.SphereCast(agent.transform.position + new Vector3(0.5f, 0.5f, 0.5f), 0.5f, agent.transform.forward, out hit, agent.GetFollowRange()))
        {
            if (hit.collider.tag == "Player")
            {
                agent.SetState(FollowPlayerState.GetInstance());
            }
        }
    }
 public override void Update(EnemyAgent agent)
 {
     //check if target still in attack range if yes attack again after ending the attack animation
     agent.SetPlayerTarget();
     if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange())
     {
         if (agent.GetCurrentTimeBtwAttacks() <= 0)
         {
             agent.Attack();
         }
         else
         {
             agent.AdjustAttackTime();
         }
     }
     else
     {
         agent.SetState(FollowPlayerState.GetInstance());
     }
 }
 public override void Enter(EnemyAgent agent)
 {
     agent.GetNavMeshAgent().isStopped = false;
     agent.SetPlayerTarget();
 }
 public override void Exit(EnemyAgent agent)
 {
     agent.GetNavMeshAgent().isStopped = false;
     agent.SetAnimation(false);
 }