using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class M_UICanvas : MonoBehaviour
{
    public Text bgmTimeTxt;
    public Button btnSalt;
    public Button btnScheol;
    public Image mask;
    GameManager gm;
    public Text count;
    // Use this for initialization
    void Start()
    {
        gm = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameManager>();
        btnSalt.onClick.AddListener(delegate { SceneManager.LoadSceneAsync("OriginSalt"); StartCoroutine(ShowMask()); });
        btnSalt.onClick.AddListener(delegate { SceneManager.LoadSceneAsync("OriginScheol"); StartCoroutine(ShowMask()); });
        btnSalt.gameObject.SetActive(false);
        btnScheol.gameObject.SetActive(false);
        count.gameObject.SetActive(false);
    }
    public void Finish()
    {
        btnSalt.gameObject.SetActive(true);
        btnScheol.gameObject.SetActive(true);
        count.gameObject.SetActive(true);
        count.text = gm.GetScore().ToString();
    }
    IEnumerator ShowMask()
    {
        while (true)
        {
            Color cm = mask.color;
            cm.a += 16 * Time.deltaTime;
            mask.color = cm;
            yield return null;
        }
    }
    // Update is called once per frame
    void Update()
    {
        bgmTimeTxt.text = gm.GetBGMTime().ToString();

    }
}
