Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        LaserTimer();

        // Сообщаем системе прицеливания куда направлен ствол турели, чтобы она могла передвинуть курсор
        var gunDirection = new Ray(gun.transform.position, gun.transform.forward);

        aimSystem.SetRealAim(aimSystem.AimSpherePoint(gunDirection));
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
        {
            LockedCamMode = false;
        }
        else
        {
            LockedCamMode = true;
        }


        if (LockedCamMode)
        {
            weaponController.Aim(aimSystem.AimSpherePoint(Camera.main.ScreenPointToRay(Input.mousePosition)));

            var h = Input.mousePosition.x / Screen.width;
            var v = Input.mousePosition.y / Screen.height;
            if (h < 0.25f)
            {
                cameraController.RotationUpdate(-1);
            }
            else if (h > 0.75f)
            {
                cameraController.RotationUpdate(1);
            }
            if (v < 0.2f)
            {
                cameraController.AngleUpdate(1);
            }
            else if (v > 0.8f)
            {
                cameraController.AngleUpdate(-1);
            }
        }
        else
        {
            cameraController.AngleUpdate(Input.GetAxis("Mouse Y"));
            cameraController.RotationUpdate(Input.GetAxis("Mouse X"));
        }

        UpdateAimingCursor(LockedCamMode);

        cameraController.CameraDistanceUpdate(Input.mouseScrollDelta.y);

        if (Input.GetMouseButtonDown(0))
        {
            weaponController.Shoot(gameObject);
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
    }