using System.Collections;
using UnityEngine;

namespace Wizard;

public class SpotCardExchangeDialog : MonoBehaviour
{
	private const int EXCHANGE_DIALOG_DEPTH = 900;

	[SerializeField]
	private SpotCardExchange _spotCardExchangeOriginal;

	public void CreateSpotCardExchangeDialog()
	{
		if (FirstTips.IsFirstTipsOpen(FirstTips.TipsType.SpotCardExchange))
		{
			CreateDialogWithFirstTips();
		}
		else
		{
			CreateDialog();
		}
	}

	private void CreateDialog()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetTitleLabel(Data.SystemText.Get("Shop_0149"));
		dialogBase.SetLayer("MyPage");
		dialogBase.SetPanelDepth(900);
		SpotCardExchange spotCardExchange = Object.Instantiate(_spotCardExchangeOriginal);
		dialogBase.SetObj(spotCardExchange.gameObject);
		spotCardExchange.Init();
	}

	private void CreateDialogWithFirstTips()
	{
		UIManager.GetInstance().StartFirstTips(FirstTips.TipsType.SpotCardExchange);
		StartCoroutine(CreateDialogAfterOpenFirstTips());
	}

	private IEnumerator CreateDialogAfterOpenFirstTips()
	{
		UIManager uiMgr = UIManager.GetInstance();
		while (!uiMgr.IsActiveFirstTips())
		{
			yield return null;
		}
		yield return new WaitForSeconds(0.5f);
		CreateDialog();
	}
}
