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

public class RadioButton : MonoBehaviour
{

	private Button[] radioButtons;
    private Button[] prayerButtons;

    void Start()
	{
		radioButtons = GetComponentsInChildren<Button>();
        prayerButtons = GameObject.Find("NormalButton").GetComponentsInChildren<Button>();
        enabled = false;
	}

	public void radioButtonLogic(Button sender)
	{
		sender.interactable = false;
		for (int i = 0; i<radioButtons.Length; i++)
		{
			if(radioButtons[i] != sender)
			{
				radioButtons[i].interactable = false;
			}
		}
        for (int i = 0; i < prayerButtons.Length; i++)
        {
            prayerButtons[i].interactable = false;
        }
        StartCoroutine(ReactivateButtons(sender));
	}

    private IEnumerator ReactivateButtons(Button sender)
    {
        yield return new WaitForSeconds(10.0f);
        for (int i = 0; i < radioButtons.Length; i++)
        {
            if (radioButtons[i] != sender)
            {
                radioButtons[i].interactable = true;
            }
        }
        while (!GameMgr.instance.CanClickIcons())
        {
            yield return new WaitForSeconds(0.1f);
        }
        for (int i = 0; i < prayerButtons.Length; i++)
        {
            prayerButtons[i].interactable = true;
        }
    }
}
