public void AcceptFilteredStimulus(Stimulus stimulus)
 {
     Debug.Log("Type : " + stimulus.type + " Source : " + stimulus.source);
     foreach (Envelope e in envelopes)
     {
         // Has an envelope been created for this source
         if (e.source == stimulus.source)
         {
             // This is an update stimulus
             if (e.Exists(stimulus))
             {
                 // Update the time
                 if (stimulus.type == Stimulus.StimulusTypes.AudioWeapon || stimulus.type == Stimulus.StimulusTypes.AudioMovement || stimulus.type == Stimulus.StimulusTypes.AudioCollision)
                 {
                     brain.searchPos.transform.position = e.source.transform.position;
                     e.Update(stimulus);
                 }
                 e.Update(stimulus);
                 return;
             }
             else
             {
                 // A new stimulus for an existing envelope
                 e.Add(stimulus, GetConfiguration(stimulus));
                 return;
             }
         }
     }
     // Create a new envelope and event
     envelopes.Add(new Envelope(stimulus, GetConfiguration(stimulus)));
 }
Exemple #2
0
 public void Add(Stimulus stimulus, Configuration config)
 {
     events.Add(new Event(stimulus, config));
     // Debug.Log("Event added");
     // Debug.Log(stimulus.type);
     Process();
 }
Exemple #3
0
 public Envelope(Stimulus stimulus, Configuration config)
 {
     source = stimulus.source;
     events = new List <Event>();
     markEnvelopeForDeletion = false;
     Add(stimulus, config);
 }
Exemple #4
0
        public void Update(Stimulus stimulus)
        {
            Event foundEvent = events.Find(e => e.source == stimulus.source && e.type == stimulus.type);

            if (foundEvent != null)
            {
                foundEvent.Update();
                Process();
            }
        }
 // Return the configuration for a stimulus
 private Configuration GetConfiguration(Stimulus stimulus)
 {
     foreach (Configuration c in perceptionManager.configs)
     {
         if (c.Type == stimulus.type)
         {
             return(c);
         }
     }
     return(null);
 }
Exemple #6
0
 public Event(Stimulus s, Configuration config)
 {
     this.type                 = s.type;
     this.source               = s.source;
     this.location             = s.location;
     this.direction            = s.direction;
     this.radius               = s.radius;
     this.config               = config;
     this.birth                = Time.time;
     this.life                 = 0f;
     this.markEventForDeletion = false;
 }
Exemple #7
0
 public void AcceptStimulus(Stimulus stimulus)
 {
     stimuliBuffer.Add(stimulus);
 }
Exemple #8
0
        private bool Filter(TargetTrackingManager tsm, GameObject registrant, Stimulus stimulus)
        {
            // Don't send an agent's own stimuli to itself
            if (stimulus.source != registrant)
            {
                TargetTrackingManager.AgentTypes destinationAgentType = tsm.agentType;
                // Who is the agent interested in
                int validTypes = tsm.agentFilter;

                TargetTrackingManager.AgentTypes sourceAgentType;
                if (stimulus.source.GetComponent <TargetTrackingManager>() == null)
                {
                    sourceAgentType = TargetTrackingManager.AgentTypes.Friendly;
                }
                else
                {
                    sourceAgentType = stimulus.source.GetComponent <TargetTrackingManager>().agentType;
                }

                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Hostile) && (destinationAgentType == TargetTrackingManager.AgentTypes.Friendly) && ((validTypes & TargetTrackingManager.HOSTILE) != 0))
                {
                    return(true);
                }
                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Hostile) && (destinationAgentType == TargetTrackingManager.AgentTypes.Hostile) && ((validTypes & TargetTrackingManager.FRIENDLY) != 0))
                {
                    return(true);
                }
                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Hostile) && (destinationAgentType == TargetTrackingManager.AgentTypes.Neutral) && ((validTypes & TargetTrackingManager.NEUTRAL) != 0))
                {
                    return(true);
                }

                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Friendly) && (destinationAgentType == TargetTrackingManager.AgentTypes.Friendly) && ((validTypes & TargetTrackingManager.FRIENDLY) != 0))
                {
                    return(true);
                }
                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Friendly) && (destinationAgentType == TargetTrackingManager.AgentTypes.Hostile) && ((validTypes & TargetTrackingManager.HOSTILE) != 0))
                {
                    return(true);
                }
                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Friendly) && (destinationAgentType == TargetTrackingManager.AgentTypes.Neutral) && ((validTypes & TargetTrackingManager.NEUTRAL) != 0))
                {
                    return(true);
                }

                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Neutral) && (destinationAgentType == TargetTrackingManager.AgentTypes.Friendly) && ((validTypes & TargetTrackingManager.NEUTRAL) != 0))
                {
                    return(true);
                }
                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Neutral) && (destinationAgentType == TargetTrackingManager.AgentTypes.Hostile) && ((validTypes & TargetTrackingManager.NEUTRAL) != 0))
                {
                    return(true);
                }
                if ((sourceAgentType == TargetTrackingManager.AgentTypes.Neutral) && (destinationAgentType == TargetTrackingManager.AgentTypes.Neutral) && ((validTypes & TargetTrackingManager.NEUTRAL) != 0))
                {
                    return(true);
                }
                return(false);
            }
            else
            {
                return(false);
            }
        }
Exemple #9
0
 public bool Exists(Stimulus stimulus)
 {
     return(events.Exists(e => e.source == stimulus.source && e.type == stimulus.type));
 }