private int calculateAmountOfResourceToCollect(MaterialConcept.MaterialType materialType) { if (materialType == MaterialConcept.MaterialType.Wood) { int totalWoodCount = RPGAgentTools.FindObjectsOfType <StorageComponent> ().Select(component => component.GetWoodCount()).Sum(); return(controller.WoodToCollect - totalWoodCount); } else { int totalStoneCount = RPGAgentTools.FindObjectsOfType <StorageComponent> ().Select(component => component.GetStoneCount()).Sum(); return(controller.StoneToCollect - totalStoneCount); } }
private void requestCollectingStone(AgentId agentId) { string conversationId = "stone_" + agentId.GetGlobalName() + "_" + Time.fixedTime; int totalStoneCount = RPGAgentTools.FindObjectsOfType <StorageComponent> ().Select(component => component.GetStoneCount()).Sum(); int amount = controller.StoneToCollect - totalStoneCount; AgentAction action = new GetMaterialAction(new MaterialConcept(MaterialConcept.MaterialType.Stone), amount); AgentMessage message = new AgentMessage(AgentMessage.PerformativeType.REQUEST); message.Sender = coordinatorAgent.AId; message.Receiver = agentId; message.Protocol = Protocols.FIPA_REQUEST; message.Content = action; message.ConversationId = conversationId; ScheduledJob job = new ScheduledJob(agentId, action, conversationId); coordinatorAgent.ScheduledJobs.Add(job); coordinatorAgent.Send(message); }