public void CheckCondition() { if (onCondition != null && onCondition.Invoke()) { if (onAction != null) { onAction.Invoke(); } } }
private void Shoot() { Vector2 firePos = rb.position + (lookDir.normalized * 0.55f); GameObject go = Instantiate(gun.bullet, firePos, Quaternion.Euler(0, 0, angle)); go.tag = "PlayerBullet"; go.GetComponent <Rigidbody2D>().AddForce(lookDir.normalized * gun.projectileSpeed, ForceMode2D.Impulse); gun.ammoInClip--; OnChange?.Invoke(health, gun.ammo, gun.ammoInClip); }
private static ISubstance plugin_OnActionWait(ISubstance value, Guid self, string eventName) { Logger.Trace($"Start Plugin_onActionWait {self}.{eventName}"); var oSignalEvent = new ManualResetEvent(false); ISubstance result = null; var data = createOnAction(value, self, eventName); if (data != null) { _currentWait[data] = oSignalEvent; OnAction?.Invoke(data); if (!oSignalEvent.WaitOne(99 * 1000)) //This thread will block here until the reset event is sent. { _currentWait[data] = null; result = null; } else { result = (data as SandboxDataValue).Value; } } oSignalEvent.Dispose(); if (_currentWait.ContainsKey(data)) { _currentWait.TryRemove(data, out oSignalEvent); } oSignalEvent = null; Logger.Trace("End Plugin_onActionWait", result); return(result); }
private void BufferedInputController_OnJoystickPressAction() { lastInputState = GetCurrentInputState(); //Debug.Log($"buff1: {lastInputState}"); lastActionChangeTime = Time.time; OnAction?.Invoke(CurrentAction); }
public bool Flap(ControlDir dir) { if (dc.stunned || !readInput) { return(false); } int idir = dir == ControlDir.LEFT ? -1 : 1; // Physics Vector2 flap = flapVelocity; flap.x *= idir; rb2d.velocity = flap; // Art Effects Turn(idir); anim.SetBool("Flap", true); AudioSource.PlayClipAtPoint(flapSound, Camera.main.transform.position, flapVolume); if (OnFlap != null) { OnFlap.Invoke(); } chargeTimer = 0; return(true); }
private void ShootProjectile(int dir) { // Projectile Physics Vector2 spawnpointOffset = projSpawnpoint; spawnpointOffset.x *= dir; Vector2 spawnpoint = (Vector2)transform.position + spawnpointOffset; Vector2 pVelocity = projectileVelocity; pVelocity.x *= dir; GameObject projectile = Instantiate(projectilePrefab, spawnpoint, Quaternion.identity); projectile.GetComponent <Rigidbody2D>().velocity = pVelocity; // Recoil Physics Vector2 recoil = recoilVelocity; recoil.x *= -dir; rb2d.velocity = recoil; // Art Effects Discharge(); anim.SetTrigger("Fire"); AudioSource.PlayClipAtPoint(fireSound, Camera.main.transform.position, fireVolume); Turn(dir); if (OnFireball != null) { OnFireball.Invoke(); } }
void bw_DoWork() { if (OnAction != null) { OnAction.Invoke(null, null); } }
protected override void OnMouseClick(MouseEventArgs e) { if (geometry.IsPointOnBoard(e.Location)) { OnAction?.Invoke(this, geometry.PointOnBoard); } }
public VirtualMouse() { _timer.Elapsed += (object sender, ElapsedEventArgs e) => { MouseEvent[] mouseEvent = new MouseEvent[2]; switch (Button) { case MouseButton.LEFT: mouseEvent[0] = MouseEvent.MOUSEEVENTF_LEFTDOWN; mouseEvent[1] = MouseEvent.MOUSEEVENTF_LEFTUP; break; case MouseButton.MIDDLE: mouseEvent[0] = MouseEvent.MOUSEEVENTF_MIDDLEDOWN; mouseEvent[1] = MouseEvent.MOUSEEVENTF_MIDDLEUP; break; case MouseButton.RIGHT: mouseEvent[0] = MouseEvent.MOUSEEVENTF_RIGHTDOWN; mouseEvent[1] = MouseEvent.MOUSEEVENTF_RIGHTUP; break; } mouse_event(mouseEvent[0], (uint)this.Position.X, (uint)this.Position.Y, 0, UIntPtr.Zero); mouse_event(mouseEvent[1], (uint)this.Position.X, (uint)this.Position.Y, 0, UIntPtr.Zero); OnAction?.Invoke(this, new EventArgs()); }; }
private void RefreshItems() { if (boxContianer == null) { return; } BindListener(); var data = Items?.ToList(); var count = data == null ? 0 : data.Count(); var j = 0; var removeItems = new List <int>(); for (int i = 0; i < boxContianer.Children.Count; i++) { var item = boxContianer.Children[i]; if (item is AddListBoxItem) { continue; } if (j >= count) { removeItems.Add(i); j++; continue; } (item as BookListBoxItem).Source = data[j]; j++; } if (removeItems.Count > 0) { for (int i = removeItems.Count - 1; i >= 0; i--) { boxContianer.Children.RemoveAt(removeItems[i]); } } if (j >= count) { MoveActionButton(); return; } for (; j < count; j++) { var book = new BookListBoxItem(); book.Width = ItemWidth; book.Height = ItemHeight; book.OnAction += (_, item, e) => { if (e == ActionEvent.NONE) { boxMenu?.Show(GetActionPosition(book)); return; } OnAction?.Invoke(this, item, e); }; boxContianer.Children.Add(book); book.Source = data[j]; } MoveActionButton(); RefreshSize(); }
private void FireOnAction(Campaign campaign, Mod mod, CampaignThumbnailAction action) { if (OnAction != null) { OnAction.Invoke(this, new CampaignActionEventArgs(campaign, mod, action)); } }
internal protected virtual void TriggerOnAction(Component sender) { if (OnAction != null) { OnAction.Invoke(new EventArgs(sender)); } }
private static void plugin_OnAction(ISubstance value, Guid self, string eventName) { Logger.Trace($"Start Plugin_onAction {self}.{eventName}"); var data = createOnAction(value, self, eventName); OnAction?.Invoke(data); Logger.Trace("End Plugin_onAction"); }
private void OnAction_callback(NodeActionEvent action, IntPtr native_context_ref, IntPtr native_trigger_ref, IntPtr native_traverser_ref, IntPtr userdata) { if (action != NodeActionEvent.REMOVE) { OnAction?.Invoke(this, action, CreateObject(native_context_ref) as Context, CreateObject(native_trigger_ref) as NodeActionProvider, CreateObject(native_traverser_ref) as TraverseAction, userdata); } else { OnAction?.Invoke(this, action, CreateObject(native_context_ref) as Context, null, CreateObject(native_traverser_ref) as TraverseAction, native_trigger_ref); } }
public void SendAction() { if (Command != null) { Command.Execute(CommandParameter); } if (OnAction != null) { OnAction.Invoke(this, State); } }
public void InvokeAction(FrameworkElement ui, AdaptiveActionEventArgs args) { // ToggleVisibility is a renderer-handled action if (args.Action is AdaptiveToggleVisibilityAction toggleVisibilityAction) { this.ToggleVisibility(toggleVisibilityAction.TargetElements); return; } OnAction?.Invoke(ui, args); }
protected override void SetActive(bool b, Quest quest) { base.SetActive(b, quest); if (b) { onEnable.Invoke(quest); } else { onDisable.Invoke(quest); } }
private static void plugin_OnActionCallBack(ISubstance value, Guid self, string eventName, EventDelegate method) { Logger.Trace($"Start Plugin_onActionCallBack {self}.{eventName}"); var data = createOnAction(value, self, eventName); if (data != null) { _currentDeligate[data] = method; Task.Run(() => OnAction?.Invoke(data)); } Logger.Trace("End Plugin_onActionCallBack"); }
private void Init() { controls = new Controls(); controls.Enable(); controls.Player.CrouchSwitch.performed += ctx => onCrouchSwitch?.Invoke(); controls.Player.Action.performed += ctx => onAction?.Invoke(); controls.Player.SwitchCamera.performed += ctx => onSwitchCamera?.Invoke(); controls.Player.Reload.performed += ctx => onReload?.Invoke(); controls.Player.Kick.performed += ctx => onKick?.Invoke(); controls.UI.Cheats.performed += ctx => onCheats?.Invoke(); controls.UI.Pause.performed += ctx => onPause?.Invoke(); controls.UI.Hide.performed += ctx => onHide?.Invoke(); Load(); }
private void Stomp() { if (dc.Dead) { return; } var v = rb2d.velocity; v.y = stompBoost; rb2d.velocity = v; if (OnStomp != null) { OnStomp.Invoke(); } }
public void Update(UiFocusContainer container) { if (_game.Keyboard.IsKeyDownOnce(Keys.W)) { MoveToPreviousElement?.Invoke(); } else if (_game.Keyboard.IsKeyDownOnce(Keys.S)) { MoveToNextElement?.Invoke(); } if (_game.Keyboard.IsKeyDownOnce(Keys.Space) || _game.Keyboard.IsKeyDownOnce(Keys.Enter)) { OnAction?.Invoke(container.CurrentElement); } }
public void OnAnswer(bool right) { if (right) { _audioSource.clip = _audioClipRight; _audioSource.Play(); } else { _audioSource.clip = _audioClipWrong; _audioSource.Play(); } OnAction.Invoke(right); _updated = true; }
public void DoAction() { List <MoodBehaviour> moodBehaviours = ActionBehaviour.MoodBehaviours.Where(m => m.Mood == _cat.Mood).ToList(); if (moodBehaviours.Count == 0) { _cat.SetReaction("проигнорировала ваши попытки " + ActionBehaviour.ActionLabel); return; } MoodBehaviour selectedBehaviour = moodBehaviours[Random.Range(0, moodBehaviours.Count)]; _cat.SetReaction(selectedBehaviour.Reaction); _cat.SetMood(selectedBehaviour.NextMood); OnAction?.Invoke(ActionBehaviour.ActionLabel, _cat.Reaction); }
public void InvokeAction(FrameworkElement ui, AdaptiveActionEventArgs args) { // ToggleVisibility is a renderer-handled action if (args.Action is AdaptiveToggleVisibilityAction toggleVisibilityAction) { ToggleVisibility(toggleVisibilityAction.TargetElements); return; } else if (args.Action is AdaptiveShowCardAction && Config.Actions.ShowCard.ActionMode == ShowCardActionMode.Inline) { ToggleShowCardVisibility((Button)ui); return; } OnAction?.Invoke(ui, args); }
public void Update(UiFocusContainer container) { foreach (var uiElement in container.UiElements) { if (uiElement.GetBounds().Contains(_game.Mouse.X, _game.Mouse.Y)) { if (container.CurrentElement == uiElement) { if (_game.Mouse.IsLeftButtonDownOnce()) { OnAction?.Invoke(uiElement); } } else { MoveToElement?.Invoke(uiElement); } break; } } }
internal static void Action(SandboxDataValue value) { Logger.Trace("Start Action(SandboxDataValue ", value, ")"); var data = value; if (ActionConnections.TryGetValue($"{data.From}.{data.EventName}", out ActionConfig info)) { data.To = info.Events; data.Controled = info.Controled; } try { Logger.Trace("Start Action invoke", data.ToJson()); Task.Run(() => OnAction?.Invoke(data)); } catch (Exception ex) { Logger.Fatal(ex); } Logger.Trace("End Action(SandboxDataValue value, string eventName)"); }
internal IEnumerator ToggleAction() { for (int i = 0; i < ToogleAmount; i++) { action = true; if (AnimState == AnimTag.Action) { OnAction.Invoke(); //Invoke on Action SetFloatID(-1); break; } yield return(null); } action = false; //Reset Action if (AnimState != AnimTag.Action) { ActionID = -1; //Means that it could not make an action animation SetFloatID(0); } }
private void MoreBtn_Tapped(object sender, TappedRoutedEventArgs e) { OnAction?.Invoke(this, Source, ActionEvent.NONE); e.Handled = true; }
public void InvokeAction(FrameworkElement ui, AdaptiveActionEventArgs args) { OnAction?.Invoke(ui, args); }
private void MainBox_Tapped(object sender, TappedRoutedEventArgs e) { OnAction?.Invoke(this, Source, ActionEvent.CLICK); }