コード例 #1
0
    /// <summary>
    /// Returns the amount of time the target has
    /// not been in the AI's FOV
    /// </summary>
    /// <param name="target">The Object the AI is seeking</param>
    /// <returns></returns>
    public virtual float GetWhenTargetLastVisible(GameObject target)
    {
        MemoryProps tempMemory = myMemory[target];

        if (tempMemory != null)
        {
            return(Time.time - tempMemory.whenTargetLastVisible);
        }
        return(0f); //needs to be some high number we need to figure out
    }
コード例 #2
0
    /// <summary>
    /// Returns the time target was last seen
    /// </summary>
    /// <param name="target">The Object the AI is seeking</param>
    /// <returns></returns>
    public virtual float GetWhenTargetBecameVisible(GameObject target)
    {
        MemoryProps tempMemory = myMemory[target];

        if (tempMemory != null)
        {
            return(tempMemory.whenTargetLastVisible);
        }
        return(0f);
    }
コード例 #3
0
    /// <summary>
    /// Returns the time target has been in FOV
    /// </summary>
    /// <param name="target">The Object the AI is seeking</param>
    /// <returns></returns>
    public virtual float GetTargetVisibleTime(GameObject target)
    {
        MemoryProps tempMemory = myMemory[target];

        if (tempMemory != null)
        {
            return(tempMemory.targetVisibleTime);
        }
        return(0f);
    }
コード例 #4
0
    /// <summary>
    /// Returns the target's position
    /// from when they are last in FOV
    /// </summary>
    /// <param name="target">The Object the AI is seeking</param>
    /// <returns></returns>
    public Vector3 GetLastVisibleTargetPos(GameObject target)
    {
        MemoryProps tempMemory = myMemory[target];

        if (tempMemory != null)
        {
            return(tempMemory.lastVisibleTargetPos);
        }
        Debug.Log("Error-Attempting to get Pos of unregistered target");
        return(new Vector3(0f, 0f, 0f)); //TODO: need to put better error-handling
    }
コード例 #5
0
    /// <summary>
    /// Returns true if the target is
    /// within range of the AI to be
    /// attacked
    /// </summary>
    /// <param name="target">The Object the AI is seeking</param>
    /// <returns></returns>
    public virtual bool IsAttackable(GameObject target)
    {
        MemoryProps tempMemory = myMemory[target];

        if (tempMemory != null)
        {
            return(tempMemory.targetAttackable);
        }
        Debug.Log("Error-Attempting to get Attack info of unregistered target");
        return(false);
    }
コード例 #6
0
    /// <summary>
    /// We get all of the potential targets in this Game Instance
    /// Then update the memory Property information of each of those that
    /// exist within this AI's FOV
    /// </summary>
    public virtual void UpdateFOV()
    {
        //For each target in this AI's game instance
        //find those who are currently visible to the AI
        // List<GameObject> targets = new List<GameObject>(); //TODO: needs to get all the targets in the world
        // List<GameObject> targets = new List<GameObject>();
        // targets = this.myInstance.targets;

        if (targets != null)
        {
            hitColliders = Physics.OverlapSphere(transform.position, fovRadius, mask);
            //  print("Not Scanning");
            foreach (GameObject t in targets)
            {
                if (myOwner != t.GetComponent <AI>())//We dont want to this AI
                {
                    //Make a new memory if it doesn't already exist
                    MakeNewMemory(t);

                    //Get the memory info for this target
                    MemoryProps properties = myMemory[t];



                    //Gets all GameObjects that are within the radius around the AI
                    //Collider[]


                    for (int i = 0; i < hitColliders.Length; i++)
                    {
                        //check if the object is within the angle bounds
                        if (Vector3.Angle(transform.forward, (hitColliders[i].transform.position - transform.position)) < angleSpread)
                        {
                            //TODO: Check to see if something is between target and AI that would obsturct them

                            if (Vector3.Distance(hitColliders[i].transform.position, transform.position) <= this.attackDistance)
                            {
                                properties.targetAttackable = true;
                            }
                            else
                            {
                                properties.targetAttackable = false;
                            }


                            // we need to check some how if its in the FOV
                            properties.targetVisibleTime     = Time.time;
                            properties.lastVisibleTargetPos  = t.transform.position;
                            properties.whenTargetLastVisible = Time.time;
                            properties.myLayer = t.gameObject.layer;

                            /*If the new target was not originially in FOV
                             * Then we set their FOV to true
                             * And mark when we saw them
                             */
                            if (properties.targetInFOV == false)
                            {
                                properties.targetInFOV             = true;
                                properties.whenTargetBecameVisible = properties.targetVisibleTime;
                            }
                        }
                    }
                }
            }
        }

        //  print("Scanning");
        ScanArea();
    }
コード例 #7
0
 public MemoryResponseArgs(MemoryConnector connector, MemoryProps props)
 {
     _connector = connector;
     _props     = props;
 }
コード例 #8
0
 public MemoryResponseArgs(MemoryConnector connector, MemoryProps props)
 {
     _connector = connector;
     _props = props;
 }