using UnityEngine;
using System.Collections;

public class Score : MonoBehaviour {

	TextMesh _textMesh;
	float _internalScore;
	
	// Use this for initialization
	void Start () {
		_textMesh = transform.GetComponent<TextMesh>();
	}
	
	// Update is called once per frame
	void Update () {
		if(_internalScore > 0)
			_textMesh.text = ((int)_internalScore).ToString("n0");
		else
			_textMesh.text = "";
		_internalScore = Mathf.Lerp(_internalScore, (float)Globals.Score, Time.deltaTime * 10.0f);
		if(_internalScore > Globals.Score - 1)
			_internalScore = Globals.Score;
		
	}
}
