Example #1
0
        private void CheckMouseInput()
        {
            if (Input.GetMouseButton(0))
            {
                var cameraOffset = _cameraView.GetCameraOffset();

                var playerPosition =
                    Camera.main.ScreenToWorldPoint(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f)) +
                    cameraOffset;
                var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                var distance = new Vector3(Mathf.Abs(mousePosition.x - playerPosition.x),
                                           Mathf.Abs(mousePosition.y - playerPosition.y), 0);

                if (distance.x < distance.y)
                {
                    CurrentMovingDirection =
                        mousePosition.y > playerPosition.y ? InputDirection.Up : InputDirection.Down;
                }
                else if (distance.x > distance.y)
                {
                    CurrentMovingDirection =
                        mousePosition.x > playerPosition.x ? InputDirection.Right : InputDirection.Left;
                }
            }
        }