Exemple #1
0
    /// <summary>
    /// This will go through the subgoals and will remove
    /// the goals which are completed at the end of the list
    /// and will then process the next goal
    /// </summary>
    /// <returns>The status of the current goal</returns>
    protected GoalProps.goalStatus ProcessSubGoals()
    {
        //Removes completed and failed goals from the front
        while ((subGoals.Count > 0) && (subGoals[0].isCompleted() || subGoals[0].hasFailed()))
        {
            subGoals[0].Terminate();
            subGoals.RemoveAt(0);
        }

        //Process first goal at list
        if (subGoals.Count > 0)
        {
            // print(subGoals[0]);
            GoalProps.goalStatus status = subGoals[0].Process();

            if (status == GoalProps.goalStatus.COMPLETED && subGoals.Count - 1 > 1)
            {
                return(GoalProps.goalStatus.ACTIVE);
            }

            return(status);
        }
        else //no more goals, return completed
        {
            return(GoalProps.goalStatus.COMPLETED);
        }
    }
    /// <summary>
    /// Goes thru the subgoals and process' them.
    /// </summary>
    /// <returns>The status of the goal we are processing.</returns>
    public override GoalProps.goalStatus Process()
    {
        ActivateIfInactive();
        GoalProps.goalStatus SubgoalStatus = ProcessSubGoals();

        if (SubgoalStatus == GoalProps.goalStatus.COMPLETED || SubgoalStatus == GoalProps.goalStatus.FAILED)
        {
            myProperties.myStatus = GoalProps.goalStatus.INACTIVE;
        }

        return(myProperties.myStatus);
    }