Exemplo n.º 1
0
    public IEnumerator AIChase()
    {
        while (currentstate == SOLDIER_STATE.CHASE)
        {
            ThisLineSight.Sensitity = LineSight.SightSensitivity.LOOSE;
            ThisAgent.isStopped     = false;
            ThisAgent.SetDestination(ThisLineSight.LastKnowSighting);
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }
            if (ThisAgent.remainingDistance <= ThisAgent.stoppingDistance)
            {
                ThisAgent.isStopped = true;

                if (!ThisLineSight.CanSeeTarget)
                {
                    CurrenrState = SOLDIER_STATE.PATROL;
                }
                else
                {
                    CurrenrState = SOLDIER_STATE.ATTACK;
                }
                yield break;
            }
        }
        yield return(null);
    }
Exemplo n.º 2
0
    public override void Die()
    {
        base.Die();

        if (animator != null)
        {
            animator.SetFloat("Speed", 0f);
            animator.SetFloat("PlayerWalking", 0f);
        }

        currentState = SOLDIER_STATE.DYING;

        Destroy(rigidBody);
        Destroy(GetComponent <Collider2D>());
    }
Exemplo n.º 3
0
 public IEnumerator AIPatrol()
 {
     while (currentstate == SOLDIER_STATE.PATROL)
     {
         print("我已经打到你了!" + Random.value);
         ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;
         ThisAgent.isStopped     = false;
         ThisAgent.SetDestination(PatrolDestination.position);
         while (ThisAgent.pathPending)
         {
             yield return(null);
         }
         if (ThisLineSight.CanSeeTarget)
         {
             ThisAgent.isStopped = true;
             CurrenrState        = SOLDIER_STATE.CHASE;
             yield break;
         }
     }
     yield return(null);
 }
Exemplo n.º 4
0
    public IEnumerator AIAttack()
    {
        while (currentstate == SOLDIER_STATE.ATTACK)
        {
            ThisAgent.isStopped = false;

            ThisAgent.SetDestination(ThisLineSight.LastKnowSighting);
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }
            if (ThisAgent.remainingDistance > ThisAgent.stoppingDistance)
            {
                CurrenrState = SOLDIER_STATE.CHASE;
                yield break;
            }
            else
            {
            }

            yield return(null);
        }
        yield return(null);
    }
Exemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     GameObject[] Destinations = GameObject.FindGameObjectsWithTag("Dest");
     PatrolDestination = Destinations[Random.Range(0, Destinations.Length)].GetComponent <Transform>();
     CurrenrState      = SOLDIER_STATE.PATROL;
 }