• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StateID类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中StateID的典型用法代码示例。如果您正苦于以下问题:C# StateID类的具体用法?C# StateID怎么用?C# StateID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StateID类属于命名空间,在下文中一共展示了StateID类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: AddTransition

 public void AddTransition(Transition newTransition, StateID newId)
 {
     if (map.ContainsKey (newTransition))
     {
         Debug.LogError("Error: Transition " + newTransition + " already in map.");
         return;
     }
     map.Add (newTransition, newId);
     Debug.Log ("Added transition: " + newTransition);
 }
开发者ID:Greg-Rus,项目名称:Game,代码行数:10,代码来源:S_FSM_Framework.cs


示例17: AddTransition

 /// <summary>
 /// Adds a transition with the corresponding state.
 /// </summary>
 /// <param name="transition">Transition</param>
 /// <param name="id">State</param>
 public void AddTransition(Transition transition, StateID id)
 {
     // Check if the params are invalid, if valid --> add Transition to the map.
     if (transition == Transition.NullTransition)
         Debug.LogError("FSMState: NullTransition!");
     else if (id == StateID.NullStateID)
         Debug.LogError("FSMState: NullStateID!");
     else if (map.ContainsKey(transition))
         Debug.LogError("FSMState: State " + stateID.ToString() + " already has transition " + transition.ToString() + "!");
     else
         map.Add(transition, id);
 }
开发者ID:Parzival42,项目名称:Bread,代码行数:17,代码来源:FSMState.cs


示例18: GetFSMState

 public FSMState GetFSMState(StateID stateId)
 {
     int numFSMStates = allFSMStates.Count;
     for(int i = 0; i < numFSMStates; ++i)
     {
         FSMState fsmState = allFSMStates[i];
         if (fsmState != null && fsmState.GetStateId() == stateId)
         {
             return fsmState;
         }
     }
     return null;
 }
开发者ID:moto2002,项目名称:unityLab,代码行数:13,代码来源:FSMMachine.cs


示例19: State

        /// <summary>
        /// Class constructor.
        /// <param name="id">State identifier</param>
        /// </summary>
        protected State(StateID id)
        {
            //Set identifier
            m_ID = id;

            //Set default value
            m_Active		= true;
            m_PopUp			= false;
            m_VisibleCursor = false;

            //Create layers
            m_Layer = SpriteManager.AddLayer();
            m_Panel = new List<Control>();
        }
开发者ID:yggy123,项目名称:closed-sky,代码行数:18,代码来源:State.cs


示例20: ChangeState

    public override void ChangeState(StateID stateID)
    {
        // Cambio la animacion
        ChangeAnimation(stateID == StateID.Stop ? StateID.Forward : stateID);

        // Paro el sonido anterior
        Sounds[(int)CurrentState.ID].Stop();

        // Cambio el estado
        base.ChangeState(stateID);

        // Cambio el sonido en reproduccion
        Sounds[(int)CurrentState.ID].Play();
    }
开发者ID:jennydvr,项目名称:SimpleRunner,代码行数:14,代码来源:PlayerManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StateMachine类代码示例发布时间:2022-05-24
下一篇:
C# StateFlags类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap