当前位置: 首页>>代码示例>>C#>>正文


C# StateID类代码示例

本文整理汇总了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());
    }
开发者ID:kreeds,项目名称:TestProjectDemo,代码行数:31,代码来源:FSMState.cs

示例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;
 }
开发者ID:GeorgeDon,项目名称:MyPrivate,代码行数:27,代码来源:FSMsystem.cs

示例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);
    }
开发者ID:SabiKov,项目名称:HumanEvolution2,代码行数:25,代码来源:NPCStateManager.cs

示例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);
    }
开发者ID:garyfitz82,项目名称:Crash-of-the-Titans,代码行数:35,代码来源:FSMSystem.cs

示例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);
    }
开发者ID:kreeds,项目名称:TestProjectDemo,代码行数:29,代码来源:FiniteStateMachine.cs

示例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);
    }
开发者ID:kurainisei,项目名称:SpaceVehicle,代码行数:26,代码来源:FSMSystem.cs

示例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);
    }
开发者ID:daxaxelrod,项目名称:Loom-Vr,代码行数:29,代码来源:BankFiniteStateMachine.cs

示例8: EnemyRandomWalk

    public EnemyRandomWalk(StateID stateID, NPCBreadcrumb enemyReference)
    {
        this.stateID = stateID;
        this.enemyReference = enemyReference;

        NPCBreadcrumb.FoundPlayer += FoundPlayer;
    }
开发者ID:Parzival42,项目名称:Bread,代码行数:7,代码来源:EnemyRandomWalk.cs

示例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);
        }
    }
开发者ID:Parzival42,项目名称:Bread,代码行数:33,代码来源:FiniteStateMachine.cs

示例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);
    }
开发者ID:giorgimode,项目名称:Space-Wars-Unity3D,代码行数:34,代码来源:AdvancedFSM.cs

示例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;
 }
开发者ID:pixeltasim,项目名称:SFML.NET_Gamedev,代码行数:33,代码来源:StateStack.cs

示例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
        }
    }
开发者ID:Broghain,项目名称:GTO7,代码行数:25,代码来源:FiniteStateMachine.cs

示例13: StateTransition

        public StateTransition(TransitionID transitionID, StateID nextStateID)
        {
            this.TransitionID = transitionID;
            this.NextStateID = nextStateID;
            this.EventsRunning = false;

            RemoveAllEvents();
        }
开发者ID:MitchLindsay,项目名称:red-havoc,代码行数:8,代码来源:StateTransition.cs

示例14: SetState

 public void SetState(StateID stateID)
 {
     if(!states.ContainsKey(stateID))
         return;
     if(currentState != null)
         currentState.Leave();
     currentState = states[stateID];
     currentState.Enter();
 }
开发者ID:SkaterDanny,项目名称:3D-DreamTeam,代码行数:9,代码来源:StateMachine.cs

示例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 );
 }
开发者ID:jcollins2014,项目名称:Project,代码行数:11,代码来源:EnemySniperScript.cs


注:本文中的StateID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。