コード例 #1
0
    public IEnumerator UpdateForm()
    {
        Vector3 storePosition = Vector3.zero;
        float   distance      = 0f;

        while (true)
        {
            distance = Vector3.Distance(storePosition,
                                        transform.position);

            if (distance > .5f &&
                stimulus.GetCurrentOrigin() == Stimulus.origin.Object)
            {
                stimulus.SetCurrentOrigin(Stimulus.origin.Sneaking);
                movingObject = true; // storing the Object aspect;
            }
            else if (distance < .5f && movingObject)
            {
                stimulus.SetCurrentOrigin(Stimulus.origin.Object);
                movingObject = false;
            }
            storePosition = transform.position;
            yield return(new WaitForSeconds(.25f));
        }
    }
コード例 #2
0
 // this needs some more thought...
 private void PlayDead()
 {
     if (stimulus.GetCurrentOrigin() == Stimulus.origin.Incapacitated)
     {
         stimulus.SetCurrentOrigin(Stimulus.origin.Guard);
     }
     else
     {
         stimulus.SetCurrentOrigin(Stimulus.origin.Incapacitated);
     }
 }
コード例 #3
0
    void OnTriggerEnter(Collider other)
    {
        Stimulus stimulus = other.GetComponent <Stimulus>();

        if (stimulus != null)
        {
            Stimulus.origin currentOrigin = stimulus.GetCurrentOrigin();
            //Check the aspect
            if (currentOrigin == desiredStimulusOrigin ||
                currentOrigin == Stimulus.origin.Sneaking)
            {
                print("Touched " + desiredStimulusOrigin + "!");
                patientTouched = true;
            }
        }
    }
コード例 #4
0
 protected override void Initialize()
 {
     self            = GetComponent <Humanoid>();
     allSceneObjects = FindObjectsOfType <GameObject>();
     foreach (GameObject o in allSceneObjects)
     {
         Humanoid testHumanoid = o.GetComponent <Humanoid>();
         if (testHumanoid != null && testHumanoid != self)
         {
             Stimulus test_S = o.GetComponent <Stimulus>();
             if (test_S.GetCurrentOrigin() == targetOriginType)
             {
                 humanoids.Add(testHumanoid);
             }
         }
     }
     targetSeen = false;
 }
コード例 #5
0
 //Detect perspective field of view for the AI Character
 void DetectAspect()
 {
     foreach (Humanoid h in humanoids)
     {
         RaycastHit hit;
         Vector3    rayDirection;
         //Direction from current position to player position
         rayDirection = h.GetPosition() - transform.position;
         int FieldOfView  = 60;
         int ViewDistance = 100;
         //Check the angle between the AI character's forward
         //vector and the direction vector between player and AI
         if ((Vector3.Angle(rayDirection, transform.forward)) < FieldOfView)
         {
             // Detect if player is within the field of view
             if (Physics.Raycast(transform.position, rayDirection,
                                 out hit, ViewDistance))
             {
                 // testing Stimulus even after initialization ensures the
                 // correct types of humanoids are added to the the
                 // 'humanoid' list, because copycat can change his
                 // stimulus type and all characters can crouch.
                 Stimulus stimulus = hit.collider.GetComponent <Stimulus>();
                 if (stimulus != null)
                 {
                     Stimulus.origin currentOrigin = stimulus.GetCurrentOrigin();
                     //Check the origin of the stimulus.
                     // Ignore. “Sneaking” players CAN be seen.
                     if (currentOrigin == desiredStimulusOrigin ||
                         currentOrigin == Stimulus.origin.Sneaking)
                     {
                         print(desiredStimulusOrigin + " seen!");
                         // print(playerTrans.transform.gameObject.name);
                         seenTarget = h;
                         targetSeen = true;
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
    //Detect perspective field of view for the AI Character
    void DetectAspect()
    {
        RaycastHit hit;

        rayDirection = playerTrans.position - transform.position;

        if (Physics.Raycast(transform.position, rayDirection,
                            out hit, SoundDistance))
        {
            Stimulus stimulus = hit.collider.GetComponent <Stimulus>();
            if (stimulus != null)
            {
                Stimulus.origin currentOrigin = stimulus.GetCurrentOrigin();
                //Check the aspect
                if (currentOrigin == desiredStimulusOrigin)
                {
                    print("Heard target.");
                    patientHeard = true;
                }
            }
        }
    }
コード例 #7
0
 public Stimulus.origin GetOriginOfStimulus()
 {
     return(stimulus.GetCurrentOrigin());
 }