Exemple #1
0
        // ------------------------------------------------------------------
        // Desc:
        // ------------------------------------------------------------------

        public void CheckConditions()
        {
            // if we are in transtion, don't do anything
            if (inTransition)
            {
                return;
            }

            //
            for (int i = 0; i < currentStates.Count; ++i)
            {
                State activeChild = currentStates[i];

                // NOTE: if parent transition triggerred, the child should always execute onExit transition
                for (int j = 0; j < activeChild.transitionList.Count; ++j)
                {
                    Transition transition = activeChild.transitionList[j];
                    if (transition.onCheck())
                    {
                        // exit states
                        transition.source.parent.ExitStates(transition.target, transition.source);      // TODO: 这里应该不进行++i

                        // route happends here
                        if (transition.target.mode == Mode.Exclusive &&
                            transition.target.children.Count > 0)
                        {
                            State firstChild = transition.target.children[0];
                            if (firstChild.isRoute)
                            {
                                firstChild.CheckRoute(transition);
                            }
                        }

                        // transition on start
                        if (transition.onStart != null)
                        {
                            transition.onStart();
                        }

                        // set current transition
                        currentTransition = transition;
                        inTransition      = true;

                        break;
                    }
                }

                if (inTransition == false)
                {
                    activeChild.CheckConditions();
                }
            }
        }