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

C# StateMachine类代码示例

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

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



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

示例1: Start

	// Use this for initialization
	void Start () {
		navAgent = GetComponent<NavMeshAgent> ();
		home = GameObject.Find ("Home");

		fsm = new StateMachine<GhostAI> (this);
		fsm.setState (new ScatterState ());
	}
开发者ID:Rarau,项目名称:AI_Lab,代码行数:8,代码来源:GhostAI.cs


示例2: InitialTransition

    public void InitialTransition()
    {
        //This is an odd request by a user, where they wanted to use methods declared in a super class. By default we expect this to fail, but we can enable this behaivour
        //by removing BindingFlags.DeclaredOnly from the reflection routine in StateMachine.cs

        fsm = engine.Initialize<States>(behaviour, States.One);
        fsm.ChangeState(States.Two);

        //Test for when we want to include superclass methods
        //Assert.AreEqual(1, behaviour.oneStats.enterCount);
        //Assert.AreEqual(0, behaviour.oneStats.updateCount);
        //Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
        //Assert.AreEqual(1, behaviour.oneStats.exitCount);
        //Assert.AreEqual(1, behaviour.oneStats.finallyCount);

        //Assert.AreEqual(1, behaviour.twoStats.enterCount);
        //Assert.AreEqual(0, behaviour.twoStats.updateCount);
        //Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
        //Assert.AreEqual(0, behaviour.twoStats.exitCount);
        //Assert.AreEqual(0, behaviour.twoStats.finallyCount);

        //Test for no superclass methods
        Assert.AreEqual(0, behaviour.oneStats.enterCount);
        Assert.AreEqual(0, behaviour.oneStats.updateCount);
        Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
        Assert.AreEqual(0, behaviour.oneStats.exitCount);
        Assert.AreEqual(0, behaviour.oneStats.finallyCount);

        Assert.AreEqual(0, behaviour.twoStats.enterCount);
        Assert.AreEqual(0, behaviour.twoStats.updateCount);
        Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
        Assert.AreEqual(0, behaviour.twoStats.exitCount);
        Assert.AreEqual(0, behaviour.twoStats.finallyCount);
    }
开发者ID:thefuntastic,项目名称:Unity3d-Finite-State-Machine,代码行数:34,代码来源:TestDerivedFromSuperClass.cs


示例3: AssignAnimationToCharacter

    /// <summary>
    /// Assigns the animation to the character.
    /// </summary>
    static void AssignAnimationToCharacter(AnimationClip clip, GameObject character)
    {
        //create a new controller
        UnityEditorInternal.AnimatorController my_controller = new UnityEditorInternal.AnimatorController();
        my_controller.name = "generic_controller";

        //check if the animator component is already attached to the character
        if (character.GetComponent<Animator>() == null)
            character.AddComponent<Animator>();

        //create the state machine with the animation clip
        StateMachine sm = new StateMachine();
        sm.AddState("default_state");
        sm.GetState(0).SetMotion(0, clip);

        //check if the controller already has a based layer
        if (my_controller.GetLayerCount() == 0)
            my_controller.AddLayer("Base Layer");
        //set the state machine
        my_controller.SetLayerStateMachine(0, sm);

        //assign the controller
        Animator animator = (Animator)character.GetComponent<Animator>();
        UnityEditorInternal.AnimatorController.SetAnimatorController(animator,my_controller);
    }
开发者ID:noa99kee,项目名称:character-model-detection,代码行数:28,代码来源:ScreenCapture.cs


示例4: Start

    protected override void Start()
    {
        base.Start();//gets the start from living entity
        startingHealth += startingHealth/100*waveStats._percentHP;
        health = startingHealth;
        print(health + "hp");
        /** we halen een referentie op naar de state machine */
        stateMachine = GetComponent<StateMachine>();
        //anim.GetComponent<Animator>();
        /** we voegen de verschillende states toe aan de state machine */
		MakeStates();

        /** we geven de eerste state door (rondlopen) */
        if (patrol)
        {
            stateMachine.SetState(StateID.Patrol);
        }
        else if(charge)
        {
            stateMachine.SetState(StateID.Charge);
        }
        else
        {
            stateMachine.SetState(StateID.Wandering);
        }

    }
开发者ID:DavidZwit,项目名称:MytheDAG2016,代码行数:27,代码来源:Guard.cs


示例5: Start

 // Use this for initialization
 void Start ()
 {
     GoToMiddleOfTile();
     speed_max = 3;
     state_machine = new StateMachine();
     state_machine.ChangeState(new StateKeeseNormal(this, GetComponent<SpriteRenderer>(), flap));
 }
开发者ID:ConnorUllmann,项目名称:EECS494_Proj1,代码行数:8,代码来源:Keese.cs


示例6: OnEnable

		public override void OnEnable() {
			base.OnEnable();
			
			stateMachine = (StateMachine)target;
			stateMachineObject = stateMachine.gameObject;
			HideLayersAndStates();
		}
开发者ID:Kartoshka,项目名称:Crabby-Pulse-2,代码行数:7,代码来源:StateMachineEditor.cs


示例7: ShowWithTarget

 public static void ShowWithTarget(StateMachine target) {
     var editor = GetWindow<StateMachineEditor>();
     editor.machine = target;
     editor.stateSelected = null;
     editor.transitionSelected = null;
     editor.Show();
 }
开发者ID:GregWeil,项目名称:ResearchProjectGSAS,代码行数:7,代码来源:StateMachineEditor.cs


示例8: Run

		public static void Run () {
			var model = new StateMachine<Instance>("history");

			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var shallow = new State<Instance>("shallow", model);
			var deep = new State<Instance>("deep", model);
			var end = new FinalState<Instance>("final", model);

			var s1 = new State<Instance>("s1", shallow);
			var s2 = new State<Instance>("s2", shallow);

			initial.To(shallow);
			new PseudoState<Instance>("shallow", shallow, PseudoStateKind.ShallowHistory).To(s1);
			s1.To(s2).When<string>(c => c == "move");
			shallow.To(deep).When<string>(c => c == "go deep");
			deep.To(shallow).When<string>(c => c == "go shallow");
			s2.To(end).When<string>(c => c == "end");

			model.Validate();

			var instance = new Instance("history");

			model.Initialise(instance);

			model.Evaluate(instance, "move");
			model.Evaluate(instance, "go deep");
			model.Evaluate(instance, "go shallow");
			model.Evaluate(instance, "end");

			Trace.Assert(model.IsComplete(instance));
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:31,代码来源:History.cs


示例9: Start

 // Use this for initialization
 void Start()
 {
     sm = StateMachine<States>.Initialize(this);
     sm.ChangeState(States.Lobby);
     resourceManager = this.GetComponent<ResourceManager>();
     currentPlayer = playerManager.currentPlayer;
 }
开发者ID:RGamberini,项目名称:Hex-Based-Unity-Game,代码行数:8,代码来源:Game.cs


示例10: WaitingState

 public WaitingState(StateMachine sm, CameraManager cam, Game game, float time, Team TeamOnSuper)
     : base(sm, cam, game)
 {
     this.remainingTime = time;
     this.TeamOnSuper = TeamOnSuper;
     this.onWiningPoints = false;
 }
开发者ID:sylafrs,项目名称:rugby,代码行数:7,代码来源:WaitingState.cs


示例11: WhenGuardConditionTrue_IsGuardConditionMetIsTrue

        public void WhenGuardConditionTrue_IsGuardConditionMetIsTrue()
        {
            var transtioning = new StateMachine<State, Trigger>.TransitioningTriggerBehaviour(
                Trigger.X, State.C, () => true);

            Assert.IsTrue(transtioning.IsGuardConditionMet);
        }
开发者ID:Horb,项目名称:stateless,代码行数:7,代码来源:TriggerBehaviourFixture.cs


示例12: ExposesCorrectUnderlyingTrigger

        public void ExposesCorrectUnderlyingTrigger()
        {
            var transtioning = new StateMachine<State, Trigger>.TransitioningTriggerBehaviour(
                Trigger.X, State.C, () => true);

            Assert.AreEqual(Trigger.X, transtioning.Trigger);
        }
开发者ID:Horb,项目名称:stateless,代码行数:7,代码来源:TriggerBehaviourFixture.cs


示例13: StateMachine

 /// <summary>
 /// Initializes a new instance of the <see cref="StateMachine"/> class.
 /// </summary>
 /// <param name="sm">Sm.</param>
 public StateMachine(StateMachine sm)
     : this()
 {
     if(sm != null){
         SetAllStatus(sm._status[0],sm._status[1],sm._status[2]);
     }
 }
开发者ID:mariojgpinto,项目名称:UnityUtilities,代码行数:11,代码来源:StateMachine.cs


示例14: Run

		public static void Run () {
			var model = new StateMachine<Instance>("compTest");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);

			var activity1 = new State<Instance>("activity1", model);
			var activity2 = new State<Instance>("activity2", model);
			var activity3 = new State<Instance>("activity3", model);
			var junction1 = new PseudoState<Instance>("junction1", model, PseudoStateKind.Junction);
			var junction2 = new PseudoState<Instance>("junction2", model, PseudoStateKind.Junction);
			var end = new FinalState<Instance>("end", model);

			var subInitial = new PseudoState<Instance>("subInitial", activity2, PseudoStateKind.Initial);
			var subEnd = new FinalState<Instance>("subEnd", activity2);

			subInitial.To(subEnd);
			initial.To(activity1);
			activity1.To(activity2);
			activity2.To(junction1);
			junction1.To(junction2).Else();
			junction2.To(activity3).Else();
			activity3.To(end);

			model.Validate();

			var instance = new Instance("transitions");
			model.Initialise(instance);

			Trace.Assert(model.IsComplete(instance));
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:29,代码来源:Transitions.cs


示例15: FieldPlayer

        public FieldPlayer(SoccerTeam homeTeam,
                      int homeRegionIndex,
                      State<FieldPlayer> startState,
                      Vector2D heading,
                      Vector2D velocity,
                      double mass,
                      double maxForce,
                      double maxSpeed,
                      double maxTurnRate,
                      double scale,
                      PlayerBase.PlayerRoles role)
            : base(homeTeam, homeRegionIndex, heading, velocity, mass, maxForce, maxSpeed, maxTurnRate, scale, role)
        {
            _stateMachine = new StateMachine<FieldPlayer>(this);

            if (startState != null)
            {
                _stateMachine.CurrentState = _stateMachine.PreviousState = startState;
                _stateMachine.GlobalState = GlobalPlayerState.Instance;
                _stateMachine.CurrentState.Enter(this);
            }

            _steeringBehaviors.Seperation = true;

            //set up the kick regulator
            _kickRegulator = new Regulator(ParameterManager.Instance.PlayerKickFrequency);
        }
开发者ID:soshimozi,项目名称:SimpleSoccer.Net,代码行数:27,代码来源:FieldPlayer.cs


示例16: AdcStateMachine

        public AdcStateMachine(User user)
        {
            _states[AdcProtocolState.Unknown] = new UnknownState(user);
            _states[AdcProtocolState.Protocol] = new ProtocolState(user);
            _states[AdcProtocolState.Identify] = new IdentifyState(user);
            _states[AdcProtocolState.Normal] = new NormalState(user);

            _stateMachine = new StateMachine<AdcProtocolState, StateMachineEvent, Command>(
                () => user.StateManager.GetOrAddStateAsync(StoredState, AdcProtocolState.Unknown),
                state => user.StateManager.SetStateAsync(StoredState, state));

            _stateMachine
                .ConfigureState(_states[AdcProtocolState.Unknown])
                .SwitchTo(AdcProtocolState.Protocol, StateMachineEvent.ClientOpened)
                .ElseSwitchTo(AdcProtocolState.Unknown);

            _stateMachine
                .ConfigureState(_states[AdcProtocolState.Protocol])
                .ConfigureIfChoice(new SupportsChoice(user))
                .ConfigureIfChoice(new ProtocolStatusChoice(user))
                .ConfigureElseTransition(new ProtocolToUnknownTransition(user));

            _stateMachine
                .ConfigureState(_states[AdcProtocolState.Identify])
                .ConfigureIfChoice(new IdentifyInfChoice(user))
                .ConfigureIfChoice(new IdentifyStatusChoice(user))
                .ConfigureElseTransition(new IdentifyToUnknownTransition(user));

            _stateMachine
                .ConfigureState(_states[AdcProtocolState.Normal])
                .ConfigureTransition(new NormalToUnknownTransition(user))
                .ConfigureIfChoice(new NormalStatusChoice(user))
                .ConfigureElseTransition(new NormalProcessing(user));
        }
开发者ID:Caraul,项目名称:FabricAdcHub,代码行数:34,代码来源:AdcStateMachine.cs


示例17: TryGetStateMachine

 private bool TryGetStateMachine(out StateMachine stateMachine)
 {
     stateMachine = null;
     ITextBuffer textBuffer;
     return _weakTextBuffer.TryGetTarget(out textBuffer) &&
         textBuffer.Properties.TryGetProperty(typeof(StateMachine), out stateMachine);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:RenameTrackingTaggerProvider.UndoPrimitive.cs


示例18: onEnterState

	public override void onEnterState ( StateMachine  prevState)
	{
		base.onEnterState(prevState);
		this.prevState = prevState;
		//open menu
		setCurrentState( main_state );
	}
开发者ID:spytroll33,项目名称:roguelike,代码行数:7,代码来源:PopMenuState.cs


示例19: GuardTest

        public GuardTest()
        {
            this.testee = new StateMachine<StateMachine.States, StateMachine.Events>();

            this.testee.Initialize(StateMachine.States.A);
            this.testee.EnterInitialState();
        }
开发者ID:kkcosmo,项目名称:statemachine,代码行数:7,代码来源:GuardTest.cs


示例20: onEnterState

 //inform player move
 public override void onEnterState( StateMachine  prevState)
 {
     base.onEnterState(prevState);
     this.prevState = prevState;
     actionPoint = 1;
     this.targetLayer = GameController.instance.interactLayer;
 }
开发者ID:EricHuAktsk,项目名称:roguelike,代码行数:8,代码来源:PlayerTurnState.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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