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


C# StateMachine类代码示例

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


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


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