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

public class ColorGlower : MonoBehaviour {

	public float maxGlow;

	private float currentGlow;
	private bool isLighting;
	private Color initColor;

	// Use this for initialization
	void Awake () {
		initColor = gameObject.GetComponent<Text>().color;
		isLighting = true;
	}
	
	// Update is called once per frame
	void Update () {
		if(isLighting) {
			if( currentGlow < maxGlow ) {
				currentGlow += 0.01f;
				gameObject.GetComponent<Text>().color = new Color (initColor.r + currentGlow, initColor.g + currentGlow, + initColor.b + currentGlow);
			}
			else {
				isLighting = false;
			}
		}
		else {
			if( currentGlow > 0 ) {
				currentGlow -= 0.01f;
				gameObject.GetComponent<Text>().color = new Color (initColor.r + currentGlow, initColor.g + currentGlow, + initColor.b + currentGlow);
			}
			else {
				isLighting = true;
			}
		}
	}
}
