Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Flocking
- {
- public class SubMission
- {
- private List<Goal> goals; // goals that need to be accomplished for this mission
- public SubMission()
- {
- goals = new List<Goal>();
- }
- public void AddGoal(Goal goal)
- {
- goals.Add(goal);
- }
- public void Update(float dt)
- {
- foreach(var goal in goals)
- goal.Update(dt);
- }
- public Goal.State GetState()
- {
- int goalsInProgress = 0;
- foreach(var goal in goals)
- {
- switch(goal.GetState())
- {
- // if a goal has failed, return Failed
- case Goal.State.Failed:
- return Goal.State.Failed;
- case Goal.State.InProgress:
- ++goalsInProgress;
- break;
- }
- }
- // if there are no goals in progress, it means all goals were completed
- if( goalsInProgress == 0 )
- return Goal.State.Accomplished;
- return Goal.State.InProgress;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement