示例#1
0
    private void createMoveToState()
    {
        moveToState = (fsm, gameObject) => {
            GOAPAction action = currentActions.Peek();
            if (action.RequiresInRange() && action.target == null)
            {
                fsm.popState();
                fsm.popState();
                fsm.pushState(idleState);
                return;
            }

            if (dataProvider.moveAgent(action))
            {
                fsm.popState();
            }
        };
    }
示例#2
0
    private void createMoveToTargetState()
    {
        moveToTargetState = (fsm, gameObj) => {
            // Moves AI towards target

            GOAPAction action = currentActions.Peek();

            // Action requires a target but has none. Go back to planning stage
            if (action.requiresInRange() && action.rTarget == null)
            {
                fsm.popState();                  // Clear moveToTargetState
                fsm.popState();                  // Clear performActionState
                fsm.pushState(idleState);
                return;
            }

            // If the moveAgent variable becomes true (which tells us if the AI reached the target), clear moveToTargetState
            if (dataProvider.moveAgent(action))
            {
                fsm.popState();
            }
        };
    }