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

namespace ToadieTechnika.GGJ2018Game
{
    public enum Panels
    { 
        Menu,
        Gameplay,
        Finish
    }

    public class PanelsController : GenericSingleton<PanelsController>
    {
        [SerializeField]
        Camera m_CameraComponent;

        [SerializeField]
        List<GameObject> m_Panels = new List<GameObject>();
        Panels m_CurrentPanel;

        [Space]
        [SerializeField]
        TransitionScript m_TransitionController;

        #region Functions
        public void ResetPanels()
        {
            //Reset Panels
            m_Panels.Clear();

            for (int i = 0; i < transform.childCount - 1; i++)
            {
                m_Panels.Add(transform.GetChild(i).gameObject);
                m_Panels[i].SetActive(false);
            }

            m_Panels[0].SetActive(true);
        }

        public void ChangePanel(Panels _WhichPanel)
        {
            m_Panels[(int)m_CurrentPanel].SetActive(false);
            m_CurrentPanel = _WhichPanel;
            m_Panels[(int)m_CurrentPanel].SetActive(true);

            #region Camera bkg color
            Color _UseColor;
            string _HexCode = string.Empty;
            switch (_WhichPanel)
            {
                case Panels.Gameplay:
                    _HexCode = "#523CA8FF";
                    break;
                default:
                    _HexCode = "#B7C3D3FF";
                    break;
            }

            ColorUtility.TryParseHtmlString(_HexCode, out _UseColor);
            m_CameraComponent.backgroundColor = _UseColor;
            #endregion
        }
        #endregion
    }
}
