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

public class ScreenManager : MonoBehaviour {
	
	public static ScreenManager Instance;

	[SerializeField] BaseScreen[] screenList;

	void Awake() {
		if (ScreenManager.Instance != null)
		{
			Destroy(this.gameObject);
			return;
		}

		ScreenManager.Instance = this;

		foreach(BaseScreen oldScreen in screenList)
		{
			Hide(oldScreen.name);
		}

		Show("TitlePanel");
	}


	public void Hide(string screenTitle)
	{
		foreach (BaseScreen bs in this.screenList)
		{
			if (bs.name == screenTitle)
			{
				bs.gameObject.SetActive(false);
			}
		}
	}
	public void Show(string screenTitle)
	{
		foreach(BaseScreen oldScreen in screenList)
		{
			Hide(oldScreen.name);
		}
		foreach (BaseScreen bs in this.screenList)
		{
			if (bs.name == screenTitle)
			{
				bs.gameObject.SetActive(true);
			}
		}
	}
}
