当前位置: 首页>>代码示例>>C#>>正文


C# IState.Exit方法代码示例

本文整理汇总了C#中IState.Exit方法的典型用法代码示例。如果您正苦于以下问题:C# IState.Exit方法的具体用法?C# IState.Exit怎么用?C# IState.Exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IState的用法示例。


在下文中一共展示了IState.Exit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAgent

        /// <summary>
        /// Adds an agent to the manager.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The manager expects to take ownership of the state objects.  It also assumes that the 
        /// state objects are inactive but ready to activate.
        /// </para>
        /// </remarks>
        /// <param name="planner">The agent's planner.</param>
        /// <param name="mover">The agent's mover.</param>
        /// <returns>The index of the agent, or -1 on failure.</returns>
        public int AddAgent(IState planner, IState mover)
        {
            if (planner == null || mover == null)
                return -1;

            for (int i = 0; i < mPlanners.Length; i++)
            {
                if (mPlanners[i] == null)
                {
                    if (!planner.Enter())
                        break;

                    if (!mover.Enter())
                    {
                        planner.Exit();
                        break;
                    }

                    mPlanners[i] = planner;
                    mMovers[i] = mover;

                    return i;
                }
            }

            return -1;
        }
开发者ID:oathx,项目名称:Six,代码行数:39,代码来源:NavManager.cs

示例2: ExitAncestors

        /// <summary>
        /// Exits all states upwards, beginning with <paramref name="startState"/> and stopping right before <paramref name="targetAncestor"/>.
        /// </summary>
        /// <param name="startState">The starting point of the path upwards. This state will be exited, too.</param>
        /// <param name="targetAncestor">The end of the path of states that will be exited. This state will not be exited.</param>
        /// <remarks>This algorithm is not recursive. It moves from the <paramref name="startState"/> up to the <paramref name="targetAncestor"/>,
        /// calling Enter on each state in between.</remarks>
        internal void ExitAncestors( IState startState, IState targetAncestor )
        {
            if ( startState == null )
            {
                throw new ArgumentNullException( "startState", "The given state must not be null." );
            }

            if ( targetAncestor == null )
            {
                throw new ArgumentNullException( "targetAncestor", "The given state must not be null." );
            }

            if ( targetAncestor.Depth > startState.Depth )
            {
                throw new InvalidOperationException( "The target ancestor must not be deeper than the start state." );
            }

            while ( startState != targetAncestor )
            {
                startState.Exit();
                startState = startState.Parent;
            }
        }
开发者ID:galaktor,项目名称:ngin,代码行数:30,代码来源:Machine.cs


注:本文中的IState.Exit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。