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


C# IState.Enter方法代码示例

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


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

示例1: ChangeState

 protected void ChangeState(IState newState)
 {
     state.Exit();
     state = newState;
     state.Enter();
     Publish(new Events.NetworkOut { Action = (ep) => server.NetworkOut.SetUnitState(ep, Id, newState.EncodeEnum) });
 }
开发者ID:Keldyn,项目名称:BattleOfTheClans,代码行数:7,代码来源:UnitStates.cs

示例2: ChangeState

		public void ChangeState(IState state) {
			if (currentState != null) {
				currentState.Leave(this, state);
			}
			state.Enter(this, currentState);

			this.previousState = currentState;
			this.currentState = state;
		}
开发者ID:Hakua,项目名称:PokeSharp,代码行数:9,代码来源:LogicBrushTool.cs

示例3: ChangeState

 public void ChangeState(IState newState, IActor Actor) {
     if (state != null && newState != null) {
         state.Exit(Actor);
         previousState = state;
         state = newState;
         state.Enter(Actor);
         Actor.Save();
     }
 }
开发者ID:jandar78,项目名称:Novus,代码行数:9,代码来源:AI.cs

示例4: ChangeState

 public void ChangeState(IState state)
 {
     _prevState = _currState;
     _currState = state;
     if (_prevState != null)
         _prevState.Leave();
     if (_currState != null)
         _currState.Enter();
 }
开发者ID:hiyijia,项目名称:UnityGameFramework,代码行数:9,代码来源:StateMachine.cs

示例5: DoState

 public void DoState()
 {
     IState NextState = CurrentState.Step();
     if (NextState.GetType() != CurrentState.GetType())
     {
         CurrentState.Leave();
         CurrentState = NextState;
         CurrentState.Enter();
     }
 }
开发者ID:milesgray,项目名称:resatiate,代码行数:10,代码来源:FSM.cs

示例6: Update

 public void Update()
 {
     IState previous = _state;
     _state = _state.Update();
     if(_state != previous)
     {
         previous.Quit();
         _state.Enter();
     }
 }
开发者ID:malaybaku,项目名称:harriet,代码行数:10,代码来源:StateMachine.cs

示例7: ChangeState

        public virtual void ChangeState(ITransition transition)
        {
            if (transition == null)
            {
                throw new ArgumentNullException(nameof(transition), "Cannot change state with a null transition");
            }

            var oldState = this.State;
            var newState = this.GetDestinationState(transition);

            if (newState == null)
            {
                throw new InvalidTransitionException(oldState, transition);
            }

            FireChanging(newState);

            // Exit old State
            try
            {
                State.Exit(transition);
            }
            catch (Exception e)
            {
                throw new StateFailedToExitException(oldState, transition, e);
            }

            // Change State
            State = newState;

            // Enter new State
            try
            {
                State.Enter(transition);
            }
            catch (Exception e)
            {
                throw new StateFailedToEnterException(oldState, transition, newState, e);
            }

            FireChanged();

            State.Action(this);
        }
开发者ID:dickiepotter,项目名称:State,代码行数:44,代码来源:StateMachineBase.cs

示例8: 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

示例9: ProcessNextState

        public void ProcessNextState()
        {
			if (null != m_CurrentState)
			{
                if (ProcessCurrentStateExit() && !m_CurrentState.Exit())
                {
                    m_NextState = m_CurrentState;//yes this is right - don't let them change state
                }
			}

            m_CurrentState = m_NextState;
            m_NextState = null;

            SetControlLayout(m_CurrentState.Control as IContextPanelControl);

			m_CurrentState.Enter();
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:17,代码来源:UIStateMachine.cs

示例10: ChangeState

        protected void ChangeState(IState newState)
        {
            if (aiState == newState) return;

            if (aiState != null)
                aiState.Exit();
            aiState = newState;
            aiState.Enter();
            OnChangesState();
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:10,代码来源:NPC.cs

示例11: ChangeState

        /// <summary>
        /// Pushes the machine into a new state and retains the current state as previous state.
        /// </summary>
        /// <param name="newState"></param>
        public void ChangeState(IState newState)
        {
            if(newState == null)
            {
                //System.Diagnostics.Debug.WriteLine("Attempted to set a null state for " + m_Owner.ToString());
            #if DEBUG
                throw new Exception("Attempted to set a null state for " + m_Owner.ToString());
            #endif
                return;
            }

            if (m_Owner.OnBeforeCurrentStateChanged(this, m_CurrentState, newState))
            {
                m_PreviousState = m_CurrentState;

                if (m_CurrentState != null)
                {
                    m_CurrentState.Exit(m_Owner);
                }
                m_CurrentState = newState;
                m_CurrentState.Enter(m_Owner);

                m_Owner.OnAfterCurrentStateChanged(this, m_PreviousState, m_CurrentState);
            }
        }
开发者ID:kamilion,项目名称:WISP,代码行数:29,代码来源:StateMachine.cs

示例12: TryChangeState

        public virtual bool TryChangeState(ITransition transition)
        {
            if (transition == null)
            {
                return false;
            }

            var oldState = this.State;
            var newState = this.GetDestinationState(transition);

            if (newState == null)
            {
                return false;
            }

            FireChanging(newState);

            // Exit old State
            try
            {
                State.Exit(transition);
            }
            catch
            {
                return false;
            }

            // Change State
            State = newState;

            // Enter new State
            try
            {
                State.Enter(transition);
            }
            catch
            {
                State = oldState;
                return false;
            }

            FireChanged();

            try
            {
                State.Action(this);
            }
            catch
            {
                return false;
            }

            return true;
        }
开发者ID:dickiepotter,项目名称:State,代码行数:54,代码来源:StateMachineBase.cs

示例13: TransitionState

        private void TransitionState(IState state)
        {
            mPlanner.Exit();
            mPlanner = state;

            if (mPlanner.Enter())
                agent.data.flags &= ~NavFlag.PlannerFailed;
            else
            {
                agent.data.flags |= NavFlag.PlannerFailed;
                Debug.LogError(agent.transform.name + ": Planner transition failed: " + state);
            }
        }
开发者ID:tsuixl,项目名称:act,代码行数:13,代码来源:NavPlanner.cs

示例14: EnterAncestors

        /// <summary>
        /// Calls all <see cref="RHFSM.State.Enter"/> methods on all states from the ancestor to the target state in the correct order.
        /// </summary>
        /// <param name="targetState">The target state down to which <see cref="RHFSM.State.Enter"/> of all states will be called. This state will be entered, too.</param>
        /// <param name="startAncestor">The ancestor that will function as a starting point for the calls downwards through all states.
        /// This state will not be entered, since it already should be active.</param>
        /// <remarks>This algorithm is recursive. It moves from the <paramref name="targetState"/> up to the <paramref name="startAncestor"/>.
        /// When the ancestor is found, it drops all the way back, calling the <see cref="RHFSM.State.Enter"/> method in the correct order.</remarks>
        internal void EnterAncestors( IState targetState, IState startAncestor )
        {
            if ( targetState == null )
            {
                throw new ArgumentNullException( "targetState", "The given state must not be null." );
            }

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

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

            // IF current is nca, Enter() it and return.
            if ( targetState == startAncestor )
            {
                return;
            }

            IState nextParent = targetState.Parent == null ? targetState : targetState.Parent;
            this.EnterAncestors( nextParent, startAncestor );

            targetState.Enter();
        }
开发者ID:galaktor,项目名称:ngin,代码行数:36,代码来源:Machine.cs

示例15: SetAgentPlanner

        /// <summary>
        /// Applies a new planner to an existing agent.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The manager expects to take ownership of the planner.  It also assumes that the planner 
        /// is inactive but ready to activate.
        /// </para>
        /// </remarks>
        /// <param name="index">The index of the agent.</param>
        /// <param name="planner">The new planner. (Must not be null.)</param>
        public bool SetAgentPlanner(int index, IState planner)
        {
            if (planner == null || mPlanners[index] == null)
                return false;

            mPlanners[index].Exit();

            if (planner.Enter())
            {
                mPlanners[index] = planner;
                return true;
            }
            else
            {
                RemoveAgent(index);
                return false;
            }
        }
开发者ID:oathx,项目名称:Six,代码行数:29,代码来源:NavManager.cs


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