本文整理汇总了C#中IState.OnEnter方法的典型用法代码示例。如果您正苦于以下问题:C# IState.OnEnter方法的具体用法?C# IState.OnEnter怎么用?C# IState.OnEnter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IState
的用法示例。
在下文中一共展示了IState.OnEnter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeState
public void ChangeState(IState _state)
{
IState prevState = currState;
if (_state != currState && _state != null)
{
prevState.OnExit();
currState = _state;
currState.OnEnter();
}
}
示例2: TransitionTo
public void TransitionTo(IState state)
{
if (!(state is IdleState) && !_stackState.Contains(state))
_stackState.Add(state);
CurrentState = state;
CurrentState.FiniteStateMachine = this;
CurrentState.OnLeave = OnStateLeave;
Log.Write("Transition to: {0}", state.GetType(), ConsoleColor.Red);
CurrentState.OnEnter();
}
示例3: ChangeState
public void ChangeState(IState newState)
{
if (newState == null)
throw new ArgumentNullException("newState","The input state cannot be null");
PreviousState = CurrentState;
if (CurrentState != null)
CurrentState.OnExit(new AgentEventArgs<Agent>(Agent));
CurrentState = newState;
CurrentState.OnEnter(new AgentEventArgs<Agent>(Agent));
}
示例4: PushNovelState
public void PushNovelState(IState state)
{
stateStack.Add(state);
state.OnEnter();
}
示例5: ChangeState
void ChangeState(IState newState)
{
if(state != null) state.OnExit();
state = newState;
StateInputHandler = state;
if (state != null) state.OnEnter();
if (StateChanged != null) StateChanged(this, null);
}
示例6: Start
// Use this for initialization
void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
// instantiate dictionary and add states
states = new Dictionary<string, IState>();
states.Add(IdleState, new PlayerIdleState());
states.Add(RunState, new PlayerRunState());
states.Add(JumpState, new PlayerJumpState());
if (floorLayer == 0) // if floor layer has not been set in the inspector, set it to layer named Floor
{
floorLayer = LayerMask.GetMask("Floor");
}
// set the current state to Idle
currentState = states[IdleState];
currentState.OnEnter(this);
}
示例7: Change
public void Change(States stateName, params object[] optional)
{
mCurrentState.OnExit();
mCurrentState = mStates[stateName];
mCurrentState.OnEnter(optional);
}
示例8: ChangeState
void ChangeState(IState newState)
{
if (state != null) state.OnExit();
state = newState;
if (state != null) state.OnEnter();
}