示例#1
0
    private void IdleState()
    {
        idle = (fsm, gameObj) => {
            List <KeyValuePair <string, object> > worldState = goapAgent.GetWorldState();

            KeyValuePair <string, object> goal = goapAgent.GetSubGoals();
            planner.Reset();
            if (!goal.Equals(new KeyValuePair <string, object>()))
            {
                Queue <GoapAction> plan = planner.Plan(availableActions, worldState, goal);

                if (plan != null)
                {
                    // we have a plan, hooray!
                    currentActions = plan;
                    goapAgent.PlanFound(goal, plan);

                    fsm.popState();
                    fsm.pushState(act);
                }
                else
                {
                    goapAgent.PlanFailed(goal);
                    fsm.popState();
                    fsm.pushState(idle);
                }
            }
            else
            {
                goapAgent.GameFinished();
            }
        };
    }