using UnityEngine;
using System.Collections;

public class ScoreManager : MonoBehaviour {

	static ScoreManager _instance;

	float points;

	public float basePointIncreaseSpeed = 1f;

	public float pointSpeedExponent = 1.1f;
	public float pointTimeBeforeExplosion = 100f;

	float pointSpeed;

	static public ScoreManager instance {
		// using lazy instantiation here... 
		get{
			return _instance;
		}
	}

	void Awake(){
		_instance = this;
	}

	void Start(){
		points = 0;
		pointSpeed = basePointIncreaseSpeed;
	}

	void Update(){
		if(GameManager.instance.currentState != GameManager.GameState.GameOverWow && 
			GameManager.instance.currentState != GameManager.GameState.GameOverNoAdepts){
			pointSpeed = basePointIncreaseSpeed + (Mathf.Pow(GameManager.instance.elapsedTime, pointSpeedExponent) / pointTimeBeforeExplosion);
			points += pointSpeed;
		}
	}

	public int Points()
	{
		// Returning floored points
		return (int) (Mathf.Floor(points / 10) * 10);
	}
}
