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

public class ScoreText : MonoBehaviour {

    public Text plusText;

    Text text;

    GlobalManager manager;

    int savedScore;

	// Use this for initialization
	void Start () {
        text = GetComponent<Text>();
        manager = GameObject.FindGameObjectWithTag("GameController").GetComponent<GlobalManager>();
	}
	
	// Update is called once per frame
	void Update () {
        if (manager.score != savedScore)
        {
            text.text = "Score: " + manager.score;

            plusText.text = "+" + (manager.score - savedScore);
            plusText.color = new Color(1, 1, 0, 1);

            savedScore = manager.score;
        }

        if (plusText.color.a > 0)
        {
            plusText.color = new Color(1, 1, 0, plusText.color.a - Time.deltaTime / 2f);
        }
	}
}
