Exemplo n.º 1
0
    public void Switch2(int switchState, bool isNotReset)
    {
        BehaviorState behavior = GetBehavior(switchState);

        if (behavior != null)
        {
            ResetWait();
            if (behavior == mCurrentBehavior)
            {
                if (!isNotReset)
                {
                    mCurrentBehavior.End(mRole, mCurrentBehavior);
                    mCurrentBehavior.Start(mRole, mCurrentBehavior);
                }
            }
            else
            {
                if (mCurrentBehavior != null)
                {
                    mCurrentBehavior.End(mRole, behavior);
                }

                BehaviorState lastBehavior = mCurrentBehavior;
                mCurrentBehavior = behavior;
                mCurrentBehavior.Start(mRole, lastBehavior);
            }
        }
    }
Exemplo n.º 2
0
    public void UpdateBehaviors()
    {
        if (mCurrentBehavior == null)
        {
            if (mStartBehavior != null)
            {
                mCurrentBehavior = mStartBehavior;
                mCurrentBehavior.Start(mRole, null);
            }
        }
        else
        {
            int nBehavior = mCurrentBehavior.Update(mRole);
            nBehavior = CheckFSMCurBehavior(nBehavior);
            if (nBehavior != mCurrentBehavior.mnBehavior)
            {
                if (mCurrentBehavior == mOverrideBehavior)
                {
                    mOverrideBehavior = null;
                }

                if (nBehavior == -1 && (mStartBehavior != null))
                {
                    nBehavior = mStartBehavior.mnBehavior;
                }

                BehaviorState behavior = GetBehavior(nBehavior);
                if (behavior == null)
                {
                    behavior = mStartBehavior;
                }

                if (behavior != null)
                {
                    Switch2(behavior.mnBehavior, true);
                }
                else
                {
                    mCurrentBehavior = null;
                }
            }
        }
    }