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


C# FSMState.DoBeforeEntering方法代码示例

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


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

示例1: PerformTransition

    /// <summary>
    /// This method tries to change the state the FSM is in based on
    /// the current state and the transition passed. If current state
    ///  doesn't have a target state for the transition passed, 
    /// an ERROR message is printed.
    /// </summary>
    public void PerformTransition(Transition trans)
    {
        // Check for NullTransition before changing the current state
        if (trans == Transition.NullTransition)
        {
            Debug.LogError("FSM ERROR: NullTransition is not allowed for a real transition");
            return;
        }
 
        // Check if the currentState has the transition passed as argument
        StateID id = currentState.GetOutputState(trans);
        if (id == StateID.NullStateID)
        {
            Debug.LogError("FSM ERROR: State " + currentStateID.ToString() +  " does not have a target state " + 
                           " for transition " + trans.ToString());
            return;
        }
 
        // Update the currentStateID and currentState       
        currentStateID = id;
        foreach (FSMState state in states)
        {
            if (state.ID == currentStateID)
            {
                // Do the post processing of the state before setting the new one
                currentState.DoBeforeLeaving();
 
                currentState = state;
 
                // Reset the state to its desired condition before it can reason or act
                currentState.DoBeforeEntering();
                break;
            }
        }
 
    } // PerformTransition()
开发者ID:kurainisei,项目名称:SpaceVehicle,代码行数:42,代码来源:FSMSystem.cs

示例2: PerformTransition

    public void PerformTransition(FSMTransition trans)
    {
        if (trans == FSMTransition.NullTransition)
        {
            return;
        }

        FSMStateId id = currentState.GetOutputStateId(trans);

        if (id == FSMStateId.NullState)
        {
            return;
        }

        currentStateId = id;
        foreach(FSMState state in stateList)
        {
            if(state.StateID == id)
            {
                currentState.DoBeforeLeaving();

                currentState = state;

                currentState.DoBeforeEntering();

                break;
            }
        }
    }
开发者ID:foolyoung,项目名称:F02,代码行数:29,代码来源:FSM.cs

示例3: PerformTransition

    /// <summary>
    /// Tries to change the state of the FSM based on the current state 
    /// and the given transition.
    /// If the current state does not have a target state for the passed transition,
    /// no transition will be performed.
    /// </summary>
    /// <param name="transition">Transition</param>
    public void PerformTransition(Transition transition)
    {
        // StateID of the desired transition.
        StateID id = currentState.GetOutputState(transition);

        if (transition == Transition.NullTransition)
            Debug.LogError("FSMState: NullTransition is not allowed.");
        else if (id == StateID.NullStateID)
            Debug.LogError("FSMState: State " + currentStateID.ToString() + " does not have a target state for transition " + transition.ToString());
        else
        {
            // Change current state
            currentStateID = id;

            foreach (FSMState state in states)
            {
                if (state.ID == currentStateID)
                {
                    // Call processing before leaving.
                    currentState.DoBeforeLeaving();

                    //Change current state.
                    currentState = state;

                    //Call proceccing after entering.
                    currentState.DoBeforeEntering();
                    break;
                }
            }
        }
    }
开发者ID:Parzival42,项目名称:Bread,代码行数:38,代码来源:FiniteStateMachine.cs

示例4: PerformTransition

    // next method tries to chage the state the fsm is in based on the current state
    //and the transition passed in. If the current state doesnt have a target state for the transition passed,
    // prints an error message
    public void PerformTransition(Transition trans)
    {
        if (trans == Transition.NullTransition) {
            Debug.LogError("FSM error, NullTransition is not allowed for a real transition");
            return;
        }
        // look at current state
        // see if it has the transition passed as an argument
        StateID id = currentState.GetOutputState(trans); // using method created above
        if (id == StateID.NullStateID) {
            Debug.LogError("FSM ERROR: State " + currentStateID.ToString() + " does not have a target state " +
                           " for transition " + trans.ToString());
            return;

        }
        // update the currentStateID and the currentState
        currentStateID = id;
        foreach (FSMState state in states) {
            if (state.ID == currentStateID) {
                // post processes to do to the state before setting a new one
                currentState.DoBeforeLeaving();
                currentState = state;

                // reset the state to its condition before is can be enacted (reasoning steps included)
                currentState.DoBeforeEntering();
                break;
            }

        } // performTranition()
    }
开发者ID:daxaxelrod,项目名称:Loom-Vr,代码行数:33,代码来源:BankFiniteStateMachine.cs

示例5: PerformTransition

    public void PerformTransition(Transition trans)
    {
        StateID id = currentState.GetNextState (trans);
        currentStateID = id;

        foreach (FSMState state in states)
        {
            if(state.ID == currentStateID)
            {
                currentState.DoBeforeExiting();
                currentState  = state;
                currentState.DoBeforeEntering();
                break;
            }
        }
    }
开发者ID:Greg-Rus,项目名称:Linker,代码行数:16,代码来源:FSM.cs

示例6: PerformTransition

	public void PerformTransition(Transition trans)
	{
		if(trans == Transition.NullTransition)
		{
			Debug.LogError("FSM Error: NullTransition is not allowed for a real transition");
			return;
		}
		
		StateID id = currentState.GetOutputState(trans);
		if(id == StateID.NullStateID)
		{
			Debug.LogError("FSM Error: State " + currentStateID.ToString() + " does not have a target state for transition " + trans.ToString());
			return;
		}
		
		currentStateID = id;
		foreach(FSMState state in states)
		{
			if(state.ID == currentStateID)
			{
				currentState.DoBeforeLeaving();
				
				currentState = state;
				
				currentState.DoBeforeEntering();
				
				break;
			}
		}
	}
开发者ID:longde123,项目名称:pathfinding,代码行数:30,代码来源:FSMSystem.cs

示例7: PerformTransition

    public void PerformTransition(Transition trans)
    {
        if (trans == Transition.NullTransition)
        {
            Debug.Log("Null Transition not allowed");
            return;
        }

        StateID id = currentState.GetOutputState(trans);
        if (id == StateID.NullState)
        {
            Debug.Log("Transition to Null State not allowed");
            return;
        }

        currentStateID = id;
        foreach (FSMState state in states)
        {
           // Debug.Log(state.ID.ToString() + " " + currentStateID.ToString());
            if (state.ID == currentStateID)
            {
                Debug.Log("Performing Transition to: " + state.ID.ToString());
                currentState.DoBeforeLeaving();

                currentState = state;

                currentState.DoBeforeEntering();
                return;
            }
        }

        Debug.Log("Transition Error: Output State does not exist");
        return;
    }
开发者ID:InuoeK,项目名称:ImoutoProject,代码行数:34,代码来源:ImoutoStates.cs


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