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

C# FiniteStateMachine类代码示例

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

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



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

示例1: Awake

    void Awake()
    {
        mainFSM = new FiniteStateMachine<State>();
        mainFSM.AddTransition(State.Initialize, State.SetupNewGame, null, InitializeNewGame, OnSettingUpNewGame);
        mainFSM.AddTransition(State.SetupNewGame, State.Game, null, () => StartCoroutine(InitializeGameLogicStuff()), null);
        mainFSM.AddTransition(State.Game, State.GameOver, OnGameIsOver);
        mainFSM.AddTransition(State.GameOver, State.Restart, null);
        mainFSM.AddTransition(State.Restart, State.SetupNewGame, null, InitializeNewGame, null);
        mainFSM.AddTransition(State.Restart, State.Quit, null);
        mainFSM.StateChanged += (object s, EventArgs e) => {
            Debug.Log("state: " + mainFSM.CurrentState.ToString() + " | game state: " + gameFSM.CurrentState.ToString());
        };

        gameFSM = new FiniteStateMachine<GameState>();
        gameFSM.AddTransition(GameState.Idle, GameState.InGameMenu, OnInGameMenuOpened);
        gameFSM.AddTransition(GameState.InGameMenu, GameState.Idle, OnInGameMenuClosed);
        gameFSM.StateChanged += (object s, EventArgs e) => {
            Debug.Log("state: " + mainFSM.CurrentState.ToString() + " | game state: " + gameFSM.CurrentState.ToString());
        };

        GameIsOver += (object s, EventArgs e) => { Debug.Log("oh no!"); };
        InGameMenuOpened += (object s, EventArgs e) => { Time.timeScale = 0f; Debug.Log("PAUSED"); };
        InGameMenuClosed += (object s, EventArgs e) => { Time.timeScale = 1f; Debug.Log("UNPAUSED"); };

        igm = GetComponent<InGameMenu>();
        mainFSM.ChangeState(State.SetupNewGame);
    }
开发者ID:rafedb,项目名称:fsm_framework,代码行数:27,代码来源:GameManager.cs


示例2: Input_handles_value_types

 public void Input_handles_value_types()
 {
     var machine = new FiniteStateMachine<string, int>();
     machine.CurrentState = "Start";
     machine.Transitions.Add( new StateTransition<string, int>{InputValidator = i => i.Equals(0), FromState = "Start", ToState = "End"} );
     machine.Input(0);
 }
开发者ID:DavidMoore,项目名称:Foundation,代码行数:7,代码来源:FiniteStateMachineTests.cs


示例3: CooldownBehaviour

 public CooldownBehaviour(GameObject gameObject, FiniteStateMachine fsm, string variableName, float cooldown)
     : base(gameObject)
 {
     this.fsm = fsm;
       this.variableName = variableName;
       this.cooldown = cooldown;
 }
开发者ID:BrunoRomes,项目名称:UnityTests,代码行数:7,代码来源:CooldownBehaviour.cs


示例4: GenerateStateMachine

        public static FiniteStateMachine GenerateStateMachine(string id, int states, double transitionsPerState, double endStateProbability)
        {
            var fsm = new FiniteStateMachine();
            var rand = new Random();
            fsm.Id = id;

            for (int i = 0; i < states; i++)
            {
                var state = new State();
                state.Name = "q" + i.ToString();
                state.IsEndState = rand.NextDouble() < endStateProbability;
                fsm.States.Add(state);
            }

            var transitions = (int)Math.Floor(states * transitionsPerState + 0.5);
            for (int i = 0; i < transitions; i++)
            {
                State start;
                State end;
                string input;
                do
                {
                    start = fsm.States[rand.Next(fsm.States.Count)];
                    end = fsm.States[rand.Next(fsm.States.Count)];
                    input = __inputs[rand.Next(__inputs.Length)];
                } while (start.Transitions.Any(t => t.Input == input));
                var transition = new Transition();
                transition.StartState = start;
                transition.EndState = end;
                transition.Input = input;
                fsm.Transitions.Add(transition);
            }

            return fsm;
        }
开发者ID:NMFCode,项目名称:SynchronizationsBenchmark,代码行数:35,代码来源:StateMachineGenerator.cs


示例5: Generator

 public Generator()
 {
     mFSM = new FiniteStateMachine(Signals[0], () => Random());
     mFSM.addState(Signals[1], () => Sine());
     mFSM.addState(Signals[2], () => Square());
     mFSM.addState(Signals[3], () => Sawtooth());
 }
开发者ID:yuriik83,项目名称:Process-Simulator-2-OpenSource,代码行数:7,代码来源:Generator.cs


示例6: RangeState

 public RangeState(FiniteStateMachine fsm)
     : base(fsm)
 {
     _attack = fsm.GetComponent<KRAttack>();
     _krtransform = fsm.GetComponent<KRTransform>();
     _krmovement = fsm.GetComponent<KRMovement>();
 }
开发者ID:HyroVitalyProtago,项目名称:KingdomsRebellion,代码行数:7,代码来源:RangeState.cs


示例7: Valve

 public Valve()
 {
     mFSM = new FiniteStateMachine("Stoped", () => ValveStoped());
     mFSM.addState("Opens", () => ValveOpens());
     mFSM.addState("Closes", () => ValveCloses());
     mFSM.addState("Esd", () => ValveEsd());
 }
开发者ID:yuriik83,项目名称:Process-Simulator-2-OpenSource,代码行数:7,代码来源:Valve.cs


示例8: TestNonSignificantTurnNonPoi

 /// <summary>
 /// Tests if the given turn is significant.
 /// </summary>
 /// <param name="test"></param>
 /// <param name="machine"></param>
 /// <returns></returns>
 private static bool TestNonSignificantTurnNonPoi(FiniteStateMachine<MicroPlannerMessage> machine, object test)
 {
     if (!PoiWithTurnMachine.TestPoi(machine, test))
     {
         if (test is MicroPlannerMessagePoint)
         {
             MicroPlannerMessagePoint point = (test as MicroPlannerMessagePoint);
             if (point.Point.Angle != null)
             {
                 if (point.Point.ArcsNotTaken == null || point.Point.ArcsNotTaken.Count == 0)
                 {
                     return true;
                 }
                 switch (point.Point.Angle.Direction)
                 {
                     case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.StraightOn:
                     case RelativeDirectionEnum.SlightlyLeft:
                     case RelativeDirectionEnum.SlightlyRight:
                         return true;
                 }
             }
         }
         return false;
     }
     return false;
 }
开发者ID:cmberryau,项目名称:routing,代码行数:32,代码来源:PoiWithTurnMachine.cs


示例9: TestNonSignificantTurn

 /// <summary>
 /// Tests if the given turn is significant.
 /// </summary>
 /// <param name="machine"></param>
 /// <param name="test"></param>
 /// <returns></returns>
 private static bool TestNonSignificantTurn(FiniteStateMachine<MicroPlannerMessage> machine, object test)
 {
     if (!TurnMachine.TestSignificantTurn(machine, test))
     { // it is no signficant turn.
         return true;
     }
     return false;
 }
开发者ID:cmberryau,项目名称:routing,代码行数:14,代码来源:TurnMachine.cs


示例10: InitFSM

 private void InitFSM()
 {
     this.FSM = new FiniteStateMachine<BossEntity>(this)
         .Add(new BossPatrolState())
         .Add(new BossPlayerShootState())
         .Add(new BossCircleShootState())
         .Add(new BossSprayShootState());
 }
开发者ID:Caresilabs,项目名称:MAH_Artificial_Intelligence,代码行数:8,代码来源:BossEntity.cs


示例11: Awake

    protected void Awake()
    {
        _fsm = new FiniteStateMachine();

        _fsm.AddState(new MonsterWanderState(gameObject));

        _fsm.ChangeState(new FSMTransition(MonsterState.Wander));
    }
开发者ID:jtuttle,项目名称:umbra-client,代码行数:8,代码来源:MonsterAI.cs


示例12: Perform

 public override void Perform(FiniteStateMachine fsm)
 {
     TransitionIndex = Math.Min(TransitionIndex, fsm.Transitions.Count - 1);
     var t = fsm.Transitions[TransitionIndex];
     t.StartState = null;
     t.EndState = null;
     fsm.Transitions.RemoveAt(TransitionIndex);
 }
开发者ID:NMFCode,项目名称:SynchronizationsBenchmark,代码行数:8,代码来源:RemoveTransitionAction.cs


示例13: Start

	// Use this for initialization
	private void Start() {
		State stateOne = new State("There was a dark cell. Press C to go to the corner");
		State stateTwo = new State("There was a dark corner of a dark cell. Press B to go to go back");
		stateOne.nextStates.Add(KeyCode.C, stateTwo);
		stateTwo.nextStates.Add(KeyCode.B, stateOne);
		stateMachine = new FiniteStateMachine(stateOne);
		stateMachine.states.Add(stateTwo);
		text.text = stateMachine.currentState.description;
	}
开发者ID:polygonica,项目名称:UdemyUnityTutorials,代码行数:10,代码来源:TextControllerScript.cs


示例14: Start

 // Use this for initialization
 void Start()
 {
     stateMachine = GetComponent<FiniteStateMachine>();
     stateMachine.InitializeStateMachine();
     stateMachine.AddState(new BomberReachedScreenEdge(this.transform));
     stateMachine.AddState(new BomberAttackingPlayer(this.transform, GameManager.instance.GetPlayer()));
     stateMachine.AddState(new BomberMovingToPosition(this.transform));
     stateMachine.AddState(new BomberDead(this.transform));
 }
开发者ID:Broghain,项目名称:GTO7,代码行数:10,代码来源:BomberController.cs


示例15: Initialize

    protected void Initialize()
    {
        StateBathroom = GetComponentInChildren(typeof(BathroomState)) as BathroomState;
        StateKitchen = GetComponentInChildren(typeof(KitchenState)) as KitchenState;
        StateBedroom = GetComponentInChildren(typeof(BedroomState)) as BedroomState;
        StateCloset = GetComponentInChildren(typeof(ClosetState)) as ClosetState;

        FSM = new FiniteStateMachine<MovingVoice>(this);
    }
开发者ID:JungleJinn,项目名称:exile-metalgearcloset,代码行数:9,代码来源:MovingVoice.cs


示例16: TestVeryShortArc

 /// <summary>
 /// Returns true if the given test object is a very short arc!
 /// </summary>
 /// <param name="test"></param>
 /// <param name="machine"></param>
 /// <returns></returns>
 private static bool TestVeryShortArc(FiniteStateMachine<MicroPlannerMessage> machine, object test)
 {
     if (test is MicroPlannerMessageArc)
     {
         MicroPlannerMessageArc arc = (test as MicroPlannerMessageArc);
         return arc.Arc.Distance.Value < 20;
     }
     return false;
 }
开发者ID:cmberryau,项目名称:routing,代码行数:15,代码来源:ImmidiateTurnMachine.cs


示例17: Init

    public void Init()
    {
        initialPosition = body.transform.position;

        accessibilityStateMachine = gameObject.AddComponent<FiniteStateMachine>();
        stateMachine = gameObject.AddComponent<FiniteStateMachine>();

        accessibilityStateMachine.currentState = new DoorIsLockedState(this);
        stateMachine.currentState = new DoorIsClosedState(this);
    }
开发者ID:hassank,项目名称:WendyWebVR,代码行数:10,代码来源:Door.cs


示例18: Monster

        public Monster()
        {
            random = new Random();

            components.Add(timerWrapper = new TimerWrapper());
            timerWrapper.AutoCreateTimers = true;

            components.Add(brain = new FiniteStateMachine());
            components.Add(targetComponent = new TargetingComponent<Player>(this));
        }
开发者ID:Jntz,项目名称:jamipeli,代码行数:10,代码来源:Monster.cs


示例19: Awake

    protected void Awake()
    {
        _fsm = new FiniteStateMachine();

        _fsm.AddState(new HeroSeekState(gameObject));
        _fsm.AddState(new HeroWalkState(gameObject));
        _fsm.AddState(new HeroWaitState(gameObject));

        //_fsm.ChangeState(new FSMTransition(HeroState.Seek));
    }
开发者ID:jtuttle,项目名称:umbra-client,代码行数:10,代码来源:HeroAI.cs


示例20: Start

 // Use this for initialization
 void Start()
 {
     stateMachine = GetComponent<FiniteStateMachine>();
     stateMachine.InitializeStateMachine();
     stateMachine.AddState(new GunnerReachedScreenEdge(this.transform));
     stateMachine.AddState(new GunnerAttackingPlayer(this.transform));
     stateMachine.AddState(new GunnerMovingToPosition(this.transform));
     stateMachine.AddState(new GunnerInFormation(this.transform));
     stateMachine.AddState(new GunnerDead(this.transform));
 }
开发者ID:Broghain,项目名称:GTO7,代码行数:11,代码来源:GunnerController.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# FirstFloor类代码示例发布时间:2022-05-24
下一篇:
C# Fingerprint类代码示例发布时间: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