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