예제 #1
0
    public override void UpdatePattern(BehaviourAI ai, SenseMemoryFactory.SMData data)
    {
        base.UpdatePattern(ai, data);

        if (ai.DestinationReached(0.1f))
        {
            if (spotsToCheck > 0)
            {
                spotsToCheck--;
                Vector3 point = GetSurveyPoint(ai);
                ai.agent.SetDestination(point);
            }
            else
            {
                // remove inspection point
                ai.sMF.inspectionPoints.RemoveAt(0);

                // exit behaviour if no more inspection points
                if (ai.sMF.inspectionPoints.Count < 1)
                {
                    KillPattern(ai);
                    return;
                }
            }
        }
    }
예제 #2
0
 public override void UpdatePattern(BehaviourAI ai, SenseMemoryFactory.SMData data)
 {
     if (ai.DestinationReached(0.5f))
     {
         if (investigationPoint == ai.sMF.targetLastSeen)
         {
             Debug.Log("TLS set to Vector3.zero");
             ai.sMF.targetLastSeen = Vector3.zero;
             KillPattern(ai);
             return;
         }
         else if (investigationPoint == data.inspectionPoints[0])
         {
             Debug.Log("inspectionPoint removed");
             ai.sMF.inspectionPoints.RemoveAt(0);
             if (ai.sMF.inspectionPoints.Count < 1)
             {
                 KillPattern(ai);
                 return;
             }
         }
         else
         {
             Debug.Log("InvestigationPoint is set to strange value... (InvestigatePattern)");
         }
     }
 }
예제 #3
0
    // Gets called when pattern is re-called (is cheaper due to if check)
    public override void UpdatePattern(BehaviourAI ai, SenseMemoryFactory.SMData data)
    {
        base.UpdatePattern(ai, data);
        // If we're close enough to the waypoint...
        if (ai.DestinationReached(0.1f))
        {
            // if agent has reached final destination waypoint pos
            if (Vector3.Distance(wayPoints[waypointIndex].position, ai.transform.position) < 0.5f)
            {
                waypointIndex = Random.Range(0, wayPoints.Count);
            }
            // Transform(s) of the current waypoint in the waypoints array.
            Vector3 point = GetRandomEnRoutePos(wayPoints[waypointIndex].position, ai);

            // Agent destination (move to current waypoint position).
            ai.agent.SetDestination(point);
        }
    }
예제 #4
0
 public override void UpdatePattern(BehaviourAI ai, SenseMemoryFactory.SMData data)
 {
     if (data.targets.Count != 0)
     {
         retreatPoint = ai.GetAvoidanceWaypoint(data.targets[0].position);
         ai.agent.SetDestination(retreatPoint);
     }
     if (ai.DestinationReached(0.1f))
     {
         if (!rotated)
         {
             retreatPoint = ai.transform.position + (data.targetLastSeen - ai.transform.position).normalized;
             ai.agent.SetDestination(retreatPoint);
             rotated = true;
         }
         else
         {
             KillPattern(ai);
             rotated = false;
             return;
         }
     }
 }