本文整理汇总了C#中State.OnEnter方法的典型用法代码示例。如果您正苦于以下问题:C# State.OnEnter方法的具体用法?C# State.OnEnter怎么用?C# State.OnEnter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State.OnEnter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveTo
public void MoveTo(State state) {
if (stateStack.Count > 0) {
var top = stateStack.Pop();
top.OnExit();
stateStack.Clear();
}
state.StateMachine = this;
stateStack.Push(state);
state.OnEnter();
}
示例2: AddState
public void AddState(Enum name, Action<Enum> enterCallback, Action updateCallback, Action<Enum> exitCallback)
{
State state = new State (name, enterCallback, updateCallback, exitCallback);
this.states.Add (state.Name, state);
if (null == this.currentState) {
this.currentState = state;
state.OnEnter (null);
}
}
示例3: SetState
protected void SetState(int stateID)
{
if (_curState != null)
_curState.OnLeave(this);
_curState = _dicStates[stateID];
_curStateID = stateID;
_curState.OnEnter(this);
}
示例4: Awake
void Awake()
{
states = new Dictionary<System.Type, State> ();
states.Add(typeof(FlyingState), new FlyingState(this));
states.Add(typeof(BarrelRollLeft), new BarrelRollLeft(this));
states.Add(typeof(BarrelRollRight), new BarrelRollRight(this));
states.Add(typeof(TrainTransition), new TrainTransition(this));
currentState = states[typeof(FlyingState)];
currentState.OnEnter();
}
示例5: Start
/// <summary>
/// This calls initialize on each state in the fsm.
/// </summary>
protected virtual void Start()
{
SetStates();
Initialize();
foreach ( State state in states.Values )
{
state.Initialize(this);
}
currentState = states.Values.ElementAt( 0 );
currentState.OnEnter();
}
示例6: ForceChangeToState
public void ForceChangeToState(State newState)
{
currentState = newState; // Update the current state
newState.OnEnter(); // Enter the new state
}
示例7: EnterState
public void EnterState(State newState)
{
currentState.OnExit(); // Exit the current state
currentState = newState; // Update the current state
newState.OnEnter(); // Enter the new state
}
示例8: SetStateInternal
private bool SetStateInternal()
{
if(_currentState != null)
{
if(_currentState.OnExit != null)
{_currentState.OnExit();}
_currentState.ProcessLinkTo(nextState);
_lastState = _currentState.Name;
}
_currentState = _stateList[nextState];
nextState = "";
Logger.Log(_name + " - Entering State: " + _currentState.Name, 0);
if(_currentState != null && _currentState.OnEnter != null)
{_currentState.OnEnter();}
return true;
}
示例9: state_change_me
public void state_change_me(State current, State newstate)
{
int index = list.IndexOf(current);
if (index == -1)
{
Debug.LogError("state_change_me(" + current + ", " + newstate + ") : " + current + " introuvable !");
return;
}
while (index > 0)
{
index--;
list[index].OnLeave();
}
current.OnLeave();
index = list.IndexOf(current);
if (index == -1)
{
Debug.LogError("state_change_son(" + current + ", " + newstate + ") : " + current + ".OnLeave() ne doit pas changer l'�tat !");
return;
}
list.RemoveRange(0, index + 1);
list.Insert(0, newstate);
newstate.OnEnter();
index = list.IndexOf(newstate);
if (index != -1 && list.Count > index + 1)
list[index + 1].OnChildChanged();
}
示例10: PushTo
public void PushTo(State state) {
state.StateMachine = this;
stateStack.Push(state);
state.OnEnter();
}
示例11: EnterState
public void EnterState(System.Type newStateType)
{
currentState.OnExit();
currentState = states[newStateType];
currentState.OnEnter();
}