Example #1
0
 public Planner(PlanningTree root, GameObject agent, NavMeshAgent agentNav, WorldState ws)
 {
     this.root     = root;
     this.agent    = agent;
     this.agentNav = agentNav;
     this.ws       = ws;
 }
Example #2
0
    private int runPlanFromNode(PlanningTree node)
    {
        // Debug.Log(node.task);
        if (!preconditionsMet(node.task))
        {
            return(-1);
        }
        int result = -1;

        if (node.children.Count == 0)
        {
            return(taskExecutor(node.task));
        }

        for (int i = 0; i < node.children.Count; i++)
        {
            result = runPlanFromNode(node.children[i]);
            if (result == 1)
            {
                executing = false;
                return(1);
            }
        }
        return(result);
    }
Example #3
0
    private void initializePlanningTree()
    {
        PlanningTree root = new PlanningTree(null, "BeAwesome");

        root.addChild(new PlanningTree(root, "Teleport"));
        root.addChild(new PlanningTree(root, "AvoidEnemy"));
        root.addChild(new PlanningTree(root, "CollectItems"));

        PlanningTree curNode = root.children[1];

        curNode.addChild(new PlanningTree(curNode, "StayInPosition"));
        curNode.addChild(new PlanningTree(curNode, "HideInAlcove"));

        currentNode = root;
    }
Example #4
0
 public void addChild(PlanningTree node)
 {
     children.Add(node);
 }
Example #5
0
 public void addChildToPos(int childPos, PlanningTree node)
 {
     children.Insert(childPos, node);
 }
Example #6
0
 public PlanningTree(PlanningTree parent, string task)
 {
     this.parent = parent;
     this.task   = task;
 }