Exemplo n.º 1
0
 public MaterialConcept.MaterialType?GetMaterialType(ScheduledJob job)
 {
     if (job.Action is GetMaterialAction)
     {
         GetMaterialAction action = job.Action as GetMaterialAction;
         return(action.GetMaterial().GetMaterialType());
     }
     return(null);
 }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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");
        }
    }