Ejemplo n.º 1
0
    private void GenerateInputs(bool useDefault)
    {
        if (configHandler.ContainsSection("Input"))
        {
            if (configHandler.GetKeysSectionCount("Input") > inputMapper.inputMap.Count)
            {
                configHandler.RemoveSection("Input");
            }
        }

        foreach (var iMap in inputMapper.inputMap)
        {
            GameObject InputObject = Instantiate(inputObject);
            Text       InputText   = InputObject.transform.GetChild(0).GetComponent <Text>();
            Button     InputButton = InputObject.transform.GetChild(1).GetComponent <Button>();
            string     InputName   = iMap.InputName;
            KeyCode    InputKey    = iMap.DefaultKey;

            InputObject.transform.SetParent(inputsContent);
            InputObject.transform.localScale = new Vector3(1, 1, 1);
            InputObject.name = InputName;
            InputText.text   = InputName.ToUpper();

            if (useDefault)
            {
                InputButton.transform.GetChild(0).GetComponent <Text>().text = InputKey.ToString();
                configHandler.Serialize("Input", InputName, InputKey.ToString());
            }
            else
            {
                KeyCode DeserializedKey = KeyCode.None;

                if (configHandler.ContainsSectionKey("Input", InputName))
                {
                    DeserializedKey = Parser.Convert <KeyCode>(configHandler.Deserialize("Input", InputName));
                }

                if (inputMapper.RewriteConfig)
                {
                    if (DeserializedKey != InputKey)
                    {
                        configHandler.Serialize("Input", InputName, InputKey.ToString());
                    }
                    else
                    {
                        InputKey = DeserializedKey;
                    }
                }
                else
                {
                    InputKey = DeserializedKey;
                }

                InputButton.transform.GetChild(0).GetComponent <Text>().text = InputKey.ToString();
            }

            InputButton.onClick.AddListener(delegate { Rebind(InputName); });
            InputsList.Add(new InputMap(InputName, InputKey, InputButton));
        }
    }
Ejemplo n.º 2
0
 void LoadInputsToList()
 {
     for (int i = 0; i < controlsHelper.InputsList.Count; i++)
     {
         string value = configHandler.Deserialize("Input", controlsHelper.InputsList[i].Input);
         InputKeysCache.Add(value);
     }
 }
Ejemplo n.º 3
0
 void Update()
 {
     if (configHandler.ContainsSection("Game") && configHandler.ContainsSectionKey("Game", "Volume"))
     {
         AudioListener.volume = float.Parse(configHandler.Deserialize("Game", "Volume"));
     }
 }
Ejemplo n.º 4
0
    void Update()
    {
        if (configHandler && configHandler.ContainsSection("Game") && configHandler.ContainsSectionKey("Game", "Sensitivity"))
        {
            float sensitivity = float.Parse(configHandler.Deserialize("Game", "Sensitivity"));
            if (!(sensitivity == 0))
            {
                if (!(sensitivityX == 0))
                {
                    sensitivityX = sensitivity;
                }
                if (!(sensitivityY == 0))
                {
                    sensitivityY = sensitivity;
                }
            }
        }

        if (Cursor.lockState == CursorLockMode.None)
        {
            return;
        }

        if (axes == RotationAxes.MouseXAndY)
        {
            // Read the mouse input axis
            rotationX += (Input.GetAxis("Mouse X") * sensitivityX / 30 * cmra.GetComponent <Camera>().fieldOfView + offsetX);
            rotationY += (Input.GetAxis("Mouse Y") * sensitivityY / 30 * cmra.GetComponent <Camera>().fieldOfView + offsetY);

            rotationX = ClampAngle(rotationX, minimumX, maximumX);
            rotationY = ClampAngle(rotationY, minimumY, maximumY);

            Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
            Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, Vector3.left);

            player.transform.localRotation = playerOriginalRotation * xQuaternion;
            transform.localRotation        = originalRotation * yQuaternion;
        }
        else if (axes == RotationAxes.MouseX)
        {
            rotationX += (Input.GetAxis("Mouse X") * sensitivityX / 60 * cmra.GetComponent <Camera>().fieldOfView + offsetX);
            rotationX  = ClampAngle(rotationX, minimumX, maximumX);

            Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
            transform.localRotation = originalRotation * xQuaternion;
        }
        else
        {
            rotationY += (Input.GetAxis("Mouse Y") * sensitivityY / 60 * cmra.GetComponent <Camera>().fieldOfView + offsetY);
            rotationY  = ClampAngle(rotationY, minimumY, maximumY);

            Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, Vector3.left);
            transform.localRotation = originalRotation * yQuaternion;
        }
        offsetY = 0F;
        offsetX = 0F;
    }
Ejemplo n.º 5
0
    void Update()
    {
        if (configHandler.GetKeysCount() > 0 && !isSet)
        {
            useKey = Parser.Convert <KeyCode>(configHandler.Deserialize("Input", "Use"));
            isSet  = true;
        }

        if (Input.GetKeyDown(useKey) && !isPressed)
        {
            Debug.Log("Use Key Pressed!");
            isPressed = true;
        }
        else if (isPressed)
        {
            isPressed = false;
        }
    }
Ejemplo n.º 6
0
    private void DeserializeSettings(bool Apply)
    {
        GrainToggle.isOn      = configHandler.Deserialize <bool>("Graphic", "PostProcessing_Grain");
        BloomToggle.isOn      = configHandler.Deserialize <bool>("Graphic", "PostProcessing_Bloom");
        MotionBlurToggle.isOn = configHandler.Deserialize <bool>("Graphic", "PostProcessing_MotionBlur");
        AmbientOccToggle.isOn = configHandler.Deserialize <bool>("Graphic", "PostProcessing_AmbientOcclusion");

        QualityLevel                 = configHandler.Deserialize <int>("Graphic", "GraphicQuality");
        QualityDropdown.value        = QualityLevel;
        AntialiasingLevel            = configHandler.Deserialize <int>("Graphic", "Antialiasing");
        AntialiasingDropdown.value   = AntialiasingLevel;
        AnisotropicLevel             = configHandler.Deserialize <int>("Graphic", "Anisotropic");
        AnisotropicDropdown.value    = AnisotropicLevel;
        TextureQualityLevel          = configHandler.Deserialize <int>("Graphic", "TextureQuality");
        TextureQualityDropdown.value = TextureQualityLevel;
        SkinWeightsLevel             = configHandler.Deserialize <int>("Graphic", "SkinWeight");
        SkinWeightsDropdown.value    = SkinWeightsLevel;
        VSyncLevel                     = configHandler.Deserialize <int>("Graphic", "VSync");
        VSyncDropdown.value            = VSyncLevel;
        ShadowResolutionLevel          = configHandler.Deserialize <int>("Graphic", "ShadowResolution");
        ShadowResolutionDropdown.value = ShadowResolutionLevel;
        ShadowQualityLevel             = configHandler.Deserialize <int>("Graphic", "ShadowQuality");
        ShadowQualityDropdown.value    = ShadowQualityLevel;
        ShadowCascadesLevel            = configHandler.Deserialize <int>("Graphic", "ShadowCascades");
        ShadowCascadesDropdown.value   = ShadowCascadesLevel;
        ShadowProjecionLevel           = configHandler.Deserialize <int>("Graphic", "ShadowProjecion");
        ShadowProjecionDropdown.value  = ShadowProjecionLevel;
        ShadowDistanceSlider.value     = configHandler.Deserialize <int>("Graphic", "ShadowDistance");

        VolumeSlider.value      = configHandler.Deserialize <float>("Game", "Volume");
        SensitivitySlider.value = configHandler.Deserialize <float>("Game", "Sensitivity");

        ApplyGraphic(Apply);

        isLoaded = true;
    }
Ejemplo n.º 7
0
    void Update()
    {
        transform.SetSiblingIndex(0);

        if (inputManager.HasInputs())
        {
            UseKey       = inputManager.GetInput("Use");
            GrabKey      = inputManager.GetInput("Pickup");
            ThrowKey     = inputManager.GetInput("Throw");
            RotateKey    = inputManager.GetInput("Fire");
            CursorKey    = inputManager.GetInput("Zoom");
            InventoryKey = inputManager.GetInput("Inventory");
        }

        if (configHandler.ContainsSectionKey("Game", "Volume"))
        {
            float volume = float.Parse(configHandler.Deserialize("Game", "Volume"));
            AudioListener.volume = volume;
        }

        if (!uiInteractive)
        {
            return;
        }

        if (Input.GetKeyDown(ShowPauseMenuKey) && !isPressed && !antiSpam)
        {
            isPressed = true;
            PauseGamePanel.SetActive(!PauseGamePanel.activeSelf);
            MainGamePanel.SetActive(!MainGamePanel.activeSelf);

            StartCoroutine(AntiPauseSpam());

            if (useGreyscale)
            {
                if (!greyscaleIn)
                {
                    GreyscaleScreen(true);
                }
                else if (!greyscaleOut)
                {
                    GreyscaleScreen(false);
                }
            }

            isPaused = !isPaused;
        }
        else if (isPressed)
        {
            isPressed = false;
        }

        if (PauseGamePanel.activeSelf && isPaused && isPressed)
        {
            Crosshair.enabled = false;
            LockPlayerControls(false, false, true, 3, true);
            scriptManager.GetScript <PlayerFunctions>().enabled = false;
            GetComponent <FloatingIconManager>().SetAllIconsVisible(false);
            if (reallyPause)
            {
                foreach (var PauseEvent in PauseEvents)
                {
                    PauseEvent.OnPauseEvent(true);
                }

                Time.timeScale = 0;
            }
        }
        else if (isPressed)
        {
            Crosshair.enabled = true;
            LockPlayerControls(true, true, false, 3, false);
            scriptManager.GetScript <PlayerFunctions>().enabled = true;
            GetComponent <FloatingIconManager>().SetAllIconsVisible(true);
            if (TabButtonPanel.activeSelf)
            {
                TabButtonPanel.SetActive(false);
            }
            if (reallyPause)
            {
                foreach (var PauseEvent in PauseEvents)
                {
                    PauseEvent.OnPauseEvent(false);
                }

                Time.timeScale = 1;
            }
        }

        if (Input.GetKeyDown(InventoryKey) && !isPressed && !isPaused && !isOverlapping)
        {
            isPressed = true;
            TabButtonPanel.SetActive(!TabButtonPanel.activeSelf);
        }
        else if (isPressed)
        {
            isPressed = false;
        }

        NotificationsPanel.SetActive(!TabButtonPanel.activeSelf);

        if (TabButtonPanel.activeSelf && isPressed)
        {
            Crosshair.enabled = false;
            GetComponent <FloatingIconManager>().SetAllIconsVisible(false);
            LockPlayerControls(false, false, true, 3, true);
            HideSprites(hideType.Interact);
            HideSprites(hideType.Grab);
            HideSprites(hideType.Examine);
        }
        else if (isPressed)
        {
            Crosshair.enabled = true;
            LockPlayerControls(true, true, false, 3, false);
            GetComponent <FloatingIconManager>().SetAllIconsVisible(true);
        }

        LockScript <ExamineManager>(!TabButtonPanel.activeSelf);

        if (Notifications.Count > 3)
        {
            Destroy(Notifications[0]);
        }

        Notifications.RemoveAll(GameObject => GameObject == null);

        if (greyscale && colorGrading)
        {
            if (greyscaleIn)
            {
                if (colorGrading.saturation.value > -99)
                {
                    colorGrading.saturation.value -= Time.fixedDeltaTime * (greyscaleFadeSpeed * 20);
                }
                else if (colorGrading.saturation <= -99)
                {
                    colorGrading.saturation.Override(-100);
                }
            }

            if (greyscaleOut)
            {
                if (colorGrading.saturation.value < -1)
                {
                    colorGrading.saturation.value += Time.fixedDeltaTime * (greyscaleFadeSpeed * 20);
                }
                else if (colorGrading.saturation >= -1)
                {
                    colorGrading.saturation.Override(0);
                }
            }
        }
    }
Ejemplo n.º 8
0
    void Update()
    {
        HintText.gameObject.GetComponent <CanvasRenderer>().SetAlpha(fadeHint);

        if (inputManager.HasInputs())
        {
            GrabKey      = inputManager.GetInput("Pickup").ToString();
            ThrowKey     = inputManager.GetInput("Throw").ToString();
            RotateKey    = inputManager.GetInput("Fire").ToString();
            InventoryKey = inputManager.GetInput("Inventory");
        }

        if (configHandler.ContainsSectionKey("Game", "Volume"))
        {
            float volume = float.Parse(configHandler.Deserialize("Game", "Volume"));
            AudioListener.volume = volume;
        }

        //Fade Out Hint
        if (fadeHint > 0 && startFadeHint)
        {
            fadeHint -= Time.deltaTime;
        }
        else
        {
            startFadeHint = false;
        }

        if (!uiInteractive)
        {
            return;
        }

        if (Input.GetKeyDown(ShowPauseMenuKey) && !isPressed)
        {
            isPressed = true;
            PauseGamePanel.SetActive(!PauseGamePanel.activeSelf);
            MainGamePanel.SetActive(!MainGamePanel.activeSelf);

            if (useGreyscale)
            {
                StartCoroutine(Greyscale());
            }

            isPaused = !isPaused;
        }
        else if (isPressed)
        {
            isPressed = false;
        }

        if (PauseGamePanel.activeSelf && isPaused && isPressed)
        {
            Crosshair.enabled = false;
            LockStates(true, true, true, true, 3);
            scriptManager.GetScript <PlayerFunctions>().enabled = false;
            if (reallyPause)
            {
                Time.timeScale = 0;
            }
        }
        else if (isPressed)
        {
            Crosshair.enabled = true;
            LockStates(false, true, true, true, 3);
            scriptManager.GetScript <PlayerFunctions>().enabled = true;
            if (TabButtonPanel.activeSelf)
            {
                TabButtonPanel.SetActive(false);
            }
            if (reallyPause)
            {
                Time.timeScale = 1;
            }
        }

        if (Input.GetKeyDown(InventoryKey) && !isPressed && !isPaused && !isOverlapping)
        {
            isPressed = true;
            TabButtonPanel.SetActive(!TabButtonPanel.activeSelf);
        }
        else if (isPressed)
        {
            isPressed = false;
        }

        if (TabButtonPanel.activeSelf && isPressed)
        {
            Crosshair.enabled = false;
            LockStates(true, true, true, true, 0);
            HideSprites(spriteType.Interact);
            HideSprites(spriteType.Grab);
            HideSprites(spriteType.Examine);
        }
        else if (isPressed)
        {
            Crosshair.enabled = true;
            LockStates(false, true, true, true, 0);
        }

        if (Notifications.Count > 3)
        {
            Destroy(Notifications[0]);
            Notifications.RemoveAll(GameObject => GameObject == null);
        }

        processingProfile.colorGrading.settings = colorGrading;
    }