public CancelAllJobsOfTypeBehaviour(CoordinatorAgent agent, CoordinatorController controller,
                                     MaterialConcept.MaterialType materialType) : base(agent)
 {
     this.coordinatorAgent = agent;
     this.controller       = controller;
     this.materialType     = materialType;
 }
 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);
     }
 }
Ejemplo n.º 3
0
    private void processCancelMaterialActionRequest(AgentMessage message)
    {
        GetMaterialAction action = message.Content as GetMaterialAction;

        MaterialConcept.MaterialType materialType = action.GetMaterial().GetMaterialType();
        if (materialType == MaterialConcept.MaterialType.Wood)
        {
            behaviours.FindAll(it => it.GetType() == typeof(CollectWoodBehaviour)).ForEach(it => it.Stop());
        }
        else if (materialType == MaterialConcept.MaterialType.Stone)
        {
            behaviours.FindAll(it => it.GetType() == typeof(CollectStoneBehaviour)).ForEach(it => it.Stop());
        }
        AgentMessage reply = message.Reply(AgentMessage.PerformativeType.INFORM);

        reply.Content = new CancelledJobConcept();
        Send(reply);
    }
Ejemplo n.º 4
0
    private RPGAgentToolkit.Core.Behaviour getCollectingBehaviour(AgentMessage message, Action <GatheredMaterialConcept> actionOnCollectingCompleted)
    {
        GetMaterialAction action = message.Content as GetMaterialAction;
        int amount = action.GetAmount();

        MaterialConcept.MaterialType materialType = action.GetMaterial().GetMaterialType();
        if (materialType == MaterialConcept.MaterialType.Wood)
        {
            return(new CollectWoodBehaviour(this, controller.gameObject, controller.Speed, amount, actionOnCollectingCompleted));
        }
        else if (materialType == MaterialConcept.MaterialType.Stone)
        {
            return(new CollectStoneBehaviour(this, controller.gameObject, controller.Speed, amount, actionOnCollectingCompleted));
        }
        else
        {
            throw new UnityException("Unknown material type");
        }
    }
Ejemplo n.º 5
0
 public List <ScheduledJob> GetAllJobsOfType(MaterialConcept.MaterialType type)
 {
     return(ScheduledJobs.FindAll(job => GetMaterialType(job) == type));
 }
Ejemplo n.º 6
0
 public OrderGatheringMaterialBehaviour(Agent agent, string receiver, MaterialConcept.MaterialType materialType, int amount) : base(agent)
 {
     this.receiver     = receiver;
     this.materialType = materialType;
     this.amount       = amount;
 }