Пример #1
0
    private void Move()
    {
        if (global.currentScene == global.mainScene)
        {
            playerDirection = new Vector2(0.0f, 0.0f);

            Vector2 coordinate = new Vector2(0.0f, 0.0f);
            if (global.platform == true)
            {
                coordinate = FixedRadialCoordinates(moveJoystick.Coordinate());
            }

            if (global.currentScene == global.mainScene && global.tutorial == true && guardi.move == false)
            {
                return;
            }

            if (Input.GetKey(KeyCode.W) || coordinate.y > 0)
            {
                playerDirection.y = 1.0f;
            }

            if (Input.GetKey(KeyCode.A) || coordinate.x < 0)
            {
                playerDirection.x = -1.0f;
            }

            if (Input.GetKey(KeyCode.S) || coordinate.y < 0)
            {
                playerDirection.y = -1.0f;
            }

            if (Input.GetKey(KeyCode.D) || coordinate.x > 0)
            {
                playerDirection.x = 1.0f;
            }
        }
    }
Пример #2
0
    private void Look()
    {
        bool looking = false;

        if (Input.GetMouseButton(1) || global.platform == true)
        {
            Cursor.visible = false;

            if (global.platform == false) // PC
            {
                float x = Input.GetAxis("Mouse X");
                float y = Input.GetAxis("Mouse Y");

                cameraRotation.y += x * lookSpeed;
                cameraRotation.x += y * -lookSpeed;

                if (x != 0.0f || y != 0.0f)
                {
                    looking = true;
                }
                else
                {
                    looking = false;
                }
            }
            else // Mobile
            {
                Vector2 coordinate = FixedRadialCoordinates(lookJoystick.Coordinate());
                cameraRotation.y += coordinate.x * lookSpeed;
                cameraRotation.x += coordinate.y * -lookSpeed;

                if (coordinate.x != 0.0f || coordinate.y != 0.0f)
                {
                    looking = true;
                }
                else
                {
                    looking = false;
                }
            }

            if (global.currentScene == global.startScene)
            {
                cameraRotation.y             = Mathf.Clamp(cameraRotation.y, -180.0f, 0.0f);
                camera.transform.eulerAngles = new Vector3(cameraRotation.y, 270.0f, -90.0f);

                if (gui.lookTutorialOn == false && looking == true)
                {
                    gui.ShowLookTutorial();
                    menu.ShowMenu(true);
                }
            }
            else
            {
                cameraRotation.x             = Mathf.Clamp(cameraRotation.x, -90.0f, 90.0f);
                camera.transform.eulerAngles = new Vector3(cameraRotation.x, cameraRotation.y, 0.0f);

                if (global.tutorial == true && gui.lookTutorialOn == false && looking == true)
                {
                    gui.ShowLookTutorial();
                }
            }
        }
        else
        {
            Cursor.visible = true;
        }
    }