예제 #1
0
 private void OnMouseDown()
 {
     if (OnLeftPressed != null && left)
     {
         OnLeftPressed();
     }
     else
     {
         OnRightPressed?.Invoke();
     }
 }
예제 #2
0
    private void Update()
    {
        if (Input.GetKey("a"))
        {
            OnLeftPressed?.Invoke();
        }

        if (Input.GetKey("d"))
        {
            OnRightPressed?.Invoke();
        }
    }
예제 #3
0
    private void CheckInput()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow)) // checking for input of specific key
        {
            OnLeftPressed.Invoke(MoveSide.Left);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            OnRightPressed.Invoke(MoveSide.Right);
        }

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            OnUpPressed.Invoke();
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            OnDownPressed.Invoke();
        }
    }
        /// <summary>
        /// Checks to see whether the attached base object's collider is pressed and if so triggers the appropriate event
        /// </summary>
        /// <param name="elapsedGameTime"></param>
        /// <param name="mousePosition"></param>
        public override void HandleInput(float elapsedGameTime, Vector2 mousePosition)
        {
            base.HandleInput(elapsedGameTime, mousePosition);

            DebugUtils.AssertNotNull(AttachedBaseObject.Collider);

            if (AttachedBaseObject.Collider.IsPressed)
            {
                Debug.Assert(OnLeftPressed != null && OnMiddlePressed != null && OnRightPressed != null);

                if (OnLeftPressed != null &&
                    InputManager.Instance.CheckInputEvent(InputManager.ScreenPressed, new object[] { MouseButton.kLeftButton }))
                {
                    OnLeftPressed.Invoke(AttachedBaseObject);
                }
                else if (OnMiddlePressed != null &&
                         InputManager.Instance.CheckInputEvent(InputManager.ScreenPressed, new object[] { MouseButton.kMiddleButton }))
                {
                    OnMiddlePressed.Invoke(AttachedBaseObject);
                }
                else if (OnRightPressed != null &&
                         InputManager.Instance.CheckInputEvent(InputManager.ScreenPressed, new object[] { MouseButton.kRightButton }))
                {
                    OnRightPressed.Invoke(AttachedBaseObject);
                }
            }
            else
            {
                if (PressedLastFrame)
                {
                    OnReleased.Invoke(AttachedBaseObject);
                }
            }

            PressedLastFrame = AttachedBaseObject.Collider.IsPressed;
        }
        public void StartListerning()
        {
            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                if (key.Key.Equals(ConsoleKey.LeftArrow))
                {
                    OnLeftPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.RightArrow))
                {
                    OnRightPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.Spacebar))
                {
                    OnSpacePressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.R))
                {
                    OnKeyRPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.Q))
                {
                    OnKeyQPressed?.Invoke(this, new EventArgs());
                }

                if (key.Key.Equals(ConsoleKey.Escape))
                {
                    OnEscPressed?.Invoke(this, new EventArgs());
                }
            }
        }
예제 #6
0
        private void NotifyRightPressed()
        {
            OnRightPressed?.Invoke();

            SayToLog("Right pressed.");
        }