Exemplo n.º 1
0
        // ------------------------------------------------------------------
        // Desc:
        // ------------------------------------------------------------------

        public void UpdateTransitions()
        {
            if (inTransition)
            {
                // update transition
                if (currentTransition.onTransition())
                {
                    // transition on end
                    if (currentTransition.onEnd != null)
                    {
                        currentTransition.onEnd();
                    }

                    // enter states
                    State targetState = currentTransition.target;
                    if (targetState == null)
                    {
                        targetState = currentTransition.source;
                    }

                    if (targetState.parent != null)
                    {
                        targetState.parent.EnterStates(targetState, currentTransition.source);
                    }
                    else
                    {
                        Debug.Log("targetState = " + targetState.name + ", " + name);
                    }

                    //
                    currentTransition = null;
                    inTransition      = false;
                }
            }
            else
            {
                for (int i = 0; i < currentStates.Count; ++i)
                {
                    State activeChild = currentStates[i];
                    activeChild.UpdateTransitions();
                }
            }
        }