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

namespace DuckHunter
{
    public class DebugUI : MonoBehaviour
    {
        [SerializeField] Button btnSwitch;
        [SerializeField] GameObject debugBox;
        [SerializeField] Text textA;
        [SerializeField] Slider sliderA;
        [SerializeField] Text textB;
        [SerializeField] Slider sliderB;

        public static DebugUI Instance;

        void Awake()
        {
            if (Instance)
            {
                Destroy(gameObject);
                return;
            }
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }

        void Start()
        {
            debugBox.SetActive(false);
            btnSwitch.onClick.AddListener(() => debugBox.SetActive(!debugBox.activeSelf));
            sliderA.onValueChanged.AddListener((v) =>
            {
                int finalValue = (int)v;
                GameManager.DefaultLevel = finalValue;
                textA.text = $"下次从{finalValue}关开始游戏";
            });
            sliderB.onValueChanged.AddListener((v) =>
            {
                int finalValue = (int)v;
                Time.timeScale = finalValue;
                textB.text = $"游戏运行速度：{finalValue}";
            });
        }

        public void Debug9AxisCanNotMove()
        {
            Debug.Log("9轴动不了时打印");
            string accStr = PlayerPrefs.GetString("AccIdentity0", "");
            Debug.Log("AccIdentity0:" + accStr);
            string magStr = PlayerPrefs.GetString("MagIdentity0", "");
            Debug.Log("MagIdentity0:" + magStr);
        }
    }
}
