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

public class GameManager : MonoBehaviour
{
    public static GameManager instance;
    public DialogSystem dialog;
    public DayCycle day;
    public DevianceController devianceController;
    public GameObject itemsParent;
    public SoundController soundController;

    public List<string> inventory = new List<string>() {};
    private void Awake() {
        if (instance != null) {
            Destroy(gameObject);
        } else {
            instance = this;
        }

        foreach(Transform transform in itemsParent.transform) {
            transform.gameObject.SetActive(true);
            transform.gameObject.GetComponent<Image>().color = new Color(1, 1, 1, 0);
        }
    }

    void Start() {
        soundController.ToggleSoundPlayOnLoop("BarAmbiance");
        soundController.ToggleSoundPlayOnLoop("FranceBardMusic");
    }

    void Update() {
        
    }

    public void ToggleGameObjectActive(GameObject gameObject) {
        gameObject.SetActive(!gameObject.activeSelf);
    }

    public void HideGameObjectActive(string gameObjectName) {
        GameObject obj = GetObject(gameObjectName);
        if (obj == null) return;
        obj.GetComponent<Image>().color = new Color(1, 1, 1, 0);
    }

    public void ShowGameObjectActive(string gameObjectName) {
        GameObject obj = GetObject(gameObjectName);
        if (obj == null) return;
        obj.GetComponent<Image>().color = new Color(1, 1, 1, 1);
    }

    public GameObject GetObject(string objName) {
        foreach(Transform transform in itemsParent.transform) {
            if (transform.gameObject.name.ToLower() == objName.ToLower()) {
                return transform.gameObject;
            }
        }
        return null;
    }
}
