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

public class BtnMarket : MonoBehaviour {

    Programa _programa;

    public Programa programa {
        get { return _programa; }
        set {
            _programa = value;
            gameObject.GetComponentInChildren<Text>().text = "$ " + _programa.dinheiroDiario;
            GameObject fill = transform.GetChild(2).GetChild(0).gameObject;
            fill.GetComponent<Image>().fillAmount = _programa.duracao / 12;

            fill = transform.GetChild(4).gameObject;
            fill.GetComponent<Image>().fillAmount = _programa.qualidade;
        }
    }
    public Radio radio;

    private void Update() {
        if (radio == null) {
            radio = GameObject.FindGameObjectWithTag("Radio").GetComponent<Radio>();
        }
    }

    public void AddPrograma() {
        if (_programa != null && !radio.tocando) {
            radio.AddPrograma(programa.Copy());
        }
    }

}
