本文整理汇总了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);
}
示例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));
}
示例3: Effect
protected Effect(Control control, int milliseconds)
{
Manager.Instance.IncludeResourceScript("Effects.js");
_control = control;
_milliseconds = milliseconds;
_type = Transition.Explosive;
}
示例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();
}
});
}
}
示例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);
}
示例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;
}
示例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());
}
示例8: Transition_AllowsNullSource
public void Transition_AllowsNullSource()
{
var t = new Transition<StubStateModel>(
new Trigger("trigger"),
null,
new Mock<State<StubStateModel>>("to").Object);
}
示例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;
}
示例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);
}
示例11: DeleteTransition
public void DeleteTransition(Transition transition)
{
if (map.ContainsKey(transition))
{
map.Remove(transition);
}
}
示例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 );
}
示例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;
}
示例14: AddTransition
public void AddTransition(Transition t)
{
if (t != null)
{
_transitions.Add(t);
}
}
示例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.");
}