Exemplo n.º 1
0
    IEnumerator GiveCommand()
    {
        Debug.Log("Starting command...");
        Planning.Planner planner          = null;
        bool             IsClickOnPlanner = Mouseover <Planning.Planner>(out planner);

        if (!IsClickOnPlanner)
        {
            Debug.Log("Not a planner");
            yield return(null);
        }
        else
        {
            Debug.Log("Hit" + planner.gameObject.name);
        }
        // Wait until they let go
        AIGoal goal = null;

        yield return(new WaitUntil(()
                                   => Mouseover(out goal)));

        Debug.Log("Commanding " + planner.gameObject.name + " to " + goal.gameObject.name);
        // Add the goal's conditions to the planner
        planner.goal = goal.goal.Copy();
        planner.DoPlanning();
        // Wait until it's ready
        yield return(new WaitUntil(() => !planner.currentlyPlanning));

        // Start the AI routine to achieve whatever goal you just set;
        planner.ExecutePlan();

        Debug.Log("Ending Command");
        yield return(null);
    }
Exemplo n.º 2
0
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (GUILayout.Button("\nPlan\n"))
     {
         // Say this three times fast
         Planning.Planner plan = (Planning.Planner)target;
         plan.DoPlanning();
     }
     if (GUILayout.Button("\nExecute\n"))
     {
         // Say this three times fast
         Planning.Planner plan = (Planning.Planner)target;
         plan.ExecutePlan();
     }
 }