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

public class Score : MonoBehaviour
{
	private int score = 0;

	public int ScoreValue
	{
		get { return score; }
	}

	[SerializeField]
	private UIManager uiManager;

	private bool running = false;

	public void StartScoreCount()
	{
		running = true;
		StartCoroutine(ScoreTimerCount());
	}

	public void StopScoreCount()
	{
		running = false;
		Debug.Log("Stop score");
	}

	IEnumerator ScoreTimerCount()
	{
		while(running)
		{
			IncreaseScore(10);
			Debug.LogWarning("Score coroutine running!");
			yield return new WaitForSeconds(1);
		}
	}

	public void IncreaseScore(int amount)
	{
		if(running)
		{
			score += amount;

			uiManager.ChandeScoreText(score);
		}
	}
}
