[TaskDescription("Similar to the parallel selector task, except the parallel complete task will return the child status as soon as the child returns success or failure."+
"The child tasks are executed simultaneously.")]
[TaskIcon("{SkinColor}ParallelCompleteIcon.png")]
publicclassParallelComplete:Composite
{
// The index of the child that is currently running or is about to run.
privateintcurrentChildIndex;
// The task status of every child task.
privateTaskStatus[]executionStatus;
publicoverridevoidOnAwake()
{
// Create a new task status array that will hold the execution status of all of the children tasks.
executionStatus=newTaskStatus[children.Count];
}
publicoverridevoidOnChildStarted(intchildIndex)
{
// One of the children has started to run. Increment the child index and set the current task status of that child to running.
currentChildIndex++;
executionStatus[childIndex]=TaskStatus.Running;
}
publicoverrideboolCanRunParallelChildren()
{
// This task can run parallel children.
returntrue;
}
publicoverrideintCurrentChildIndex()
{
returncurrentChildIndex;
}
publicoverrideboolCanExecute()
{
// We can continue executing if we have more children that haven't been started yet.