Esempio n. 1
0
    public static bool agentIsPlaying(Agent agt)
    {
        List <ProceduralBehavior> proceduralBehaviors = GameObject.Find("MascaretApplication").GetComponent <UnityMascaretApplication>().ProcedureBehaviorExecution.ProceduralBehaviors;
        ProceduralBehavior        proceduralBehavior  = (ProceduralBehavior)agt.getBehaviorExecutingByName("ProceduralBehavior");

        if (proceduralBehavior != null)
        {
            if (proceduralBehavior.runningProcedures.Count > 0)
            {
                ProcedureExecution procExec = proceduralBehavior.runningProcedures[proceduralBehavior.runningProcedures.Count - 1];

                List <ActionNode> nodesToExecute = procExec.getActionToExecuteFor(agt.Aid);
                if (nodesToExecute.Count > 0)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Esempio n. 2
0
    public static ActionNode getNextNodeToExecute(Agent agt)
    {
        List <ProceduralBehavior> proceduralBehaviors = GameObject.Find("MascaretApplication").GetComponent <UnityMascaretApplication>().ProcedureBehaviorExecution.ProceduralBehaviors;

        PrintSingleton.Instance.log("Agent : " + agt.name);
        ProceduralBehavior proceduralBehavior = (ProceduralBehavior)agt.getBehaviorExecutingByName("ProceduralBehavior");

        if (proceduralBehavior != null)
        {
            if (proceduralBehavior.runningProcedures.Count > 0)
            {
                PrintSingleton.Instance.log("Procedures : " + proceduralBehavior.runningProcedures.Count);
                ProcedureExecution procExec = proceduralBehavior.runningProcedures[proceduralBehavior.runningProcedures.Count - 1];

                List <ActionNode>   nodesToExecute = procExec.getActionToExecuteFor(agt.Aid);
                List <ActivityNode> activeNodes    = new List <ActivityNode>();
                foreach (ActivityExecutionToken t in procExec.getActiveToken())
                {
                    activeNodes.Add(t.currentLocation);
                }
                foreach (ActivityNode t in activeNodes)
                {
                    List <ActionNode> outgoActions = t.getOutgoingActionNode();
                    foreach (ActionNode n in outgoActions)
                    {
                        if (!n.isRunning() && nodesToExecute.Contains(n))
                        {
                            PrintSingleton.Instance.log("Action to execute : " + n.name);
                            return(n);
                        }
                    }
                }
            }
        }
        return(null);
    }