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


C# FSM.AddTransition方法代码示例

本文整理汇总了C#中FSM.AddTransition方法的典型用法代码示例。如果您正苦于以下问题:C# FSM.AddTransition方法的具体用法?C# FSM.AddTransition怎么用?C# FSM.AddTransition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FSM的用法示例。


在下文中一共展示了FSM.AddTransition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldEvaluateMultipleTransitionsUntilConditionIsMet

        public void ShouldEvaluateMultipleTransitionsUntilConditionIsMet()
        {
            var fsm = new FSM<string>();
            fsm.AddState("one");
            fsm.AddState("two");
            fsm.AddState("three");
            fsm.AddTransition("one", "two", input => false);
            fsm.AddTransition("one", "three", input => true);

            fsm.Step();

            Assert.That(fsm.CurrentState, Is.EqualTo("three"));
        }
开发者ID:neochrome,项目名称:Hatchery,代码行数:13,代码来源:FSMTests.cs

示例2: Form1

 public Form1()
 {
     InitializeComponent();
     phase_label.Text = GameState.init.ToString();
     attack.Enabled = false;
     enemy_attack.Enabled = false;
     GAMEFSM = new FSM<GameState>(GameState.init);
     GAMEFSM.AddState(GameState.init);
     GAMEFSM.AddState(GameState.player);
     GAMEFSM.AddState(GameState.enemy);
     GAMEFSM.AddState(GameState.end);
     GAMEFSM.AddTransition(GameState.init, GameState.player);
     GAMEFSM.AddTransition(GameState.player, GameState.enemy);
     GAMEFSM.AddTransition(GameState.enemy, GameState.player);
     GAMEFSM.AddTransition(GameState.player, GameState.end);
     GAMEFSM.AddTransition(GameState.enemy, GameState.end);
     SuperSave = new SaveGameData();
 }
开发者ID:guygoudeau,项目名称:Homework,代码行数:18,代码来源:Form1.cs

示例3: ShouldExecuteOnExitWhenLeavingCurrentState

        public void ShouldExecuteOnExitWhenLeavingCurrentState()
        {
            var was_here = false;
            var fsm = new FSM<string>();
            fsm.AddState("start_here", null, input => was_here = true);
            fsm.AddState("exit_here");
            fsm.AddTransition("start_here", "exit_here", input => true);

            fsm.Step();

            Assert.That(was_here, Is.True);
        }
开发者ID:neochrome,项目名称:Hatchery,代码行数:12,代码来源:FSMTests.cs

示例4: ShouldExecuteOnEnterWhenEnteringNextState

        public void ShouldExecuteOnEnterWhenEnteringNextState()
        {
            var exit_here = false;
            var fsm = new FSM<string>();
            fsm.AddState("start_here");
            fsm.AddState("exit_here", input => exit_here = true);
            fsm.AddTransition("start_here", "exit_here", input => true);

            fsm.Step();

            Assert.That(exit_here, Is.True);
        }
开发者ID:neochrome,项目名称:Hatchery,代码行数:12,代码来源:FSMTests.cs

示例5: ShouldEvaluateTransitionCondition

        public void ShouldEvaluateTransitionCondition()
        {
            var conditionEvaluated = false;
            var fsm = new FSM<string>();
            fsm.AddState("initial");
            fsm.AddState("end");
            fsm.AddTransition("initial", "end", input => { conditionEvaluated = true; return false; });

            fsm.Step();

            Assert.That(conditionEvaluated, Is.True);
        }
开发者ID:neochrome,项目名称:Hatchery,代码行数:12,代码来源:FSMTests.cs

示例6: Start

    void Start()
    {
        _health = _maxHealth;

        _fsm = new FSM<UnitStates>();
        // Add States for the FSM
        _fsm.AddState(UnitStates.INIT);
        _fsm.AddState(UnitStates.IDLE);
        _fsm.AddState(UnitStates.ATTACK);
        _fsm.AddState(UnitStates.HIT);
        _fsm.AddState(UnitStates.DEAD);
        // Add transistion for the FSM
        _fsm.AddTransition(UnitStates.INIT, UnitStates.IDLE);
        _fsm.AddTransition(UnitStates.IDLE, UnitStates.ATTACK);
        _fsm.AddTransition(UnitStates.ATTACK, UnitStates.IDLE);
        _fsm.AddTransition(UnitStates.IDLE, UnitStates.HIT);
        _fsm.AddTransition(UnitStates.HIT, UnitStates.IDLE);
        _fsm.AddTransition(UnitStates.HIT, UnitStates.DEAD);

        _fsm.Transition(_fsm.state, UnitStates.IDLE);
    }
开发者ID:Zac-King,项目名称:CombatRPG,代码行数:21,代码来源:Player.cs

示例7: ShouldFollowTransitionIfConditionIsMet

        public void ShouldFollowTransitionIfConditionIsMet()
        {
            var fsm = new FSM<string>();
            fsm.AddState("start");
            fsm.AddState("exit");
            fsm.AddTransition("start", "exit", input => true);

            fsm.Step();

            Assert.That(fsm.CurrentState, Is.EqualTo("exit"));
        }
开发者ID:neochrome,项目名称:Hatchery,代码行数:11,代码来源:FSMTests.cs

示例8: ShouldExecuteTransitionAction

        public void ShouldExecuteTransitionAction()
        {
            var action = false;
            var fsm = new FSM<string>();
            fsm.AddState("first");
            fsm.AddState("second");
            fsm.AddTransition("first", "second", input => true, input => action = true);

            fsm.Step();

            Assert.That(action, Is.True);
        }
开发者ID:neochrome,项目名称:Hatchery,代码行数:12,代码来源:FSMTests.cs

示例9: ShouldNotBeFinishedWhenCurrentHasTransitions

 public void ShouldNotBeFinishedWhenCurrentHasTransitions()
 {
     var fsm = new FSM<string>();
     fsm.AddState("one");
     fsm.AddState("two");
     fsm.AddTransition("one", "two", input => true);
     Assert.That(fsm.Finished, Is.False);
 }
开发者ID:neochrome,项目名称:Hatchery,代码行数:8,代码来源:FSMTests.cs


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