using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Holoville.HOTween;

public class ScoreHandler : MonoBehaviour
{ 

		public ScoreGained scoreGainedPrefab;
	
		private int _score;
		public static ScoreHandler instance;
		
		
		public delegate void UpdateHandler (int score);
		public static event UpdateHandler onUpdate;
				
		void Awake ()
		{
				instance = this;
		}
		
		void OnEnable ()
		{
				
		
		}
		
		void Start ()
		{
				ShowScore (Vector3.zero, "");
		}
		
		static void ShowScore (Vector3 position, string scoreText)
		{
				ScoreGained scoreGained = Instantiate (instance.scoreGainedPrefab) as ScoreGained;
				scoreGained.Init (scoreText, instance.transform, position);
		}
	
			
		public int score {
				get {
						return _score;
				}
				set {
						_score = value;
						if (onUpdate != null)
								onUpdate (score);
				}
		}		
}
