using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using cowsins;

public class ControllerSettings : MonoBehaviour
{
    public Toggle invertToggle;
    public Slider xSensitivitySlider;

    public static float xSensitivity = 30.0f;

    private PlayerMovement player => PlayerStates.instance.GetComponent<PlayerMovement>();

    void Awake()
    {
        if (PlayerStates.instance == null) {
            return;
        }
        if (player == null) {
            return;
        }
        player.controllerSensitivityX = xSensitivity;
    }

    // Start is called before the first frame update
    void OnEnable()
    {
        invertToggle.isOn = InputManager.invertedAxisY;
        xSensitivitySlider.value = InputManager.controllerSensitivityX;
    }

    public void OnInvertChange(bool invert)
    {
        InputManager.invertedAxisY = invert;
    }

    public void OnXSensitivityChange(float xSensitivity)
    {
        ControllerSettings.xSensitivity = xSensitivity;
        if(PlayerStates.instance == null) {
            return;
        }
        if(player == null) {
            return;
        }
        player.controllerSensitivityX = xSensitivity;
    }
}
