public void When_StateTrigger_DataBound_Late() { var SUT = new UserControl(); var mgr = VisualStateManager.GetVisualStateManager(SUT); var group = new VisualStateGroup(); var state = new VisualState(); group.States.Add(state); var trigger = new StateTrigger(); trigger.SetBinding(StateTrigger.IsActiveProperty, new Binding() { Path = "a" }); var groups = new List <VisualStateGroup>(); groups.Add(group); state.StateTriggers.Add(trigger); VisualStateManager.SetVisualStateGroups(SUT, groups); Assert.IsNull(trigger.DataContext); Assert.IsFalse(trigger.IsActive); SUT.DataContext = new { a = true }; Assert.IsNotNull(group.DataContext); Assert.IsNotNull(state.DataContext); Assert.IsNotNull(trigger.DataContext); Assert.IsTrue(trigger.IsActive); }
public void When_StateTrigger_DataBound_Early() { var group = new VisualStateGroup(); group.DataContext = new { a = true }; var state = new VisualState(); object stateDataContextValue = null; state.DataContextChanged += (_, e) => { stateDataContextValue = e.NewValue; }; var trigger = new StateTrigger(); state.StateTriggers.Add(trigger); group.States.Add(state); Assert.IsNull(stateDataContextValue); Assert.IsFalse(trigger.IsActive); trigger.SetBinding(StateTrigger.IsActiveProperty, new Binding() { Path = "a" }); Assert.IsNotNull(stateDataContextValue); Assert.IsTrue(trigger.IsActive); }
public void CheckDecisionsTriggers(StateMachine stateMachine, StateTrigger trigger) { if (UnusedDecisionsStateTriggers.Contains(trigger)) { return; } foreach (Decision decision in Decisions) { if (!decision.Logic) { continue; } decision.Logic.StateMachine = stateMachine; switch (trigger) { case StateTrigger.OnStateEnter: decision.Logic.OnEnter(); break; case StateTrigger.OnStateExit: decision.Logic.OnExit(); break; } } }
public override void EnterCircle(StateTrigger t) { t.SetEnabled(false); Messenger.instance.KillMessage(m); m = new Message("Great Scott! I thought you were lost!\n" + "We were sucked into <insert plot device here>\nand ended up here.\n", "Captn S"); Messenger.instance.AddMessage(m); m = new Message("You seem to have lost your mining laser,\nget into the hangar so we can get you a new one!", "Captn S", callback: OpenHatch); Messenger.instance.AddMessage(m); }
public override void EnterCircle(StateTrigger t) { t.SetEnabled (false); Messenger.instance.KillMessage (m); m = new Message ("Great Scott! I thought you were lost!\n" + "We were sucked into <insert plot device here>\nand ended up here.\n", "Captn S"); Messenger.instance.AddMessage (m); m = new Message("You seem to have lost your mining laser,\nget into the hangar so we can get you a new one!", "Captn S" , callback: OpenHatch); Messenger.instance.AddMessage (m); }
public void When_DependencyObjectCollection_And_XBind() { var SUT = new Border(); var root = new { MyElement = new Border() { Tag = true } }; var group = new VisualStateGroup(); var state = new VisualState(); var compositeTrigger = new CompositeTrigger(); var stateTrigger = new StateTrigger(); stateTrigger.SetBinding( StateTrigger.IsActiveProperty, new Binding { Path = "MyElement.Tag", CompiledSource = root } ); Assert.AreEqual(false, stateTrigger.IsActive); var triggers = new DependencyObjectCollection(); triggers.Add(stateTrigger); compositeTrigger.TriggerCollection = triggers; state.StateTriggers.Add(compositeTrigger); group.States.Add(state); VisualStateManager.SetVisualStateGroups(SUT, new List <VisualStateGroup>() { group }); SUT.ForceLoaded(); SUT.ApplyCompiledBindings(); Assert.AreEqual(true, stateTrigger.IsActive); compositeTrigger.TriggerCollection = null; Assert.IsNull(triggers.GetParent()); }
private void _Init() { if (mTriggers.Count > 0) { return; } string[] toNextStates = StateTriggers.Split('|'); for (int i = 0; i < toNextStates.Length; i++) { StateTrigger trigger = new StateTrigger(toNextStates[i]); mTriggers.Add(trigger); } }
public override void Init() { Game.Instance.MapManager = new MapManager(Game.Instance, Game.Instance.SpriteBatch); World world = Game.Instance.World; PlayerOne = new KeyboardPlayer(world); PlayerOne.Position = new Vector2(500, 500); players[0] = PlayerOne; if (players.Length == 2) { PlayerTwo = new GamepadPlayer(world, PlayerIndex.One); PlayerTwo.Position = new Vector2(500, 700); Players[1] = PlayerTwo; } else { WeaponComponent weaponComponent = PlayerOne.Components .FirstOrDefault(c => c is WeaponComponent) as WeaponComponent; weaponComponent.CurrentWeapon.AddPower(15); } topWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth / 2f, Game.Instance.ScreenHeight / 2f - 50), Game.Instance.ScreenWidth * 2, 100); bottomWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth / 2f, Game.Instance.ScreenHeight + 50), Game.Instance.ScreenWidth * 2, 100); leftWall = new Wall(world, new Vector2(-50, Game.Instance.ScreenHeight / 2f), 100, Game.Instance.ScreenHeight); rightWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth + 50, Game.Instance.ScreenHeight / 2f), 100, Game.Instance.ScreenHeight); Game.Instance.Components.Add(Game.Instance.MapManager); StateTrigger trigger = new StateTrigger(Game.Instance); Game.Instance.Components.Add(trigger); Game.Instance.MapManager.ChangeMap("testmap"); Song bgmusic = Game.Instance.Content.Load <Song>("music\\bgmusic"); MediaPlayer.Play(bgmusic); MediaPlayer.Volume = 0.15f; MediaPlayer.IsRepeating = true; }
public void When_ElementNameSetter() { var g = new Grid(); Grid innerGrid = null; var subject = new ElementNameSubject(false, "test"); var stub = new ElementStub { ContentBuilder = () => { innerGrid = new Grid() { Name = "test" }; subject.ElementInstance = innerGrid; return(innerGrid); } }; subject.ElementInstance = stub; g.Children.Add(stub); var SUT = new Setter(new TargetPropertyPath(subject, "Tag"), 42); var trigger = new StateTrigger() { IsActive = false }; var vs = new VisualState { Setters = { SUT }, StateTriggers = { trigger } }; var group = new VisualStateGroup(); group.States.Add(vs); VisualStateManager.SetVisualStateGroups(g, new List <VisualStateGroup>() { group }); Assert.IsNull(innerGrid); trigger.IsActive = true; Assert.IsNotNull(innerGrid); Assert.AreEqual(42, innerGrid.Tag); }
void StartStandard() { // App Application.targetFrameRate = 60; // Init ScoreAdder scoreAdder = new ScoreAdder(); StateTrigger stateTrigger = new StateTrigger(); CursorStandard cursorStandard = new CursorStandard(); RandomProvider randomProvider = new RandomProvider(); Resetter resetter = new Resetter(); ParentProvider parentProvider = new ParentProvider(); // Connect inputSender.AddSpawnReceiver(spawnerStandard.GetSpawnReceiver()); inputSender.SetRandomProvider(randomProvider); inputSender.AddAudioReceiver(audioPlayer.GetAudioReceiver()); inputSenderConstant.AddSpawnReceiver(cursorStandard.GetSpawnReceiver()); inputSenderConstant.SetRandomProvider(randomProvider); spawnerStandard.ReceiveFactory(fruitFactoryStandard); cursorStandard.ReceiveFactory(fruitFactoryStandard); spawnerStandard.AddScoreReceiver(scoreAdder.GetScoreReceiver()); spawnerStandard.AddAudioReceiver(audioPlayer.GetAudioReceiver()); spawnerStandard.AddStateReceiver(stateTrigger.GetStateReceiver()); spawnerStandard.SetParentProvider(parentProvider); scoreAdder.AddScoreReceiver(outputRenderer.GetScoreReceiver()); stateTrigger.AddStateReceiver(outputRenderer.GetStateReceiver()); preFailer.AddRedReceiver(redder.GetRedReceiver()); failer.AddRedReceiver(redder.GetRedReceiver()); failer.AddStateReceiver(stateTrigger.GetStateReceiver()); outputRenderer.SetResetter(resetter); resetter.AddResetable(inputSender); resetter.AddResetable(inputSenderConstant); resetter.AddResetable(fruitFactoryStandard); resetter.AddResetable(outputRenderer); resetter.AddResetable(preFailer); resetter.AddResetable(failer); resetter.AddResetable(redder); resetter.AddResetable(scoreAdder); resetter.AddResetable(spawnerStandard); resetter.AddResetable(stateTrigger); resetter.AddResetable(cursorStandard); resetter.AddResetable(randomProvider); resetter.AddResetable(parentProvider); }
public void CheckTriggers(StateMachine stateMachine, StateTrigger trigger) { foreach (ActionUsage action in Actions) { if (action.Trigger != trigger || !action.Logic) { continue; } action.Logic.StateMachine = stateMachine; action.Logic.OnUpdate(); } foreach (StateTransition transitionNode in Transitions) { transitionNode.CheckDecisionsTriggers(stateMachine, trigger); } }
public void EnterCircle(StateTrigger t) { curState.EnterCircle (t); }
/// <summary> /// Resume the workflow until it becomes idle with any bookmark /// </summary> /// <param name="trigger"> The name of the bookmark </param> public void Resume(StateTrigger trigger) { this.Resume(trigger.ToString()); }
/// <summary> /// The inspector has been enabled. /// </summary> protected virtual void OnEnable() { m_StateTrigger = target as StateTrigger; }
protected override void OnCreate(Bundle savedInstanceState) { Log.Debug(TAG, "OnCreate"); base.OnCreate(savedInstanceState); lock (DatabaseContext.DbLocker) { using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase)) { scriptHardware = db.Scripts.Include(x => x.Commands).Include(x => x.TriggerPort).FirstOrDefault(x => x.Id == Intent.Extras.GetInt(nameof(ScriptModel.Id), 0)); } } TopLayout = FindViewById <LinearLayoutCompat>(Resource.Id.script_top_layout); FooterLayout = FindViewById <LinearLayoutCompat>(Resource.Id.script_footer_layout); CardTitle.Text = GetText(Resource.String.script_edit_title); CardSubtitle.Text = GetText(Resource.String.script_edit_subtitle); DeleteScript = new AppCompatButton(this) { Text = GetText(Resource.String.delete_title) }; DeleteScript.SetTextColor(Color.DarkRed); DeleteScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); FooterLayout.AddView(DeleteScript); ButtonOk.Tag = scriptHardware.Id; CommandsScript = new AppCompatButton(this) { Text = $"{GetString(Resource.String.commands_title)} ({scriptHardware.Commands.Count})" }; CommandsScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); TopLayout.AddView(CommandsScript); StartScript = new AppCompatButton(this) { Text = GetText(Resource.String.run_the_script_title), Enabled = scriptHardware.Commands.Count > 0 }; StartScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); TopLayout.AddView(StartScript); ScriptName.Text = scriptHardware.Name; if (scriptHardware.TriggerPort != null) { AutorunTrigger.Checked = true; PortTrigger.Enabled = true; HardwareTrigger.Enabled = true; StateTrigger.Enabled = true; int indexPosition = Hardwares.Keys.ToList().IndexOf(scriptHardware.TriggerPort.HardwareId); HardwareTrigger.SetSelection(indexPosition); PortsList_UpdateSpinner(scriptHardware.TriggerPort.HardwareId, ref PortTrigger, scriptHardware.TriggerPort.Id);//, ref Ports string[] statuses = Resources.GetStringArray(Resource.Array.script_trigger_port_states_array); if (scriptHardware.TriggerPortState == true) { indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_on)); } else if (scriptHardware.TriggerPortState == false) { indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_off)); } else { indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_switch)); } StateTrigger.SetSelection(indexPosition); } }
public override void EnterBox(StateTrigger t) { Messenger.instance.KillMessage(m); exit = true; }
public virtual void EnterCircle(StateTrigger t) { }
public override void EnterBox(StateTrigger t) { Messenger.instance.KillMessage (m); Run (); }
public void EnterCircle(StateTrigger t) { curState.EnterCircle(t); }
/// <summary> /// Determines if a trigger can be executed /// </summary> /// <param name="trigger"> The trigger </param> /// <returns> true if the trigger can be executed </returns> public bool CanExecute(StateTrigger trigger) { return this.Transitions != null && this.Transitions.Any(t => t == trigger.ToString()); }
public void EnterBox(StateTrigger t) { curState.EnterBox (t); }
public virtual void EnterCircle(StateTrigger t) {}
public override void EnterBox(StateTrigger t) { tControl.TutorialDone(); }
public static StateTrigger IsActive(this StateTrigger trigger, bool isActive) { trigger.IsActive = isActive; return(trigger); }
public override void EnterBox(StateTrigger t) { Messenger.instance.KillMessage (m); exit = true; }
public virtual void EnterBox(StateTrigger t) {}
/// <summary> /// Executes a trigger on the state machine /// </summary> /// <param name="trigger"> The trigger </param> private void ExecuteTrigger(StateTrigger trigger) { this.Model.ResumeBookmark(trigger); }
public override void EnterBox(StateTrigger t) { Messenger.instance.KillMessage(m); Run(); }
public void EnterBox(StateTrigger t) { curState.EnterBox(t); }
public virtual void EnterBox(StateTrigger t) { }
/// <summary> /// Determines if a trigger can execute /// </summary> /// <param name="trigger"> The trigger </param> /// <returns> true if it can execute, false if not </returns> private bool CanExecuteTrigger(StateTrigger trigger) { return this.Model.CanExecute(trigger); }
/// <summary> /// Resume a bookmark /// </summary> /// <param name="trigger"> The trigger to resume </param> public void ResumeBookmark(StateTrigger trigger) { this.ResumeBookmark(trigger.ToString()); }