本文整理汇总了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;
}
示例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;
}
}