Exemplo n.º 1
0
    public HSMTransition EvalTransition()
    {
        HSMTransition res = m_NextTransition;

        m_NextTransition = new HSMTransition();
        return(res);
    }
Exemplo n.º 2
0
    private static void BuildTransitions(Dictionary <HSMStateAsset <TConcreteAssetClass, THSMTransitionWrapper, TState, TTrigger>, HSMState <TState, TTrigger> > relationDictionary, HSMStateAsset <TConcreteAssetClass, THSMTransitionWrapper, TState, TTrigger> baseAsset)
    {
        HSMState <TState, TTrigger> currentState = relationDictionary[baseAsset];

        for (int j = 0; j < baseAsset.transitions.Length; j++)
        {
            HSMTransition <TState, TTrigger> transition = baseAsset.transitions[j].ToHSMTransition();

            currentState.MakeChildTransition(transition.stateFrom, transition.trigger, transition.stateTo);
        }

        for (int i = 0; i < baseAsset.childs.Length; i++)
        {
            HSMStateAsset <TConcreteAssetClass, THSMTransitionWrapper, TState, TTrigger> currentAssetChild = baseAsset.childs[i];

            BuildTransitions(relationDictionary, currentAssetChild);
        }
    }
Exemplo n.º 3
0
    private void ApplyHSMTransitions()
    {
        while (m_TransitionQueue.Count != 0)
        {
            HSMTransition transition = m_TransitionQueue.Dequeue();
            switch (transition.m_Type)
            {
            case HSMTransition.EType.Clear:
                // Don't apply other transition as we completly change the stack
                m_TransitionQueue.Clear();
                ClearStack();
                PushState(transition.m_DestinationID);
                break;

            case HSMTransition.EType.Siblings:
                ReplaceState(transition.m_SourceID, transition.m_DestinationID);
                break;

            case HSMTransition.EType.Child:
                HSMState peekState = m_StateStack.Peek();
                if (peekState.GetID() == transition.m_SourceID)
                {
                    PushState(transition.m_DestinationID);
                }
                break;

            case HSMTransition.EType.Exit:
                ReplaceState(transition.m_SourceID, null);
                break;

            case HSMTransition.EType.Top:
                PushState(transition.m_DestinationID);
                break;

            case HSMTransition.EType.None:
                break;

            default:
                Assert.IsTrue(false, "Invalid transition type");
                break;
            }
        }
    }
Exemplo n.º 4
0
 protected void ChangeNextTransition(HSMTransition.EType type, StateID destinationID = null)
 {
     m_NextTransition = new HSMTransition(type, m_ID, destinationID);
 }