private void OnTriggerExit(Collider other) { if (other.tag == "Counter") { AgentTicketOffice exited = other.transform.parent.GetComponent <AgentBody>().agent as AgentTicketOffice; if (_ticketOfficeInLineOfVision.Contains(exited)) { _ticketOfficeInLineOfVision.Remove(exited); } } else if (other.tag == "Security") { AgentSecurity exited = other.transform.GetComponent <AgentBody>().agent as AgentSecurity; if (_securityInLineOfVision.Contains(exited)) { _securityInLineOfVision.Remove(exited); } } }
public SpectatorStateEnterStadium(StateMachine stateMachine) : base(stateMachine) { _himSelf = stateMachine.Agent as AgentSpectator; List <AgentSecurity> securityAgents = (_stateMachine.Agent.Body as AgentSpectatorBody).securityInLineOfVision; int minAgents = -1; AgentSecurity selectedSecurity = null; foreach (AgentSecurity ags in securityAgents) { int agents = ags.queue.agents.Count; if (agents < minAgents || minAgents == -1) { selectedSecurity = ags; minAgents = agents; } } _target = selectedSecurity; _stateMachine.Agent.SendMessage(_target, new MessageAskForQueue()); }
/// <summary> /// Main cycle of brain execution /// </summary> public void Loop() { //Kill agents foreach (Agent a in _askedForASuicide) { Guid agent; foreach (KeyValuePair <Guid, Agent> kvp in _agents) { if (kvp.Value == a) { agent = kvp.Key; } } _agents.Remove(agent); } _askedForASuicide.Clear(); //Deactivate agents foreach (Agent a in _askedForDeactivation) { Guid agent; foreach (KeyValuePair <Guid, Agent> kvp in _agents) { if (kvp.Value == a) { agent = kvp.Key; } } Agent agentToRemove = _agents[agent]; _deactivatedAgents.Add(agent, agentToRemove); _agents.Remove(agent); } _askedForDeactivation.Clear(); //Reactivate agent foreach (Agent a in _askedForReactivation) { Guid agent; foreach (KeyValuePair <Guid, Agent> kvp in _deactivatedAgents) { if (kvp.Value == a) { agent = kvp.Key; } } _agents.Add(agent, _deactivatedAgents[agent]); _deactivatedAgents.Remove(agent); } _askedForReactivation.Clear(); foreach (KeyValuePair <Guid, Agent> a in _agents) { a.Value.StateMachine.Action(); } //Every ten seconds if (Time.frameCount % 500 == 0) { foreach (KeyValuePair <Guid, Agent> a in _agents) { AgentTicketOffice ato = a.Value as AgentTicketOffice; if (ato != null) { ato.queue.peoplesInQueue.Add(ato.queue.agents.Count); } AgentSecurity sec = a.Value as AgentSecurity; if (sec != null) { sec.queue.peoplesInQueue.Add(sec.queue.agents.Count); } } } }
public SecurityStateMachine(MultiAgentSystem.AgentSecurity agent) : base(agent) { _current = new SecurityCheckTickets(this); }
public SecurityCheckTickets(StateMachine stateMachine) : base(stateMachine) { _checkingTime = 60; _currentTime = 0; _agent = _stateMachine.Agent as AgentSecurity; }