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

public class RedCircleLogic : MonoBehaviour {


	private bool finished = false;
	public int hits;


    public AudioClip hammer;
    private AudioSource source;

  

    public bool isFinished()
	{
		return finished;
	}

	void Start()
	{
		hits = int.Parse(GetComponentInChildren<Text> ().text);
        source = GetComponent<AudioSource>();
    }

	public void setNumberOnRedCircle ()
	{
		GetComponentInChildren<Text> ().text = hits.ToString();
	}
	void Update()
	{
		setNumberOnRedCircle ();
        if (hits == 0)
        {
            finished = true;
        }
        else
            finished = false;
			
	}

	public void decreaseHit()
	{
		hits -= 1;
        if (!source.isPlaying)
            source.PlayOneShot(hammer);
		if (hits < 0)
			hits = 0;
	}
		
}
