Example #1
0
        public bool Proceed()
        {
            if (entrance == null || exit == null)
            {
                throw new MissingComponentException();
            }
            if (!isActivated)
            {
                return(false);
            }

            bool resultFromExit = false;

            if (state == TaskProgressState.Idle)
            {
                if (entrance.CheckPassive())
                {
                    state            = TaskProgressState.Started;
                    startingTime     = new TimeState(TimeState.GetGlobalTimer());
                    cantSkipInterval = GlobalConstraint.TASK_CANT_SKIP_INTERVAL;
                    entrance.Deactivate();
                    exit.ActivateAndStartMonitoring();
                }
            }
            else if (state == TaskProgressState.Started)
            {
                for (int i = 0; i < instructions.Count; i++)
                {
                    instructions[i].Proceed();
                    if (!instructions[i].isAudioInstructionEnded())
                    {
                        cantSkipInterval--;
                    }
                }
                exit.CheckPassive();
                resultFromExit = exit.IsSatisfied();
                if (resultFromExit && cantSkipInterval < 0)
                {
                    TaskEndState evaluateResult = Evaluate();
                    if (evaluateResult == TaskEndState.Correct)
                    {
                        state = TaskProgressState.Ended;
                        for (int i = 0; i < instructions.Count; i++)
                        {
                            instructions[i].WrapUp();
                        }
                        MoveNext(evaluateResult);
                    }
                }
            }
            return(resultFromExit);
        }
Example #2
0
        public bool Proceed(List <Interface> interfaces)
        {
            if (entrance == null || exit == null)
            {
                throw new MissingComponentException();
            }

            if (!isActivated)
            {
                return(false);
            }
            if (state == TaskProgressState.Idle)
            {
                if (entrance.Check())
                {
                    state            = TaskProgressState.Started;
                    startingTime     = new TimeState(TimeState.GetGlobalTimer());
                    cantSkipInterval = GlobalConstraint.TASK_CANT_SKIP_INTERVAL;
                    entrance.Deactivate();
                    exit.ActivateAndStartMonitoring();
                }
            }
            else if (state == TaskProgressState.Started)
            {
                if (interfaces.Count > 0)
                {
                    instruction.Proceed(interfaces);
                    if (!instruction.isAudioInstructionEnded())
                    {
                        cantSkipInterval--;
                    }
                }
                if (exit.Check())// && cantSkipInterval < 0)
                {
                    state = TaskProgressState.Ended;
                    MoveNext(Evaluate());
                }
            }
            return(exit.isSatisfied);
        }
Example #3
0
 private void StateChangeHandler(State newState)
 {
     Debug.Log(TimeState.GetGlobalTimer() + "\tTask: " + name + "\tTaskProgressState: " + newState.ToString());
     ConditionPublisher.Instance.Send(new TaskState(this, newState as TaskProgressState));
 }