Ejemplo n.º 1
0
 protected override void LeftClick()
 {
     if (Input.GetKeyDown(keys.leftClick))
     {
         OnLeftClick?.Invoke();
     }
 }
Ejemplo n.º 2
0
 private void m_notifyIcon_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         OnLeftClick?.Invoke();
     }
 }
Ejemplo n.º 3
0
        private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            bool isSuppress = false;

            if (nCode >= 0)
            {
                switch (wParam.ToInt64())
                {
                case WM_RBUTTONUP:
                    if (OnRightClick != null)
                    {
                        isSuppress = OnRightClick.Invoke();
                    }
                    break;

                case WM_LBUTTONUP:
                    if (OnLeftClick != null)
                    {
                        isSuppress = OnLeftClick.Invoke();
                    }
                    break;
                }
            }

            if (isSuppress)
            {
                return(new IntPtr(-1));
            }
            else
            {
                return(NativeMethods.CallNextHookEx(hMouseHook, nCode, wParam, lParam));
            }
        }
Ejemplo n.º 4
0
 public void ClearLeftClickEvents()
 {
     if (OnLeftClick != null)
     {
         foreach (var d in OnLeftClick.GetInvocationList())
         {
             OnLeftClick -= (d as EventHandler);
         }
     }
 }
Ejemplo n.º 5
0
        public void Update()
        {
            float scrollWheelValue    = InputManager.CurrentMouseState.ScrollWheelValue;
            float oldScrollWheelValue = InputManager.OldMouseState.ScrollWheelValue;

            Vector2 mousePos = InputManager.MouseScreenPosition;

            if (InputManager.HasLeftClicked && !UIManager.Instance.MouseConsumedByUI)
            {
                OnLeftClick?.Invoke(this, new EventArgs());
            }

            if (InputManager.HasRightClicked)
            {
                BuildMode = false;
                ClearLeftClickEvents();
            }

            if (InputManager.IsKeyPressed(Keys.R))
            {
                GameLoop.Instance.CommitApocalypse();
            }

            if (oldScrollWheelValue > scrollWheelValue)
            {
                CameraManager.Camera.TryZoom(-0.25f);
            }
            else if (oldScrollWheelValue < scrollWheelValue)
            {
                CameraManager.Camera.TryZoom(0.25f);
            }

            float cameraSpeed = 5f;

            if (InputManager.IsKeyHeld(Keys.A))
            {
                CameraManager.Camera.MoveBy(new Vector2(-cameraSpeed, 0));
            }

            if (InputManager.IsKeyHeld(Keys.D))
            {
                CameraManager.Camera.MoveBy(new Vector2(cameraSpeed, 0));
            }

            if (InputManager.IsKeyHeld(Keys.W))
            {
                CameraManager.Camera.MoveBy(new Vector2(0, -cameraSpeed));
            }

            if (InputManager.IsKeyHeld(Keys.S))
            {
                CameraManager.Camera.MoveBy(new Vector2(0, cameraSpeed));
            }
        }
Ejemplo n.º 6
0
    public void OnPointerClick(PointerEventData eventData)
    {
        switch (eventData.button)
        {
        case PointerEventData.InputButton.Right:
            OnRightClick?.Invoke();
            break;

        case PointerEventData.InputButton.Left:
            OnLeftClick?.Invoke();
            break;
        }
    }
Ejemplo n.º 7
0
        public virtual void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (!Context.IsWorldReady || Game1.activeClickableMenu is null)
            {
                return;
            }

            int x = (int)e.Cursor.ScreenPixels.X;
            int y = (int)e.Cursor.ScreenPixels.Y;

            if (Game1.activeClickableMenu is GameMenu menu)
            {
                if (e.Button == SButton.MouseLeft || e.Button == SButton.ControllerA)
                {
                    foreach (var page in Pages)
                    {
                        if (page.Value.PageButton != null && page.Value.PageButton.isWithinBounds(x, y))
                        {
                            menu.currentTab = page.Value.pageNumber;
                            setCurrentSideTab(0);
                            page.Value.SetAsActive();
                            Game1.playSound("smallSelect");
                            page.Value.PageButton.LeftClickAction?.Invoke();
                        }
                    }

                    foreach (var v in sideTabs)
                    {
                        var page = Pages.FirstOrDefault(c => c.Value.active);
                        if (page.Value != null)
                        {
                            if (menu.currentTab >= 8 && !page.Value.active || menu.currentTab < 8 && page.Value.pageNumber != menu.currentTab)
                            {
                                continue;
                            }
                            var tab = v.Value.FirstOrDefault(c => c.containsPoint(x, y));
                            if (tab != null)
                            {
                                Game1.playSound("smallSelect");
                                this.setCurrentSideTab(Convert.ToInt32(tab.name));
                                Pages.FirstOrDefault(c => c.Value.sideTabid == this.currentSideTab).Value.SetAsActive();
                            }
                        }
                    }
                }
            }
            if (e.Button == SButton.MouseLeft)
            {
                OnLeftClick?.Invoke(this, new Coordinate(x, y));
            }
        }
Ejemplo n.º 8
0
    private void Update()
    {
        // Left Click event:
        if (Input.GetMouseButtonDown(0))
        {
            OnLeftClick?.Invoke();
        }

        // Right Click event:
        if (Input.GetMouseButtonDown(2))
        {
            OnRightClick?.Invoke();
        }
    }
Ejemplo n.º 9
0
        private void Panel_MouseClick(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
                Vector2 clickedPos = PointToClient(Cursor.Position).ToVector2();
                OnLeftClick?.Invoke(this, new LeftClickArgs(clickedPos));
                break;

            case MouseButtons.Right:
                _contextMenu.Show(Parent.PointToScreen(e.Location));
                break;
            }
            ;
        }
Ejemplo n.º 10
0
 private void  CheckLeftMouseButtonDown()
 {
     if (Input.GetMouseButtonDown(0))                                        // if we left-click
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition); // a projective ray from the point where we clicked
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 100.0f))                          // if we hit something
         {
             if (hit.transform)                                              // check if the hit exists
             {
                 OnLeftClick?.Invoke(this, new MapCoordEventArgs {
                     mapCoord = Utils.ToMapCoord(hit.point)
                 });
             }
         }
     }
 }
Ejemplo n.º 11
0
 private void ClickOrNot(MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         if (_left_up.Subtract(_left_down) < _click_threshold)
         {
             OnLeftClick?.Invoke(this, e);
         }
     }
     else if (e.ChangedButton == MouseButton.Right)
     {
         if (_right_up.Subtract(_right_down) < _click_threshold)
         {
             OnRightClick?.Invoke(this, e);
         }
     }
     _left_up    = DateTime.MaxValue;
     _left_down  = DateTime.MinValue;
     _right_up   = DateTime.MaxValue;
     _right_down = DateTime.MinValue;
 }
Ejemplo n.º 12
0
 private void StartSwipeTapDetect()
 {
     // create object to detect swipe
     swipeTapDetect = GameObject.Instantiate(Resources.Load <SwipeTapDetect>(GameUIData.SWIPE_TAP_DETECT_PREFAB_PATH));
     // subscripe finger detection
     swipeTapDetect.OnLeftSwipe += () =>
     {
         OnLeftClick?.Invoke();
     };
     swipeTapDetect.OnRightSwipe += () =>
     {
         OnRightClick?.Invoke();
     };
     swipeTapDetect.OnUpSwipe += () =>
     {
         OnUpClick?.Invoke();
     };
     swipeTapDetect.OnDownSwipe += () =>
     {
         OnDownClick?.Invoke();
     };
 }
Ejemplo n.º 13
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject[LeftChannel] != null)
            {
                StatusLeft = jObject[LeftChannel].Value <string>();
                if (StatusLeft == "click")
                {
                    OnLeftClick?.Invoke(this, new WallSwitchEventArgs(StatusLeft));
                }
                else if (StatusLeft == "double_click")
                {
                    OnLeftDoubleClick?.Invoke(this, new WallSwitchEventArgs(StatusLeft));
                }
                else if (StatusLeft == "long_click")
                {
                    OnLeftLongClick?.Invoke(this, new WallSwitchEventArgs(StatusLeft));
                }
            }

            if (jObject[RightChannel] != null)
            {
                StatusRight = jObject[RightChannel].Value <string>();
                if (StatusRight == "click")
                {
                    OnRightClick?.Invoke(this, new WallSwitchEventArgs(StatusRight));
                }
                else if (StatusRight == "double_click")
                {
                    OnRightDoubleClick?.Invoke(this, new WallSwitchEventArgs(StatusRight));
                }
                else if (StatusRight == "long_click")
                {
                    OnRightLongClick?.Invoke(this, new WallSwitchEventArgs(StatusRight));
                }
            }
        }
Ejemplo n.º 14
0
        public override void Update(Vector2 windowSize)
        {
            UpdateChildren(windowSize);

            if (Enabled && (!clicked && MouseOver(windowSize) && MouseLeftDown && !mouseDown ||
                            (ui.Input.KeyPress(Shortcut) && !ui.ignoreShortcuts)))
            {
                OnLeftClick?.Invoke(this);
            }
            if (Enabled && MouseOver(windowSize) && MouseRightClick)
            {
                OnRightClick?.Invoke(this);
            }

            if (ChangeState)
            {
                if (MouseOver(windowSize))
                {
                    if (mouseDown)
                    {
                        State = 2;
                    }
                    else
                    {
                        State = 1;
                    }
                }
                else
                {
                    State = 0;
                }
            }

            clicked = (MouseOver(windowSize) && !mouseDown && MouseLeftDown) || (ui.Input.KeyPress(Shortcut) && !ui.ignoreShortcuts);

            mouseDown = MouseLeftDown;
        }
Ejemplo n.º 15
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject[LeftChannel] != null)
            {
                if (jObject[LeftChannel].Value <string>() == "click")
                {
                    OnLeftClick?.Invoke(new EventArgs());
                }
                else if (jObject[LeftChannel].Value <string>() == "double_click")
                {
                    OnLeftDoubleClick?.Invoke(new EventArgs());
                }
                else if (jObject[LeftChannel].Value <string>() == "long_click")
                {
                    OnLeftLongClick?.Invoke(new EventArgs());
                }
            }

            if (jObject[RightChannel] != null)
            {
                if (jObject[RightChannel].Value <string>() == "click")
                {
                    OnRightClick?.Invoke(new EventArgs());
                }
                else if (jObject[RightChannel].Value <string>() == "double_click")
                {
                    OnRightDoubleClick?.Invoke(new EventArgs());
                }
                else if (jObject[RightChannel].Value <string>() == "long_click")
                {
                    OnRightLongClick?.Invoke(new EventArgs());
                }
            }
        }
Ejemplo n.º 16
0
 private void LeftClick()
 {
     OnLeftClick?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 17
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
        }

        switch (state)
        {
        case GameState.LineDraw:
            if (Input.GetMouseButton(0))
            {
                if (OnLeftClick != null)
                {
                    OnLeftClick.Invoke();
                }
            }
            if (Input.GetMouseButtonUp(0))
            {
                if (OnLeftMouseRelease != null)
                {
                    OnLeftMouseRelease.Invoke();
                }
            }
            if (Input.GetKeyDown(KeyCode.Return))
            {
                ReleasePlayer();
            }
            if (Input.GetButtonDown("Reset"))
            {
                Reset();
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                state     = GameState.Paused;
                lastState = GameState.LineDraw;
                if (PausePressed != null)
                {
                    PausePressed.Invoke(true);
                }
                else
                {
                    Debug.Log("Not subsrcibed to pause event");
                }
                Time.timeScale = 0;
            }
            break;

        case GameState.MovePlayer:
            if (Input.GetButton("Left"))
            {
                if (OnMoveLeft != null)
                {
                    OnMoveLeft.Invoke();
                }
            }
            if (Input.GetButton("Right"))
            {
                if (OnMoveRight != null)
                {
                    OnMoveRight.Invoke();
                }
            }
            if (Input.GetButtonDown("Jump"))
            {
                if (OnJump != null)
                {
                    OnJump.Invoke();
                }
            }
            if (Input.GetButtonDown("Reset"))
            {
                Reset();
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                state     = GameState.Paused;
                lastState = GameState.MovePlayer;
                if (PausePressed != null)
                {
                    PausePressed.Invoke(true);
                }
                Time.timeScale = 0;
            }
            break;

        case GameState.Paused:
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                state          = lastState;
                Time.timeScale = 1;
                if (PausePressed != null)
                {
                    PausePressed.Invoke(false);
                }
            }
            break;

        case GameState.LevelEnd:
            if (Input.GetButtonDown("Reset"))
            {
                Reset();
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                state          = GameState.Paused;
                lastState      = GameState.LevelEnd;
                Time.timeScale = 0;
                if (PausePressed != null)
                {
                    PausePressed.Invoke(true);
                }
            }
            else if (Input.anyKeyDown)
            {
                Manager <GameManager> .Instance.totalScore += Manager <UIManager> .Instance.score;
                int levelIndex = SceneManager.GetActiveScene().buildIndex;
                if (levelIndex >= SceneManager.sceneCountInBuildSettings - 1)
                {
                    Manager <GameManager> .Instance.LoadMainMenu();
                }
                else
                {
                    Manager <GameManager> .Instance.LoadNewScene(levelIndex + 1);
                }
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 18
0
 public virtual void LeftClick(UIMouseEvent evt)
 {
     OnLeftClick?.Invoke(evt, this);
     Parent?.LeftClick(evt);
 }
Ejemplo n.º 19
0
 public virtual void LeftClick(UIMouseEventArgs e)
 {
     OnLeftClick?.Invoke(this, e);
     Parent?.LeftClick(e);
 }
Ejemplo n.º 20
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            if (TBARInputs.UIAdjustmentMode.JustPressed)
            {
                TBAR.IsAdjustingUI = !TBAR.IsAdjustingUI;
            }

            if (TBARInputs.SummonStand.JustPressed && IsStandUser)
            {
                if (!PlayerStand.IsActive)
                {
                    PlayerStand.TryActivate(player);
                }

                if (player.HeldItem.GetDamageData(player).DPS > damageCaps[(int)PlayerStand.StandDamageType])
                {
                    damageCaps[(int)PlayerStand.StandDamageType] = player.HeldItem.GetDamageData(player).DPS;
                }
            }

            if (TBARInputs.OpenStandAlbum.JustPressed)
            {
                if (IsStandUser)
                {
                    UIManager.Instance.StandAlbumLayer.ToggleVisibility();
                }
            }

            if (IsStandUser)
            {
                if (TBARInputs.ComboButton1.JustPressed)
                {
                    OnInput(ComboInput.Action1);
                }

                if (TBARInputs.ComboButton2.JustPressed)
                {
                    OnInput(ComboInput.Action2);
                }

                if (TBARInputs.ComboButton3.JustPressed)
                {
                    OnInput(ComboInput.Action3);
                }

                if (HasPressedUp)
                {
                    OnInput(ComboInput.Up);
                }

                if (HasPressedDown)
                {
                    OnInput(ComboInput.Down);
                }

                if (HasPressedLeftClick)
                {
                    OnLeftClick?.Invoke(player);
                    PlayerStand.HandleImmediateInputs(player, ImmediateInput.LeftClick);
                }

                if (HasPressedRightClick)
                {
                    OnRightClick?.Invoke(player);
                    PlayerStand.HandleImmediateInputs(player, ImmediateInput.RightClick);
                }

                OldUpButtonState   = player.controlUp;
                OldDownButtonState = player.controlDown;
                OldLeftClickState  = player.controlUseItem;
                OldRightClickState = player.controlUseTile;
            }
        }