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

public class UpgradeFlasher : MonoBehaviour {

	UpgradePanel upgradePanel;

	float flashAmount = 0;

	Image img;

	// Use this for initialization
	void Start () {
		upgradePanel = GameObject.FindObjectOfType<UpgradePanel>();
		img = GetComponent<Image>();
	}
	
	// Update is called once per frame
	void Update () {
		flashAmount -= Time.deltaTime;
	
		if(flashAmount <= 0.25f) {
			if( upgradePanel.UpgradeAvailable() ) {
				flashAmount = 0.5f;
			}
			else {
				flashAmount = 0;

			}
		}

		if (flashAmount > 0){
			img.color = new Color(1f-flashAmount, 1f, 1f-flashAmount);
		}
		else {
			img.color = Color.white;
		}

	}
}
