Example #1
0
 bool FindPointOfInterest()
 {
     TimeDebug.Record("find_point_" + name + "_" + GetInstanceID());
     poiTarget = (SomethingInteresting)GlobalPOI.RandomPOI(transform.position);
     TimeDebug.Stop("find_point_" + name + "_" + GetInstanceID());
     if (poiTarget)
     {
         return(true);
     }
     return(false);
 }
Example #2
0
    public bool WalkToWp()
    {
        TimeDebug.Record("walktowp_" + name + "_" + GetInstanceID());
        if (pathfinder)
        {
            pathfinder.UpdatePathfinder(ref _wp);
        }
        TimeDebug.Stop("walktowp_" + name + "_" + GetInstanceID());

        TimeDebug.Record("checkdist_" + name + "_" + GetInstanceID());
        CheckDistances();
        TimeDebug.Stop("checkdist_" + name + "_" + GetInstanceID());

        if (!walking)
        {
            return(false);         // false: not moving; true: moving
        }
        TimeDebug.Record("move_" + name + "_" + GetInstanceID());

        // get direction fixes that will prevent getting stuck on other npc's
        Vector3 fix = Vector3.zero; // broken when chasing enemies GetFixedDistanceFromCrowd();
        //Vector3 fix2 = GetFixedDistanceFromWalls();

        Vector3 dir = (_wp - t.position).normalized;

        fix = dir;
        if (moveFixing)
        {
            moveFixing.ApplyFix(ref fix, t.position);
        }

        //dir = (dir + fix).normalized;
        dir = fix.normalized;
        rig.MovePosition(t.position + dir * Time.deltaTime * speed);
        //Debug.DrawLine(t.position, _wp, Color.yellow);
        TimeDebug.Stop("move_" + name + "_" + GetInstanceID());

        return(true);
    }
Example #3
0
 FBStatus WaitAtPointOfInterest()
 {
     TimeDebug.Record("waiting_" + name + "_" + GetInstanceID());
     if (waiting == false)
     {
         waiting = true;
         time    = Time.time + poiTarget.timeInvestment * attentionLevel;
         poiTarget.NewParticipant(this);
     }
     if (waiting)
     {
         if (Time.time < time)
         {
             return(FBStatus.Running);
         }
         poiTarget.LostInterest(this);
         waiting = false;
         TimeDebug.Stop("waiting_" + name + "_" + GetInstanceID());
         return(FBStatus.Success);
     }
     TimeDebug.Stop("waiting_" + name + "_" + GetInstanceID());
     return(FBStatus.Failure);
 }