예제 #1
0
    private void Update()
    {
        Vector3 mousePosition = Input.mousePosition;
        bool    mouseValid    = (mousePosition.y <= screen.y * 1.05f && mousePosition.y >= screen.y * -0.05f &&
                                 mousePosition.x <= screen.x * 1.05f && mousePosition.x >= screen.x * -0.05f);

        if (!mouseValid)
        {
            return;
        }

        //movement
        if (mousePosition.y > screen.y * 0.95f)
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        else if (mousePosition.y < screen.y * 0.05f)
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }

        if (mousePosition.x > screen.x * 0.95f)
        {
            OnMoveInput?.Invoke(Vector3.right);
        }
        else if (mousePosition.x < screen.x * 0.05f)
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }

        //rotation
        if (Input.GetMouseButtonDown(1))
        {
            mousePositionOnRotateStart = mousePosition.x;
        }
        else if (Input.GetMouseButton(1))
        {
            if (mousePosition.x < mousePositionOnRotateStart)
            {
                OnRotateInput?.Invoke(-1f);
            }
            else if (mousePosition.x > mousePositionOnRotateStart)
            {
                OnRotateInput?.Invoke(1f);
            }
        }

        // zoom
        if (Input.mouseScrollDelta.y > 0)
        {
            OnZoomInput?.Invoke(-3f);
        }
        else if (Input.mouseScrollDelta.y < 0)
        {
            OnZoomInput?.Invoke(3f);
        }
    }
예제 #2
0
    private void Update()
    {
        movementX       = Input.GetAxis("Horizontal") * transform.right;
        movementY       = Input.GetAxis("Vertical") * transform.forward;
        _inputDirection = movementX + movementY;
        OnMoveInput?.Invoke(_inputDirection);

        _mouseInput.x = Input.GetAxis("Mouse X") * mouseSensitivity;
        _mouseInput.y = Input.GetAxis("Mouse Y") * mouseSensitivity;
        OnMouseInput?.Invoke(_mouseInput);
    }
예제 #3
0
        private void ProcessMovementInput()
        {
            _currentMoveDirection.x = Input.GetAxisRaw("Horizontal");
            _currentMoveDirection.y = Input.GetAxisRaw("Vertical");

            if (_currentMoveDirection != _lastMoveDirection)
            {
                OnMoveInput?.Invoke(_currentMoveDirection);
            }

            _lastMoveDirection = _currentMoveDirection;
        }
    private void Update()
    {
        if (Input.GetKey(KeyCode.Z))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (Input.GetKey(KeyCode.S))
        {
            OnMoveInput?.Invoke(Vector3.back);
        }
        if (Input.GetKey(KeyCode.Q))
        {
            OnMoveInput?.Invoke(Vector3.left);
        }
        if (Input.GetKey(KeyCode.D))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }
        if (Input.GetKey(KeyCode.LeftShift))
        {
            OnMoveInput?.Invoke(Vector3.up);
        }
        if (Input.GetKey(KeyCode.LeftControl))
        {
            OnMoveInput?.Invoke(Vector3.down);
        }

        if (Input.GetKey(KeyCode.A))
        {
            OnRotateInput?.Invoke(Vector2.left);
        }
        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(Vector2.right);
        }
        if (Input.GetKey(KeyCode.R))
        {
            OnRotateInput?.Invoke(Vector2.up);
        }
        if (Input.GetKey(KeyCode.F))
        {
            OnRotateInput?.Invoke(Vector2.down);
        }

        if (Input.GetKey(KeyCode.X))
        {
            OnZoomInput?.Invoke(1f);
        }
        if (Input.GetKey(KeyCode.W))
        {
            OnZoomInput?.Invoke(-1f);
        }
    }
예제 #5
0
    // Update is called once per frame
    private void Update()
    {
        if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
        {
            return;
        }

        // Handle camera pan (WASD)
        if (Input.GetKey(KeyCode.W))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }

        if (Input.GetKey(KeyCode.S))
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }

        if (Input.GetKey(KeyCode.A))
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }

        if (Input.GetKey(KeyCode.D))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        // Handle Rotation (QE)
        if (Input.GetKey(KeyCode.Q))
        {
            OnRotateInput?.Invoke(1f);
        }

        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(-1f);
        }

        // Handle Zoom (ZX)
        if (Input.GetKey(KeyCode.Z))
        {
            OnZoomInput?.Invoke(-1f);
        }

        if (Input.GetKey(KeyCode.X))
        {
            OnZoomInput?.Invoke(1f);
        }
    }
예제 #6
0
        private void Update()
        {
            var pos          = Input.mousePosition;
            var insideScreen = -_offsetX <= pos.x && pos.x <= _screen.x + _offsetX && -_offsetY <= pos.y && pos.y <= _screen.y + _offsetY;

            if (!insideScreen)
            {
                return;
            }

            if (moveOnBorder)
            {
                if (pos.x <= _offsetX)
                {
                    OnMoveInput?.Invoke(Vector3.left);
                }
                if (pos.x >= _screen.x - _offsetX)
                {
                    OnMoveInput?.Invoke(Vector3.right);
                }
                if (pos.y <= _offsetY)
                {
                    OnMoveInput?.Invoke(Vector3.down);
                }
                if (pos.y >= _screen.y - _offsetY)
                {
                    OnMoveInput?.Invoke(Vector3.up);
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                SelectionCheck();
            }

            if (Input.mouseScrollDelta.y != 0)
            {
                OnZoomInput?.Invoke(-Input.mouseScrollDelta.y);
            }

            if (Input.GetMouseButtonDown(1))
            {
                onDragStart?.Invoke(Input.mousePosition);
            }
            if (Input.GetMouseButton(1))
            {
                onDragInput?.Invoke(Input.mousePosition);
            }
        }
예제 #7
0
        private void Update()
        {
            movingVector = new Vector2(Input.GetAxis(keyHorizontalAxis), Input.GetAxis(keyVerticalAxis));

            if (movingVector.magnitude > 0)
            {
                OnMoveInput?.Invoke(movingVector);
                return;
            }

            /*
             * movingVector = new Vector2(Input.GetAxis(mouseHorizontalAxis), Input.GetAxis(mouseVerticalAxis));
             *
             * if (movingVector.magnitude > 0) OnMoveInput?.Invoke(movingVector * dragRatio);*/
        }
예제 #8
0
    // Update is called once per frame
    void Update()
    {
        //Move
        if (Input.GetKey(KeyCode.UpArrow))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        //rotate
        if (Input.GetKey(KeyCode.Q))
        {
            OnRotateInput?.Invoke(-1f);
        }
        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(1f);
        }

        //zoom
        if (Input.GetKey(KeyCode.R))
        {
            OnZoomInput?.Invoke(-1f);
        }
        if (Input.GetKey(KeyCode.T))
        {
            OnZoomInput?.Invoke(1f);
        }


        if (Input.GetKey(KeyCode.Alpha1))
        {
            OnFocusCharacter?.Invoke(true);
        }
    }
예제 #9
0
    void Update()
    {
        // Direction
        if (Input.GetKey(KeyCode.W))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }

        if (Input.GetKey(KeyCode.S))
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }

        if (Input.GetKey(KeyCode.A))
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }

        if (Input.GetKey(KeyCode.D))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        // Rotation
        if (Input.GetKey(KeyCode.Q))
        {
            OnRotateInput?.Invoke(1f);
        }

        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(-1f);
        }

        // Zoom
        if (Input.GetKey(KeyCode.Z))
        {
            OnZoomInput?.Invoke(-1f);
        }

        if (Input.GetKey(KeyCode.X))
        {
            OnZoomInput?.Invoke(1f);
        }
    }
 private void Update()
 {
     if (Input.GetKey(KeyCode.W))
     {
         OnMoveInput?.Invoke(Vector3.up);
     }
     if (Input.GetKey(KeyCode.A))
     {
         OnMoveInput?.Invoke(Vector3.left);
     }
     if (Input.GetKey(KeyCode.S))
     {
         OnMoveInput?.Invoke(Vector3.down);
     }
     if (Input.GetKey(KeyCode.D))
     {
         OnMoveInput?.Invoke(Vector3.right);
     }
 }
예제 #11
0
 private void Directions()
 {
     if (Input.GetKey(KeyCode.W))
     {
         OnMoveInput?.Invoke(Vector3.forward);
     }
     if (Input.GetKey(KeyCode.S))
     {
         OnMoveInput?.Invoke(-Vector3.forward);
     }
     if (Input.GetKey(KeyCode.A))
     {
         OnMoveInput?.Invoke(-Vector3.right);
     }
     if (Input.GetKey(KeyCode.D))
     {
         OnMoveInput?.Invoke(Vector3.right);
     }
 }
예제 #12
0
    private void Position(Vector3 mp)
    {
        if (mp.x > screen.x * 0.95f)
        {
            OnMoveInput?.Invoke(Vector3.right);
        }
        else if (mp.x < screen.x * 0.05f)
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }

        if (mp.y > screen.y * 0.95f)
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        else if (mp.y < screen.y * 0.05f)
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }
    }
    void Update()
    {
        //Camera Movement
        if (Input.GetKey(KeyCode.W))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (Input.GetKey(KeyCode.S))
        {
            OnMoveInput?.Invoke(Vector3.back);
        }
        if (Input.GetKey(KeyCode.A))
        {
            OnMoveInput?.Invoke(Vector3.left);
        }
        if (Input.GetKey(KeyCode.D))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        //Camera Rotation
        if (Input.GetKey(KeyCode.Q))
        {
            OnRotateInput?.Invoke(-1f);
        }
        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(1f);
        }

        //Camera Zoom
        if (Input.GetKey(KeyCode.Z))
        {
            OnZoomInput?.Invoke(-1f);
        }
        if (Input.GetKey(KeyCode.X))
        {
            OnZoomInput?.Invoke(1f);
        }
    }
예제 #14
0
    // Update is called once per frame
    void Update()
    {
        // Movement control transforming
        if (Input.GetKey(KeyCode.W))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (Input.GetKey(KeyCode.S))
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }
        if (Input.GetKey(KeyCode.A))
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }
        if (Input.GetKey(KeyCode.D))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        // Rotation input
        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(-1f);
        }
        if (Input.GetKey(KeyCode.Q))
        {
            OnRotateInput?.Invoke(1f);
        }

        // Zoom input
        if (Input.GetKey(KeyCode.X))
        {
            OnZoomInput?.Invoke(1f);
        }
        if (Input.GetKey(KeyCode.Z))
        {
            OnZoomInput?.Invoke(-1f);
        }
    }
예제 #15
0
    private void Update()
    {
        // check mouse is within bounds
        Vector3 mp         = Input.mousePosition;
        bool    mouseValid = mp.y <= screen.y * 1.05f && mp.y >= screen.y * -0.05f &&
                             mp.x <= screen.x * 1.05f && mp.x >= screen.x * -0.05f;

        if (!mouseValid)
        {
            return;
        }

        // pan camera if mouse is on edge of screen
        if (mp.y > screen.y * 0.995f)
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        else if (mp.y < screen.y * 0.005f)
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }

        if (mp.x > screen.x * 0.995f)
        {
            OnMoveInput?.Invoke(Vector3.right);
        }
        else if (mp.x < screen.x * 0.005f)
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }

        if (Input.mouseScrollDelta.y > 0)
        {
            OnZoomInput?.Invoke(-3f);
        }
        else if (Input.mouseScrollDelta.y < 0)
        {
            OnZoomInput?.Invoke(3f);
        }
    }
    public void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (Input.GetKey(KeyCode.S))
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }
        if (Input.GetKey(KeyCode.A))
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }
        if (Input.GetKey(KeyCode.D))
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        ToggleUI(KeyCode.T, ResearchDisplay);
        ToggleUI(KeyCode.Y, AdvisorDisplay);
        ToggleUI(KeyCode.R, RocketDisplay);
    }
    private void Update()
    {
        if (Input.GetAxis("Vertical") > 0)
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (Input.GetAxis("Horizontal") < 0)
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }
        if (Input.GetAxis("Vertical") < 0)
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }
        if (Input.GetAxis("Horizontal") > 0)
        {
            OnMoveInput?.Invoke(Vector3.right);
        }

        if (Input.GetKey(KeyCode.Q))
        {
            OnRotateInput?.Invoke(1f);
        }
        if (Input.GetKey(KeyCode.E))
        {
            OnRotateInput?.Invoke(-1f);
        }

        if (Input.GetKey(KeyCode.Z))
        {
            OnZoomInput?.Invoke(-1f);
        }
        if (Input.GetKey(KeyCode.X))
        {
            OnZoomInput?.Invoke(1f);
        }
    }
예제 #18
0
    private void Update()
    {
        Vector3 mp         = Input.mousePosition;
        bool    mouseValid = (mp.y <= screen.y * 1.05f && mp.y >= screen.y * -0.05f && mp.x <= screen.x * 1.05f && mp.x >= screen.x * -0.05f);

        if (!mouseValid)
        {
            return;
        }

        if (mp.y > screen.y * 0.95f)
        {
            OnMoveInput?.Invoke(Vector3.forward);
        }
        if (mp.y < screen.y * 0.05f)
        {
            OnMoveInput?.Invoke(-Vector3.forward);
        }
        if (mp.x > screen.x * 0.95f)
        {
            OnMoveInput?.Invoke(Vector3.right);
        }
        if (mp.x < screen.x * 0.05f)
        {
            OnMoveInput?.Invoke(-Vector3.right);
        }


        if (Input.mouseScrollDelta.y > 0)
        {
            OnZoomInput?.Invoke(-3f);
        }
        if (Input.mouseScrollDelta.y < 0)
        {
            OnZoomInput?.Invoke(3f);
        }
    }