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


C# StateMachine.ChangeState方法代码示例

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


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

示例1: 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

示例2: Start

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

示例3: 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

示例4: 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

示例5: Awake

 void Awake()
 {
     hunger = 0;
     hungerThreashold =30;
     nose = (WolfScent)GetComponentInChildren<WolfScent>();
     eyes = (WolfSight)GetComponentInChildren<WolfSight>();
     thisWolf = new StateMachine<Wolf>(this);
     thisWolf.ChangeState(WolfRest.Instance());
 }
开发者ID:CaryJasinski,项目名称:GameAI-StateMachine,代码行数:9,代码来源:Wolf.cs

示例6: InitialTransition

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

        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);

        Assert.AreEqual(0, behaviour.threeStats.enterCount);
        Assert.AreEqual(0, behaviour.threeStats.updateCount);
        Assert.AreEqual(0, behaviour.threeStats.lateUpdateCount);
        Assert.AreEqual(0, behaviour.threeStats.exitCount);
        Assert.AreEqual(0, behaviour.threeStats.finallyCount);

        behaviour.enabled = false;
        fsm.ChangeState(States.Three);

        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(1, behaviour.twoStats.exitCount);
        Assert.AreEqual(1, behaviour.twoStats.finallyCount);

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

示例7: TestCallbacks

        public void TestCallbacks()
        {
            List<string> messages = new List<string>();

            StateMachine<TestNum> machine = new StateMachine<TestNum>();
            machine.AddState(TestNum.Red);
            machine.SubscribeToEntry(TestNum.Red, (TestNum oldState, TestNum newState) =>
            {
                messages.Add("Enter the red!");
            });
            machine.SubscribeToExit(TestNum.Red, (TestNum oldState, TestNum newState) =>
            {
                messages.Add("Exit the red!");
            });

            machine.AddState(TestNum.White);
            machine.SubscribeToEntry(TestNum.White, (TestNum oldState, TestNum newState) =>
            {
                messages.Add("Enter the white!");
            });
            machine.SubscribeToExit(TestNum.White, (TestNum oldState, TestNum newState) =>
            {
                messages.Add("Exit the white!");
            });
            machine.SubscribeToExit(TestNum.White, (TestNum oldState, TestNum newState) =>
            {
                messages.Add("Sneaky Second Message!");
            });

            machine.ChangeState(TestNum.Red);
            machine.ChangeState(TestNum.White);
            machine.ChangeState(TestNum.Red);

            Assert.AreEqual(6, messages.Count);
            Assert.AreEqual("Enter the red!", messages[0]);

            Assert.AreEqual("Exit the red!", messages[1]);
            Assert.AreEqual("Enter the white!", messages[2]);

            Assert.AreEqual("Exit the white!", messages[3]);
            Assert.AreEqual("Sneaky Second Message!", messages[4]);
            Assert.AreEqual("Enter the red!", messages[5]);
        }
开发者ID:madigan,项目名称:StateMeister,代码行数:43,代码来源:StateMachineTests.cs

示例8: IgnoreMultipleTransitions

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

        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);

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

示例9: Awake

    // Use this for initialization
    void Awake() {
        if (S != null)
            Debug.LogError("Multiple players!");
        S = this;
        start_point = transform.position;
        health = maxhealth;

        animation_state_machine = new StateMachine();
        animation_state_machine.ChangeState(new StateIdleWithSprite(this, GetComponent<SpriteRenderer>(), link_run_down[0]));

        control_state_machine = new StateMachine();
        control_state_machine.ChangeState(new StateLinkNormalMovement(this));

        roomPos = new Vector3(-1000000, -1000000);
        enemySpawnTimer = .5f;
    }
开发者ID:ConnorUllmann,项目名称:EECS494_Proj1,代码行数:17,代码来源:PlayerControl.cs

示例10: Awake

    //Vector2 dirVec;
    //private int angle;
    //Quaternion newDirToRotate;
    //public float length, yVec;
    //public bool isMoving, hasRotated, enumFinished, inState, test;
    // Use this for initialization
    void Awake()
    {
        Fatigue = 0;
        fuzzyFatigue = Random.Range(60,120);
        //inState = false;
        //test = false;
        thisDuck = new StateMachine<MotherDuck>(this);
        thisDuck.ChangeState(MotherDuckWandering.Instance());
        //thisDuck.UpdateState();
        movement = Vector3.zero;
        //prevMovement = Vector3.zero;

        //isMoving = true;
        //hasRotated = false;

        //enumFinished = false;
    }
开发者ID:CaryJasinski,项目名称:GameAI-StateMachine,代码行数:23,代码来源:MotherDuck.cs

示例11: Check

		protected override void Check()
		{
			var s1 = new StateMachine<E>(E.B);
			var s2 = new StateMachine<E>(E.C);
			var s3 = new StateMachine<E>(E.G);

			GenerateCode(SerializationMode.Optimized, s1, s2, s3);
			StateSlotCount.ShouldBe(1);

			Serialize();
			s1.ChangeState(E.A);
			s2.ChangeState(E.A);
			s3.ChangeState(E.A);

			Deserialize();
			s1.State.ShouldBe(E.B);
			s2.State.ShouldBe(E.C);
			s3.State.ShouldBe(E.G);
		}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:19,代码来源:state+machine.cs

示例12: AerialPursuer

        public AerialPursuer(State<AerialPursuer> startState,
            Point position,
            float radius,
            Vector2D velocity,
            float maxSpeed,
            Vector2D heading,
            float mass,
            Vector2D scale,
            float turnRate,
            float maxForce,
            List<Node> patrolPath,
            Workspace traversabilityMap,
            Workspace visibilityMap)
            : base(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, patrolPath, traversabilityMap, visibilityMap)
        {
            StateMachine = new StateMachine<AerialPursuer>(this);

            if (startState != null)
            {
                StateMachine.SetCurrentState(startState);
                StateMachine.ChangeState(startState);
                StateMachine.SetGlobalState(GlobalAerialPursuerStates.TheInstance);
            }
        }
开发者ID:testing32,项目名称:AIProjects,代码行数:24,代码来源:AerialPursuer.cs

示例13: Start

 // Use this for initialization
 void Start()
 {
     health = 3.0f;
     state_machine = new StateMachine();
     state_machine.ChangeState(new StateAquamentusNormal(this, GetComponent<SpriteRenderer>(), walk));
 }
开发者ID:ConnorUllmann,项目名称:EECS494_Proj1,代码行数:7,代码来源:Aquamentus.cs

示例14: Start

 // Use this for initialization
 void Start()
 {
     startPos = new Vector3((int)Mathf.Round(transform.position.x), (int)Mathf.Round(transform.position.y), 0);
     state_machine = new StateMachine();
     state_machine.ChangeState(new StateBladetrapNormal(this));
 }
开发者ID:ConnorUllmann,项目名称:EECS494_Proj1,代码行数:7,代码来源:Bladetrap.cs

示例15: Start

 void Start()
 {
     player_state_machine = new StateMachine();
     player_state_machine.ChangeState(new State_Player_Normal_Movement(this));
 }
开发者ID:cischken,项目名称:WorldBelow,代码行数:5,代码来源:Player.cs


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