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


C# Transition类代码示例

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


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

示例1: AddTransition

    public void AddTransition(Transition trans, StateID id)
    {
        //first step of the fsm
        //check the args and see if they are invalid
        if (trans == Transition.NullTransition) {
            Debug.LogError("FSM had a pretty bad error.  Null transition is not allowed for a real tranisition. \n You have a shit ton of work david");
            return;

        }

        if (id == StateID.NullStateID) {
            Debug.LogError("FSM had a pretty bad error. Null STATE id is not allowed for a real ID");
            return;
        }

        // deterministic FSM
        //      check if current transition was already inside the map

        if (map.ContainsKey(trans)) {
            // fuck, if this hits ive hit a transition that already has a transition

            //   Enum enumerations = RuntimeTypeHandle.ReferenceEquals(StateID);
            Debug.LogError("FSM had a pretty bad error" + stateID.ToString() + " Already has a transition"
                +trans.ToString() + " Impossible to assign to another state");
            return;

        }
        map.Add(trans, id);
    }
开发者ID:daxaxelrod,项目名称:Loom-Vr,代码行数:29,代码来源:BankFiniteStateMachine.cs

示例2: Transition_Equals_CustomGuardSame_SameProps_ReturnsTrue

 public void Transition_Equals_CustomGuardSame_SameProps_ReturnsTrue()
 {
     Func<StubStateModel, bool> guard = m => true;
     var t1 = new Transition<StubStateModel>(new Trigger("t1"), new State<StubStateModel>("s1"), new State<StubStateModel>("s2"), guard);
     var t2 = new Transition<StubStateModel>(new Trigger("t1"), new State<StubStateModel>("s1"), new State<StubStateModel>("s2"), guard);
     Assert.True(t1.Equals(t2));
 }
开发者ID:mmonteleone,项目名称:nate,代码行数:7,代码来源:TransitionTests.cs

示例3: Effect

        protected Effect(Control control, int milliseconds)
		{
            Manager.Instance.IncludeResourceScript("Effects.js");
            _control = control;
			_milliseconds = milliseconds;
            _type = Transition.Explosive;
        }
开发者ID:polterguy,项目名称:magix,代码行数:7,代码来源:Effect.cs

示例4: hideMenu

    /// <summary>
    /// Hide menu
    /// </summary>
    public virtual void hideMenu(float transitionTimer, MenuTransition path = MenuTransition.BACKWARD, Callback callback = null)
    {
        // Stop any transition that's currently in effect
        TransitionHandler.removeTransition(alphaTransition);
        TransitionHandler.removeTransition(positionTransition);

        if(transitionTimer == 0.0f) {

            // Make UI object invisible
            imgAlpha.alpha = 0.0f;

            // Turn off the UI game object
            gameObject.SetActive(false);

            if(callback != null) {
                callback();
            }
        }
        else {

            // Animate the position transition
            positionTransition = TransitionHandler.addTransition(() => Vector2.zero, x => menuTransform.anchoredPosition = x, new Vector2(0, -30), transitionTimer).toggleTimeScale(false);

            // Fade out the menu then disable the object after it's finished fading out
            alphaTransition = TransitionHandler.addTransition(()=>getAlpha.alpha, x => getAlpha.alpha = x, 0.0f, transitionTimer).toggleTimeScale(false).finishLerp(() => {
                gameObject.SetActive(false);
                if (callback != null) {
                    callback();
                }
            });
        }
    }
开发者ID:rhhzero,项目名称:Infinity-Rush,代码行数:35,代码来源:MenuUI.cs

示例5: AddTransition

    public void AddTransition(Transition trans, StateID id)
    {
        // Check if anyone of the args is invalid
        if (trans == Transition.NullTransition)
        {
            Debug.LogError("FSMState ERROR: NullTransition is not allowed for a real transition");
            return;
        }
 
        if (id == StateID.NullStateID)
        {
            Debug.LogError("FSMState ERROR: NullStateID is not allowed for a real ID");
            return;
        }
 
        // Since this is a Deterministic FSM,
        //   check if the current transition was already inside the map
        if (map.ContainsKey(trans))
        {
            Debug.LogError("FSMState ERROR: State " + stateID.ToString() + " already has transition " + trans.ToString() + 
                           "Impossible to assign to another state");
            return;
        }
 
        map.Add(trans, id);
    }
开发者ID:kurainisei,项目名称:SpaceVehicle,代码行数:26,代码来源:FSMSystem.cs

示例6: Button

        /// <summary>
        /// Constructs a button.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="position"></param>
        /// <param name="transitionOnTime"></param>
        /// <param name="transitionOffTime"></param>
        /// <param name="transitionOnSide"></param>
        /// <param name="transitionOffSide"></param>
        public Button(
            string text, 
            Vector2 position, 
            Color color,
            Color selectedColor,
            float scale,
            float selectedScale,
            double selectionTransitionOnTime,
            double selectionTransitionOffTime,
            double transitionOnTime, 
            double transitionOffTime, 
            ScreenSide transitionOnSide, 
            ScreenSide transitionOffSide)
            : base(transitionOnTime, transitionOffTime, transitionOnSide, transitionOffSide, null, position)
        {
            this.text = new TextComponent(text, position);

            this.color = color;
            this.selectedColor = selectedColor;

            this.scale = scale;
            this.selectedScale = selectedScale;

            this.selectionTransition = new Transition(selectionTransitionOnTime, selectionTransitionOffTime);

            this.OnSelection += Button_Selection;
            this.OnDeselection += Button_Deselection;

            this.TabStop = true;
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:39,代码来源:Button.cs

示例7: AddTransition

    // Add Transition
    public void AddTransition(Transition trans, StateID id)
    {
        //check if transition exist
        if(trans == Transition.NULL)
        {
            Debug.LogError("Trying to add a null transition");
            return;
        }
        if(id == StateID.NULL)
        {
            Debug.LogError("Trying to add a null state");
            return;
        }

        if(trans == Transition.E_NOHP)
        {
            Debug.Log("trans: " + trans.ToString() + " StateID: " + id.ToString());
        }

        // check if current map already contains key
        if(map.ContainsKey(trans))
        {
            Debug.LogError(trans.ToString() + " transition Exist, unable to have duplicate transitions for State: " + id.ToString());
            return;
        }

        map.Add(trans, id);

        Debug.Log("Sucessfully added: " + trans.ToString() + " id extract: " + map[trans] + " Current StateID: " + STATE_ID.ToString());
    }
开发者ID:kreeds,项目名称:TestProjectDemo,代码行数:31,代码来源:FSMState.cs

示例8: Transition_AllowsNullSource

 public void Transition_AllowsNullSource()
 {
     var t = new Transition<StubStateModel>(
         new Trigger("trigger"),
         null,
         new Mock<State<StubStateModel>>("to").Object);
 }
开发者ID:mmonteleone,项目名称:nate,代码行数:7,代码来源:TransitionTests.cs

示例9: GenerateStateMachine

        public static FiniteStateMachine GenerateStateMachine(string id, int states, double transitionsPerState, double endStateProbability)
        {
            var fsm = new FiniteStateMachine();
            var rand = new Random();
            fsm.Id = id;

            for (int i = 0; i < states; i++)
            {
                var state = new State();
                state.Name = "q" + i.ToString();
                state.IsEndState = rand.NextDouble() < endStateProbability;
                fsm.States.Add(state);
            }

            var transitions = (int)Math.Floor(states * transitionsPerState + 0.5);
            for (int i = 0; i < transitions; i++)
            {
                State start;
                State end;
                string input;
                do
                {
                    start = fsm.States[rand.Next(fsm.States.Count)];
                    end = fsm.States[rand.Next(fsm.States.Count)];
                    input = __inputs[rand.Next(__inputs.Length)];
                } while (start.Transitions.Any(t => t.Input == input));
                var transition = new Transition();
                transition.StartState = start;
                transition.EndState = end;
                transition.Input = input;
                fsm.Transitions.Add(transition);
            }

            return fsm;
        }
开发者ID:NMFCode,项目名称:SynchronizationsBenchmark,代码行数:35,代码来源:StateMachineGenerator.cs

示例10: CompositeStateTest

        public void CompositeStateTest()
        {
            var sm = new StateMachine();

              var s0 = CreateState("0");
              var s0States = new StateCollection();
              s0.ParallelSubStates.Add(s0States);
              sm.States.Add(s0);

              var s00 = CreateState("00");
              s0States.Add(s00);
              var s01 = CreateState("01");
              s0States.Add(s01);

              var t0 = new Transition
              {
            SourceState = s0,
            TargetState = s0,
              };
              t0.Action += (s, e) => _events = _events + "A0";

              sm.Update(TimeSpan.FromSeconds(1));
              sm.Update(TimeSpan.FromSeconds(1));
              t0.Fire();
              sm.Update(TimeSpan.FromSeconds(1));
              sm.Update(TimeSpan.FromSeconds(1));

              Assert.AreEqual("E0E00U00U0U00U0X00X0A0E0E00U00U0U00U0", _events);
        }
开发者ID:,项目名称:,代码行数:29,代码来源:

示例11: DeleteTransition

 public void DeleteTransition(Transition transition)
 {
     if (map.ContainsKey(transition))
     {
         map.Remove(transition);
     }
 }
开发者ID:yiliu1203,项目名称:FSM_AI,代码行数:7,代码来源:FSMState.cs

示例12: Awake

	void Awake() {
		
		controllerCamera = Camera.mainCamera;
		
		//Setup Messenger
		Messenger.AddListener(InputManager.kMegatileCapMet, 			OnOpenMenu);
		Messenger<Vector3>.AddListener(InputManager.kRightClickedTile, 	OnCloseMenu);
		Messenger.AddListener(kClose,									OnCloseMenu);
		
		//Setup GUIGroup
		menuGroup = new GUIContainer(controllerCamera.pixelRect,false);
		menuGroup.anchor.Set(GUIAnchor.BottomCenter);  
		
		GameGUIManager.AddGUIObject(menuGroup);
		
		//Setup Transitions and State Machine
		Transition<TileSelectionMenu> goToOptions = new Transition<TileSelectionMenu>(this, states["Options"]);
		Transition<TileSelectionMenu> closeMenu = new Transition<TileSelectionMenu>(this, states["Waiting"]);
		
		states["Waiting"].AddTransition(goToOptions);
		states["Options"].AddTransition(closeMenu);
		
		goToOptions.InitFromExpression	( "{ TransitionBehavior_OnEvent openMenu( OpenMenu ); } openMenu");
		closeMenu.InitFromExpression	( "{ TransitionBehavior_OnEvent closeMenu( CloseMenu ); } closeMenu");
		
		behaviour.ChangeState( states["Waiting"], this );
	}
开发者ID:wids-eria,项目名称:tf_client,代码行数:27,代码来源:TileSelectionMenu.cs

示例13: ToCommon

        public static StateModel ToCommon(IList<StateControl> stateControls, int modelId, string modelName)
        {
            var sm = new StateModel();
            sm.States = new List<State>();
            sm.Transitions = new List<Transition>();
            int i = 0;
            foreach (var control in stateControls)
            {
                var state = new State();
                state.Default = control.StartState;
                state.Name = control.DisplayName;
                state.StateID = i;
                Point position = Page1.GetPosition(control);
                state.X = (int) position.X;
                state.Y = (int) position.Y;
                control.StateId = i;
                i++;
                sm.States.Add(state);
            }

            foreach (var control in stateControls)
            {
                foreach (var arrow in control.ArrowsOut)
                {
                    var trans = new Transition();
                    trans.DestinationStateRef = arrow.HeadControl.StateId;
                    trans.SourceStateRef = arrow.TailControl.StateId;
                    sm.Transitions.Add(trans);
                }
            }
            sm.ModelID = modelId;
            sm.ModelName = modelName;
            return sm;
        }
开发者ID:richorama,项目名称:StateMagic,代码行数:34,代码来源:ModelConverter.cs

示例14: AddTransition

 public void AddTransition(Transition t)
 {
     if (t != null)
     {
         _transitions.Add(t);
     }
 }
开发者ID:benjaml,项目名称:PathfindingToolUnity,代码行数:7,代码来源:AgentRobinMathieu.cs

示例15: addTransition

        public void addTransition(Transition transition,string eventName)
        {
            if (!transitionList.ContainsKey(eventName))
                transitionList.Add(eventName, transition);
			else
				Debug.Log("Transition "+eventName+" not Added. Already in "+name+"'s transitions.");
        }
开发者ID:vsanchez1987,项目名称:team-ragnarok,代码行数:7,代码来源:State.cs


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