예제 #1
0
        /// <summary>
        ///     Gets the time opponent has been out of view.
        /// </summary>
        /// <param name="opponent">The opponent.</param>
        /// <returns>
        ///     The amount of time the given opponent has remained out of view (or a high value if
        ///     opponent has never been seen or not present).
        /// </returns>
        public float GetTimeOutOfView(Agent opponent)
        {
            if (opponent != null && MemoryMap.ContainsKey(opponent))
            {
                return(Time.time - MemoryMap[opponent].TimeLastVisible);
            }

            return(float.MaxValue);
        }
예제 #2
0
 /// <summary>
 ///     Check to see if there is an existing record for the opponent. If not a new record is
 ///     made and added to the memory map.
 /// </summary>
 /// <remarks>
 ///     Called by <see cref="UpdateWithSoundSource" /> and <see cref="UpdateVision" />.
 /// </remarks>
 /// <param name="opponent">The opponent.</param>
 private void MakeNewRecordIfNotAlreadyPresent(Agent opponent)
 {
     // check to see if this Opponent already exists in the memory. If it doesn't,
     // create a new record
     if (!MemoryMap.ContainsKey(opponent))
     {
         MemoryMap[opponent] = new SensoryMemoryRecord();
     }
 }
예제 #3
0
        /// <summary>
        ///     Tests if opponent within FOV.
        /// </summary>
        /// <param name="opponent">The opponent.</param>
        /// <returns>True if opponent is within FOV.</returns>
        public bool IsOpponentWithinFieldOfView(Agent opponent)
        {
            if (opponent != null && MemoryMap.ContainsKey(opponent))
            {
                return(MemoryMap[opponent].IsWithinFieldOfView);
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        ///     Tests if opponent is shootable.
        /// </summary>
        /// <param name="opponent">The opponent.</param>
        /// <returns>
        ///     True if opponent can be shot (i.e. its not obscured by walls).
        /// </returns>
        public bool IsOpponentShootable(Agent opponent)
        {
            if (opponent != null && MemoryMap.ContainsKey(opponent))
            {
                return(MemoryMap[opponent].IsShootable);
            }

            return(false);
        }
예제 #5
0
        /// <summary>
        ///     Get the time since opponent was last sensed.
        /// </summary>
        /// <param name="opponent">The opponent.</param>
        /// <returns>The amount of time opponent has been visible.</returns>
        public float GetTimeSinceLastSensed(Agent opponent)
        {
            if (opponent != null && MemoryMap.ContainsKey(opponent) &&
                MemoryMap[opponent].IsWithinFieldOfView)
            {
                return(Time.time - MemoryMap[opponent].TimeLastSensed);
            }

            return(0);
        }
예제 #6
0
        /// <summary>
        ///     Gets the time opponent has been visible.
        /// </summary>
        /// <param name="opponent">The opponent.</param>
        /// <returns>The amount of time opponent has been visible.</returns>
        public float GetTimeVisible(Agent opponent)
        {
            if (opponent != null && MemoryMap.ContainsKey(opponent) &&
                MemoryMap[opponent].IsWithinFieldOfView)
            {
                return(Time.time - MemoryMap[opponent].TimeBecameVisible);
            }

            return(0);
        }
예제 #7
0
        /// <summary>
        ///     Gets the last recorded position of opponent.
        /// </summary>
        /// <param name="opponent">The opponent.</param>
        /// <returns>The last recorded position of opponent.</returns>
        /// <exception cref="System.Exception">
        ///     Attempting to get position of unrecorded agent.
        /// </exception>
        public Vector2 GetLastRecordedPosition(Agent opponent)
        {
            if (opponent != null && MemoryMap.ContainsKey(opponent))
            {
                return(MemoryMap[opponent].LastSensedPosition);
            }

            throw new Exception(
                      "SensoryMemory.GetLastRecordedPosition: Attempting to get position of unrecorded agent.");
        }