本文整理汇总了C#中StateID类的典型用法代码示例。如果您正苦于以下问题:C# StateID类的具体用法?C# StateID怎么用?C# StateID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StateID类属于命名空间,在下文中一共展示了StateID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTransition
// Add Transition
public void AddTransition(Transition trans, StateID id)
{
//check if transition exist
if(trans == Transition.NULL)
{
Debug.LogError("Trying to add a null transition");
return;
}
if(id == StateID.NULL)
{
Debug.LogError("Trying to add a null state");
return;
}
if(trans == Transition.E_NOHP)
{
Debug.Log("trans: " + trans.ToString() + " StateID: " + id.ToString());
}
// check if current map already contains key
if(map.ContainsKey(trans))
{
Debug.LogError(trans.ToString() + " transition Exist, unable to have duplicate transitions for State: " + id.ToString());
return;
}
map.Add(trans, id);
Debug.Log("Sucessfully added: " + trans.ToString() + " id extract: " + map[trans] + " Current StateID: " + STATE_ID.ToString());
}
示例2: 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;
}
示例3: AddState
public void AddState(NPCState newState)
{
if (newState == null)
{
Debug.LogError("StateManager AddState(): Null state");
}
if (states.Count == 0)
{
states.Add(newState);
currentState = newState;
currentStateID = newState.ID;
return;
}
foreach (NPCState state in states)
{
if (state.ID == newState.ID)
{
Debug.LogError("StateManager AddState(): " + newState.ID.ToString() + " already exists");
return;
}
}
states.Add(newState);
}
示例4: 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);
}
示例5: 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);
}
示例6: AddTransition
public void AddTransition(Transition trans, StateID id)
{
// Check if anyone of the args is invalid
if (trans == Transition.NullTransition)
{
Debug.LogError("FSMState ERROR: NullTransition is not allowed for a real transition");
return;
}
if (id == StateID.NullStateID)
{
Debug.LogError("FSMState ERROR: NullStateID is not allowed for a real ID");
return;
}
// Since this is a Deterministic FSM,
// check if the current transition was already inside the map
if (map.ContainsKey(trans))
{
Debug.LogError("FSMState ERROR: State " + stateID.ToString() + " already has transition " + trans.ToString() +
"Impossible to assign to another state");
return;
}
map.Add(trans, id);
}
示例7: AddTransition
public void AddTransition(Transition trans, StateID id)
{
//first step of the fsm
//check the args and see if they are invalid
if (trans == Transition.NullTransition) {
Debug.LogError("FSM had a pretty bad error. Null transition is not allowed for a real tranisition. \n You have a shit ton of work david");
return;
}
if (id == StateID.NullStateID) {
Debug.LogError("FSM had a pretty bad error. Null STATE id is not allowed for a real ID");
return;
}
// deterministic FSM
// check if current transition was already inside the map
if (map.ContainsKey(trans)) {
// fuck, if this hits ive hit a transition that already has a transition
// Enum enumerations = RuntimeTypeHandle.ReferenceEquals(StateID);
Debug.LogError("FSM had a pretty bad error" + stateID.ToString() + " Already has a transition"
+trans.ToString() + " Impossible to assign to another state");
return;
}
map.Add(trans, id);
}
示例8: EnemyRandomWalk
public EnemyRandomWalk(StateID stateID, NPCBreadcrumb enemyReference)
{
this.stateID = stateID;
this.enemyReference = enemyReference;
NPCBreadcrumb.FoundPlayer += FoundPlayer;
}
示例9: 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);
}
}
示例10: 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);
}
示例11: createState
private State createState(StateID stateID)
{
//StateConstructor found = mFactories[stateID];
//State state = found();
State state = null;
try
{
switch (stateID)
{
case StateID.Menu:
state = new MenuState(this, mContext);
break;
case StateID.Title:
state = new TitleState(this, mContext);
break;
case StateID.Game:
state = new GameState(this, mContext);
break;
case StateID.Pause:
state = new PauseState(this, mContext);
break;
case StateID.Setting:
state = new SettingState(this, mContext);
break;
}
}
catch (Exception e)
{
Console.WriteLine(e.Message + " In state creation");
}
return state;
}
示例12: 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
}
}
示例13: StateTransition
public StateTransition(TransitionID transitionID, StateID nextStateID)
{
this.TransitionID = transitionID;
this.NextStateID = nextStateID;
this.EventsRunning = false;
RemoveAllEvents();
}
示例14: SetState
public void SetState(StateID stateID)
{
if(!states.ContainsKey(stateID))
return;
if(currentState != null)
currentState.Leave();
currentState = states[stateID];
currentState.Enter();
}
示例15: ChangeState
//Function to handle statemachine
public void ChangeState( State<EnemySniperScript> s )
{
if(s.GetType().Name == "Sniper_AttackPlayer"){
CurrentState = StateID.attacking;
}
if(s.GetType().Name == "Sniper_MoveToPlayer"){
CurrentState = StateID.moving;
}
StateMachine.ChangeState ( s );
}