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


C# StateMachine.AddState方法代码示例

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


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

示例1: Init

 public void Init(Entity o, string name)
 {
     owner = o;
     machine = new StateMachine(name);
     machine.AddState((int)AIState.IDLE, () => owner.StartIdle(), () => owner.Idling(), () => owner.EndIdle());
     machine.AddState((int)AIState.MOVE, () => owner.StartMove(), () => owner.Moving(), () => owner.EndMove());
     machine.ToState((int)AIState.IDLE);
 }
开发者ID:yangyu19840716,项目名称:Alpha,代码行数:8,代码来源:AI.cs

示例2: InitState

    private void InitState()
    {
        StateMachine = new StateMachine(this);

        StateMachine.AddState(new IdelState(StateMachine) { State = aStateState.WakeUp });
        StateMachine.AddState(new MoveState(StateMachine));

        StateMachine.Entry();
    }
开发者ID:KumoKyaku,项目名称:MMDARPG,代码行数:9,代码来源:Charator+State.cs

示例3: EnragedState

    public EnragedState(Boss boss, IState enragedState)
        : base(StateIds.Enraged, boss)
    {
        NextStateIds.Add(StateIds.Dead);
        NextStateIds.Add(StateIds.Waiting);
        NextStateIds.Add (StateIds.Regular);

        stateMachine = new StateMachine(enragedState);
        stateMachine.AddState(new StunnedState(boss));
        stateMachine.AddState(new HurtState(boss));
        stateMachine.AddState(new IdleState(boss));
    }
开发者ID:etiens,项目名称:VikingQuest,代码行数:12,代码来源:EnragedState.cs

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

示例5: CreateMachine

    public override StateMachine CreateMachine()
    {
        StateMachine machine = new StateMachine();
        machine.AddDefaultState(new EvadeState((int)States.EVADE, this));
        machine.AddState(new FleeState((int)States.FLEE, this));

        return machine;
    }
开发者ID:velhelm,项目名称:CMPS426,代码行数:8,代码来源:EvasiveAIControl.cs

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

示例7: SetupFan

        private void SetupFan(StateMachine fan, IArea room, HSREL8 hsrel8)
        {
            var fanRelay1 = hsrel8[HSREL8Pin.Relay0];
            var fanRelay2 = hsrel8[HSREL8Pin.Relay1];
            var fanRelay3 = hsrel8[HSREL8Pin.Relay2];

            fan.AddOffState()
                .WithLowOutput(fanRelay1)
                .WithLowOutput(fanRelay2)
                .WithLowOutput(fanRelay3);

            fan.AddState(new ComponentState("1")).WithHighOutput(fanRelay1).WithLowOutput(fanRelay2).WithHighOutput(fanRelay3);
            fan.AddState(new ComponentState("2")).WithHighOutput(fanRelay1).WithHighOutput(fanRelay2).WithLowOutput(fanRelay3);
            fan.AddState(new ComponentState("3")).WithHighOutput(fanRelay1).WithHighOutput(fanRelay2).WithHighOutput(fanRelay3);
            fan.TryTurnOff();

            fan.ConnectMoveNextAndToggleOffWith(room.GetButton(Bedroom.ButtonWindowLower));
        }
开发者ID:chkr1011,项目名称:CK.HomeAutomation,代码行数:18,代码来源:BedroomConfiguration.cs

示例8: Awake

 // Use this for initialization
 void Awake()
 {
     // initialize state machine
     ai_state = new StateMachine<System.Object>();
     ai_state.AddState(ai_states.none, () => { });
     ai_state.AddState(ai_states.idle, OnIdleState);
     ai_state.AddState(ai_states.trace, OnTracingState);
     ai_state.AddState(ai_states.attack, OnAttackState);
     ai_state.AddState(ai_states.special_0, OnSpecial0State);
     ai_state.SetInitState(ai_states.idle);
 }
开发者ID:cushionbadak,项目名称:Git_Unity_Aura,代码行数:12,代码来源:ProbabilityAI.cs

示例9: Start

    // this should be called before its sibling
    public virtual void Start()
    {
        // initialize state machine
        unit_state = new StateMachine<unit_states>();
        unit_state.AddState(unit_states.none, () => { });
        unit_state.AddState(unit_states.act, UnitStateAct);
        unit_state.AddState(unit_states.actpause, UnitStateActPause);
        unit_state.SetInitState(unit_states.act);

        // add aura
        GameObject aura_object = (GameObject)Instantiate(Resources.Load("Prefabs/EnemyAura"), transform.position, new Quaternion());
        aura = aura_object.GetComponent<EnemyAttackAura>();
        aura.SetOwner(this);
    }
开发者ID:cushionbadak,项目名称:Git_Unity_Aura,代码行数:15,代码来源:NewEnemyUnit.cs

示例10: Awake

    void Awake()
    {
        // create new state machine
        stateMachine = new StateMachine<PlayerController>(this, new PlayerInitState());

        // add all of states to state machine so that we can switch to them
        stateMachine.AddState(new PlayerWaitingState());
        stateMachine.AddState(new PlayerFlyState());
        stateMachine.AddState(new PlayerFallState());
        stateMachine.AddState(new PlayerRunState());
        stateMachine.AddState(new PlayerBurningState());
        stateMachine.AddState(new PlayerThunderBoostState());
        stateMachine.AddState(new PlayerFallInWaterState());
        stateMachine.AddState(new PlayerFinishRaceState());

        stateMachine.ChangeState<PlayerWaitingState>();
        // listen for state changes
        stateMachine.onStateChanged += () =>
        {
            //Debug.Log("state changed: " + stateMachine.CurrentState);
        };

        body = GetComponent<Rigidbody2D>();
        animator = GetComponentInChildren<Animator>();
        textName = GetComponentInChildren<TextMesh>();
        dragonPropertie.Load();
    }
开发者ID:trongthien18,项目名称:race-of-dragons,代码行数:27,代码来源:PlayerController.cs

示例11: SetupLight

        private void SetupLight(StateMachine light, HSREL8 hsrel8, HSPE8OutputOnly hspe8, IArea room)
        {
            // Front lights (left, middle, right)
            var fl = hspe8[HSPE8Pin.GPIO0].WithInvertedState();
            var fm = hspe8[HSPE8Pin.GPIO2].WithInvertedState();
            var fr = hsrel8[HSREL8Pin.GPIO0].WithInvertedState();

            // Middle lights (left, middle, right)
            var ml = hspe8[HSPE8Pin.GPIO1].WithInvertedState();
            var mm = hspe8[HSPE8Pin.GPIO3].WithInvertedState();
            var mr = hsrel8[HSREL8Pin.GPIO1].WithInvertedState();

            // Rear lights (left, right)
            // Two mechanical relays.
            var rl = hsrel8[HSREL8Pin.GPIO5];
            var rr = hsrel8[HSREL8Pin.GPIO4];

            light.AddOffState()
                .WithLowOutput(fl)
                .WithLowOutput(fm)
                .WithLowOutput(fr)
                .WithLowOutput(ml)
                .WithLowOutput(mm)
                .WithLowOutput(mr)
                .WithLowOutput(rl)
                .WithLowOutput(rr);

            light.AddOnState()
                .WithHighOutput(fl)
                .WithHighOutput(fm)
                .WithHighOutput(fr)
                .WithHighOutput(ml)
                .WithHighOutput(mm)
                .WithHighOutput(mr)
                .WithHighOutput(rl)
                .WithHighOutput(rr);

            var deskOnlyStateId = new ComponentState("DeskOnly");
            light.AddState(deskOnlyStateId)
                .WithHighOutput(fl)
                .WithHighOutput(fm)
                .WithLowOutput(fr)
                .WithHighOutput(ml)
                .WithLowOutput(mm)
                .WithLowOutput(mr)
                .WithLowOutput(rl)
                .WithLowOutput(rr);

            var couchOnlyStateId = new ComponentState("CouchOnly");
            light.AddState(couchOnlyStateId)
                .WithLowOutput(fl)
                .WithLowOutput(fm)
                .WithLowOutput(fr)
                .WithLowOutput(ml)
                .WithLowOutput(mm)
                .WithLowOutput(mr)
                .WithLowOutput(rl)
                .WithHighOutput(rr);

            light.WithTurnOffIfStateIsAppliedTwice();

            room.GetButton(Office.ButtonLowerRight)
                .GetPressedShortlyTrigger()
                .Attach(light.GetSetStateAction(couchOnlyStateId));

            room.GetButton(Office.ButtonLowerLeft)
                .GetPressedShortlyTrigger()
                .Attach(light.GetSetStateAction(deskOnlyStateId));

            room.GetButton(Office.ButtonUpperLeft)
                .GetPressedShortlyTrigger()
                .Attach(light.GetSetStateAction(BinaryStateId.On));

            _synonymService.AddSynonymsForArea(Room.Office, "Büro", "Arbeitszimmer");

            _synonymService.AddSynonymsForComponent(Room.Office, Office.CombinedCeilingLights, "Licht");
            _synonymService.AddSynonymsForComponent(Room.Office, Office.SocketRearLeftEdge, "Rotlicht", "Pufflicht", "Rot");

            _synonymService.AddSynonymsForComponentState(deskOnlyStateId, "Schreibtisch");
            _synonymService.AddSynonymsForComponentState(couchOnlyStateId, "Couch");
        }
开发者ID:chkr1011,项目名称:CK.HomeAutomation,代码行数:81,代码来源:OfficeConfiguration.cs

示例12: Start

    //----------------------------------------------------------------------------------------------------
    // Use this for initialization
    //----------------------------------------------------------------------------------------------------
    void Start()
    {
        mHunger = 0.5f;
        mStress = 0f;

        // set up the AI
        mStateMachine = new StateMachine();
        mStateMachine.AddState( new CrowState_Idle() );
        mStateMachine.AddState( new CrowState_Dead() );
        mStateMachine.AddState( new CrowState_Eating() );
        mStateMachine.AddState( new CrowState_Fleeing() );
        mStateMachine.AddState( new CrowState_FlyingToCorn() );
        mStateMachine.AddState( new CrowState_WaitingForStress() );

        // find the scarecrow
        mScarecrow = FindObjectOfType(typeof(Scarecrow)) as Scarecrow;

        // start moving
        FlyToCorn();

        // pick the next time for the caw sound to play
        mNextCawSoundTime = Time.time + Random.Range( 0f, 2f );
    }
开发者ID:tabacco,项目名称:crowbot,代码行数:26,代码来源:Crow.cs

示例13: Awake

    public virtual void Awake()
    {
        Boat = GlobalScript.Instance.Boat;
        stateMachine = new StateMachine(new WaitingState(this));
        stateMachine.AddState(new DeadState(this));
        AddEnragedState();
        AddRegularState();
        HealthPoints = maxHP;
        StunHP = stunResistance;

        Hurt = false;
        Recovering = false;
        //Engaged = false;
    }
开发者ID:etiens,项目名称:VikingQuest,代码行数:14,代码来源:Boss.cs

示例14: SetupFan

        private void SetupFan(StateMachine stateMachine, HSREL5 hsrel5)
        {
            var fanPort0 = hsrel5.GetOutput(4);
            var fanPort1 = hsrel5.GetOutput(5);

            stateMachine.AddOffState().WithOutput(fanPort0, BinaryState.Low).WithOutput(fanPort1, BinaryState.Low);
            stateMachine.AddState(new ComponentState("1")).WithOutput(fanPort0, BinaryState.High).WithOutput(fanPort1, BinaryState.Low);
            stateMachine.AddState(new ComponentState("2")).WithOutput(fanPort0, BinaryState.High).WithOutput(fanPort1, BinaryState.High);
            stateMachine.TryTurnOff();
        }
开发者ID:chkr1011,项目名称:CK.HomeAutomation,代码行数:10,代码来源:UpperBathroomConfiguration.cs

示例15: SetAnimator

	// Create and assign controller and animation
	void SetAnimator()
	{
		// Add the component if it's not already there
		if (gameObject.GetComponent<Animator>() == null)
			gameObject.AddComponent<Animator>();
			
		charAnimator = (Animator)gameObject.GetComponent<Animator>();

		// Set speed to 0 so no real animation takes place
		charAnimator.speed = 0.0f;
		
		UnityEditorInternal.AnimatorController aController = new UnityEditorInternal.AnimatorController();
		aController.name = "animation_controller";
		
		if (aController.GetLayerCount() == 0)
			aController.AddLayer("Base");
		
		StateMachine sm = new StateMachine();
		sm.AddState("default");
		
		// Add clip
		sm.GetState(0).SetMotion(0, (AnimationClip)animations[animCount]);
		animCount++;
		
		aController.SetLayerStateMachine(0, sm);
		
		UnityEditorInternal.AnimatorController.SetAnimatorController(charAnimator, aController);
		
		// Set time
		currTime = charAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime;
	}
开发者ID:noa99kee,项目名称:character-model-detection,代码行数:32,代码来源:CharacterScript.cs


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