예제 #1
0
    public IEnumerator EnemyAttack()
    {
        while (currentState == EMENY_STATE.ATTACK)
        {
            Debug.Log("Attacking!");
            agent.isStopped = false;
            agent.SetDestination(playerTransform.position);
            while (agent.pathPending)
            {
                yield return(null);
            }

            if (agent.remainingDistance > agent.stoppingDistance)
            {
                CurrentState = EMENY_STATE.CHASE;
                yield break;
            }
            else
            {
                playerHealth.HealthPoints -= maxDemage * Time.deltaTime;
            }
            yield return(null);
        }

        yield break;
    }
예제 #2
0
 public IEnumerator EnemyChase()
 {
     while (currentState == EMENY_STATE.CHASE)
     {
         checkVision.Sensitity = CheckVision.enmSensitity.LOW;
         agent.isStopped       = false;
         agent.SetDestination(checkVision.lastKnownSighting);
         while (agent.pathPending)
         {
             yield return(null);
         }
         if (agent.remainingDistance <= agent.stoppingDistance)
         {
             agent.isStopped = true;
             if (!checkVision.targetInSight)
             {
                 CurrentState = EMENY_STATE.PATROL;
             }
             else
             {
                 CurrentState = EMENY_STATE.ATTACK;
             }
             yield break;
         }
         yield return(null);
     }
 }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        /*GameObject[] destinations = GameObject.FindGameObjectsWithTag("Dest");
         * patrolDestination = destinations[Random.Range(0, destinations.Length)]
         *  .GetComponent<Transform>();
         *
         * CurrentState = EMENY_STATE.PATROL;
         */

        GameObject[] destinations = GameObject.FindGameObjectsWithTag("Dest");
        int          pathIndex    = Random.Range(0, destinations.Length);

        patrolDestination = destinations[Random.Range(0, destinations.Length)].GetComponent <Transform>();
        //  print($"Path: {pathIndex}");
        CurrentState = EMENY_STATE.PATROL;
    }
예제 #4
0
    public IEnumerator EnemyPatrol()
    {
        while (currentState == EMENY_STATE.PATROL)
        {
            checkVision.Sensitity = CheckVision.enmSensitity.HIGH;

            agent.isStopped = false;
            agent.SetDestination(patrolDestination.position);
            while (agent.pathPending)
            {
                yield return(null);
            }

            if (checkVision.targetInSight)
            {
                agent.isStopped = true;
                CurrentState    = EMENY_STATE.CHASE;
                yield break;
            }
            yield return(null);
        }
    }