本文整理汇总了C#中FSMState类的典型用法代码示例。如果您正苦于以下问题:C# FSMState类的具体用法?C# FSMState怎么用?C# FSMState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FSMState类属于命名空间,在下文中一共展示了FSMState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddState
/// <summary>
/// Adds a new State into the FSM if it isn't already inside.
/// The first state is also the initial state.
/// </summary>
/// <param name="state">State which will be added.</param>
public void AddState(FSMState state)
{
if (state == null)
Debug.LogError("FSMSystem: Null reference is not allowed!");
else if (states.Count == 0) // Set initial state if it is the first state.
{
states.Add(state);
currentState = state;
currentStateID = state.ID;
}
else
{
bool added = false;
// Check if the state aready has been added.
foreach (FSMState s in states)
{
if (s.ID == state.ID)
{
added = true;
Debug.LogError("FSMSystem: State " + state.ID.ToString() + " has already been added.");
}
}
if (!added)
states.Add(state);
}
}
开发者ID:Parzival42,项目名称:Bread,代码行数:33,代码来源:FiniteStateMachine.cs
示例2: AddState
public void AddState(FSMState state)
{
if (state == null)
{
Debug.LogError("FSM ERROR: Null State reference");
return;
}
if (stateList.Count == 0)
{
stateList.Add(state);
currentState = state;
currentStateId = state.StateID;
return;
}
foreach (FSMState tempState in stateList)
{
if (state.StateID == tempState.StateID)
{
Debug.LogError("state [" + state.StateID.ToString() + "] already added.");
return;
}
}
stateList.Add(state);
}
开发者ID:foolyoung,项目名称:F02,代码行数:26,代码来源:FSM.cs
示例3: initializeDefStates
public void initializeDefStates()
{
FSMState fall = new FSMState(PlayerStates.FALLING);
fall.addTransition(PlayerActions.RUN, PlayerStates.RUNNING);
fall.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.FALL_JUMP);
fsmStates.Add(fall);
FSMState run = new FSMState(PlayerStates.RUNNING);
run.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.JUMPING);
run.addTransition(PlayerActions.FALL, PlayerStates.FALLING);
fsmStates.Add(run);
FSMState jump = new FSMState(PlayerStates.JUMPING);
jump.addTransition(PlayerActions.FALL, PlayerStates.FALLING);
jump.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.DOUBLE_JUMPING);
jump.addTransition(PlayerActions.WALL_SLIDE, PlayerStates.WALL_SLIDING);
fsmStates.Add(jump);
FSMState doubleJump = new FSMState(PlayerStates.DOUBLE_JUMPING);
doubleJump.addTransition(PlayerActions.FALL, PlayerStates.FALLING);
doubleJump.addTransition(PlayerActions.WALL_SLIDE, PlayerStates.WALL_SLIDING);
fsmStates.Add(doubleJump);
FSMState fallJump = new FSMState(PlayerStates.FALL_JUMP);
fallJump.addTransition(PlayerActions.FALL, PlayerStates.RUNNING);
fsmStates.Add(fallJump);
FSMState wallSliding = new FSMState(PlayerStates.WALL_SLIDING);
wallSliding.addTransition(PlayerActions.RUN, PlayerStates.RUNNING);
wallSliding.addTransition(PlayerActions.JUMP_INPUT, PlayerStates.JUMPING);
fsmStates.Add(wallSliding);
}
开发者ID:OscarRPR,项目名称:prototype-infinite-runner,代码行数:32,代码来源:PlayerFSM.cs
示例4: Initialize
protected override void Initialize()
{
player = GameObject.FindGameObjectWithTag("Player");
playercontroller = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
curState = FSMState.Idle;
isDirection();
}
开发者ID:YaFengYi,项目名称:Unity,代码行数:7,代码来源:Enemy1FSM.cs
示例5: AddFSMState
public void AddFSMState(FSMState fsmState)
{
if (fsmState == null)
{
Debug.LogError("state is null");
return;
}
if (fsmStates.Count == 0)
{
fsmStates.Add(fsmState);
curState = fsmState;
curStateID = fsmState.ID;
return;
}
foreach (var state in fsmStates)
{
if (state.ID == fsmState.ID)
{
Debug.LogError("state has exist");
return;
}
}
fsmStates.Add(fsmState);
}
开发者ID:yiliu1203,项目名称:FSM_AI,代码行数:27,代码来源:AdvancedFSM.cs
示例6: UpdateAttackingState
protected void UpdateAttackingState()
{
SendMessage("Shoot");
currentState = FSMState.Evading;
evadingRotation = Random.rotation;
}
开发者ID:flinan,项目名称:FalconEscape,代码行数:7,代码来源:EnemyAI.cs
示例7: EnterState
public override void EnterState(FSMState prevState)
{
base.EnterState(prevState);
if((HeroState)prevState.StateId == HeroState.Seek)
_destination = (prevState as HeroSeekState).Destination;
}
开发者ID:jtuttle,项目名称:umbra-client,代码行数:7,代码来源:HeroWalkState.cs
示例8: AddState
// Add State
public void AddState(FSMState tstate)
{
if(tstate == null)
{
Debug.LogError("Null reference when adding State");
return;
}
// Initial State
if(states.Count == 0)
{
states.Add(tstate);
curState = tstate;
curStateID = tstate.STATE_ID;
return;
}
// Check for duplicate State before adding
foreach(FSMState s in states)
{
if(s.STATE_ID == tstate.STATE_ID)
{
Debug.LogError("Trying to add Duplicate state: " + tstate.STATE_ID.ToString());
return;
}
}
states.Add(tstate);
}
开发者ID:kreeds,项目名称:TestProjectDemo,代码行数:29,代码来源:FiniteStateMachine.cs
示例9: AddState
public void AddState(FSMState s)
{
if(s==null)
{
Debug.LogError("FSM ERROR:添加的状态不允许为空");
return;
}
//第一次添加状态的时候完成初始化
if(states.Count==0)
{
states.Add(s);
s.StateChange+=StateChange;
CurrentState=s;
CurrentStateID=s.ID;
return;
}
foreach(FSMState state in states)
{
if(state.ID==s.ID)
{
Debug.LogError("FSM ERROR:不能向状态机里面重复添加相同的状态");
return;
}
}
states.Add (s);
s.StateChange += StateChange;
}
开发者ID:GeorgeDon,项目名称:MyPrivate,代码行数:27,代码来源:FSMsystem.cs
示例10: AddFSMState
public void AddFSMState(FSMState fsmState)
{
if(fsmState != null)
{
if(fsmStates.Count == 0)
{
fsmStates.Add(fsmState);
currentState = fsmState;
currentStateId = fsmState.ID;
}
else
{
foreach(FSMState state in fsmStates)
{
if(state.ID == fsmState.ID)
{
Debug.LogWarning("The FSM State was already in the list");
return;
}
}
fsmStates.Add(fsmState);
}
}
else
{
Debug.LogError("The FSM State is null");
}
}
开发者ID:jberg03,项目名称:GSP494-Team-A,代码行数:28,代码来源:AdvancedFSM.cs
示例11: AddState
/// <summary>
/// This method places new states inside the FSM,
/// or prints an ERROR message if the state was already inside the List.
/// First state added is also the initial state.
/// </summary>
public void AddState(FSMState s)
{
// Check for Null reference before deleting
if (s == null)
{
Debug.LogError("FSM ERROR: Null reference is not allowed");
}
// First State inserted is also the Initial state,
// the state the machine is in when the simulation begins
if (states.Count == 0)
{
states.Add(s);
currentState = s;
currentStateID = s.ID;
return;
}
// Add the state to the List if it's not inside it
foreach (FSMState state in states)
{
if (state.ID == s.ID)
{
Debug.LogError("FSM ERROR: Impossible to add state " + s.ID.ToString() +
" because state has already been added");
return;
}
}
states.Add(s);
}
开发者ID:garyfitz82,项目名称:Crash-of-the-Titans,代码行数:35,代码来源:FSMSystem.cs
示例12: ChangeState
public void ChangeState(FSMTransition stateTransition) {
Enum nextStateId = stateTransition.NextStateId;
FSMState prevState = CurrentState;
if(nextStateId == null) {
CurrentState = _stateStack.Pop();
} else {
FSMState nextState = GetState(nextStateId);
if(nextState == null)
throw new Exception("State " + nextStateId.ToString() + " has not been defined.");
if(stateTransition.PushCurrentState)
_stateStack.Push(CurrentState);
CurrentState = nextState;
CurrentState.InitState(stateTransition);
}
Debug.Log("Changed state to: " + CurrentState.StateId.ToString());
CurrentState.EnterState(stateTransition);
if(prevState != null && !stateTransition.PushCurrentState)
prevState.Dispose();
}
开发者ID:jtuttle,项目名称:ritual,代码行数:28,代码来源:FiniteStateMachine.cs
示例13: UpdateFSMMachine
public void UpdateFSMMachine(float fDelta)
{
if (this.allFSMStates.Count != 0)
{
if (this.currentFSMState == null)
{
this.currentFSMState = this.GetFSMState(this.defaultStateId);
if(this.currentFSMState != null)
{
this.currentFSMState.Enter();
}
}
if (this.currentFSMState != null)
{
StateID stateId = this.currentFSMState.GetStateId();
StateID transitionStateId = this.currentFSMState.CheckTransitions();
if (transitionStateId != stateId)
{
FSMState fsmState = this.GetFSMState(transitionStateId);
if (fsmState != null)
{
this.currentFSMState.Exit();
this.currentFSMState = fsmState;
this.currentFSMState.Enter();
}
}
this.currentFSMState.Update(fDelta);
}
}
}
开发者ID:moto2002,项目名称:unityLab,代码行数:30,代码来源:FSMMachine.cs
示例14: AddToQueue
public void AddToQueue(FSMState state)
{
if (state)
{
m_StateQueue.Enqueue(state);
}
}
开发者ID:Ankk4,项目名称:highlyresponsive-forever,代码行数:7,代码来源:FSM.cs
示例15: AddFSMState
/// <summary>
/// Add New State into the list
/// </summary>
public void AddFSMState(FSMState fsmState)
{
// Check for Null reference before deleting
if (fsmState == null)
{
Debug.LogError("FSM ERROR: Null reference is not allowed");
}
// First State inserted is also the Initial state
// the state the machine is in when the simulation begins
if (fsmStates.Count == 0)
{
fsmStates.Add(fsmState);
currentState = fsmState;
currentStateID = fsmState.ID;
return;
}
// Add the state to the List if it´s not inside it
foreach (FSMState state in fsmStates)
{
if (state.ID == fsmState.ID)
{
Debug.LogError("FSM ERROR: Trying to add a state that was already inside the list");
return;
}
}
//If no state in the current then add the state to the list
fsmStates.Add(fsmState);
}
开发者ID:giorgimode,项目名称:Space-Wars-Unity3D,代码行数:34,代码来源:AdvancedFSM.cs
示例16: AddState
public void AddState(FSMState state)
{
if(HasState(state.StateId))
throw new Exception("State " + state.StateId.ToString() + " is already defined.");
_states.Add(state);
}
开发者ID:jtuttle,项目名称:umbra-client,代码行数:7,代码来源:FiniteStateMachine.cs
示例17: UpdateStateMachine
public void UpdateStateMachine()
{
StateID nextStateID = stateDictionary[stateMachine.GetCurrentAnimatorStateInfo(0).fullPathHash];
if (nextStateID != currentStateID) //If state has changed
{
currentStateID = nextStateID;
foreach (FSMState state in states) //Get state
{
if (state.GetStateID() == currentStateID)
{
if (currentState != null)
{
currentState.ResetState();
}
currentState = state;
break;
}
}
}
if (currentState != null)
{
currentState.UpdateState(); //update current state
}
}
开发者ID:Broghain,项目名称:GTO7,代码行数:25,代码来源:FiniteStateMachine.cs
示例18: initializeDefStates
public void initializeDefStates()
{
//should this be hardcoded?
FSMState fall = new FSMState(PlayerStates.FALLING);
fall.addTransition(PlayerActions.LAND,PlayerStates.STANDING);
fsmStates.Add(fall);
FSMState stand = new FSMState(PlayerStates.STANDING);
stand.addTransition(PlayerActions.WALK_INPUT,PlayerStates.WALKING);
stand.addTransition(PlayerActions.RUN_INPUT,PlayerStates.RUNNING);
stand.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING);
fsmStates.Add(stand);
FSMState walk = new FSMState(PlayerStates.WALKING);
walk.addTransition(PlayerActions.RUN_INPUT,PlayerStates.RUNNING);
walk.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING);
walk.addTransition(PlayerActions.STOP,PlayerStates.STANDING);
walk.addTransition(PlayerActions.FALL,PlayerStates.FALLING);
fsmStates.Add(walk);
FSMState run = new FSMState(PlayerStates.RUNNING);
run.addTransition(PlayerActions.WALK_INPUT,PlayerStates.WALKING);
run.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING);
run.addTransition(PlayerActions.STOP,PlayerStates.STANDING);
run.addTransition(PlayerActions.FALL,PlayerStates.FALLING);
fsmStates.Add(run);
FSMState jump = new FSMState(PlayerStates.JUMPING);
jump.addTransition(PlayerActions.FALL,PlayerStates.FALLING);
jump.addTransition(PlayerActions.JUMP_INPUT,PlayerStates.JUMPING);
fsmStates.Add(jump);
}
开发者ID:OscarRPR,项目名称:SR_PC,代码行数:32,代码来源:PlayerFSM.cs
示例19: RemoveState
public void RemoveState(FSMState item)
{
this.DeleteState (item.ID);
foreach(FSMState state in fsmStates)
{
state.DeleteTransition(item.RequiredTransition);
}
}
开发者ID:jberg03,项目名称:GSP494-Team-A,代码行数:8,代码来源:EnemyController.cs
示例20: AddState
public void AddState( string name, FSMState.UpdateDelegate updateDelegate = null )
{
_states.Add( name, new FSMState( name, updateDelegate ) );
if ( _states.Count == 1 )
{
_currentState = _states[name];
}
}
开发者ID:phoenixtail26,项目名称:Platformer,代码行数:8,代码来源:FSM.cs
注:本文中的FSMState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论