using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class DotCounter : MonoBehaviour {

    public int numChildren = 0;

	// Use this for initialization
	void Start () {
        //count number of children
		if (!AllScores.all_scores.scores.ContainsKey ("pac")) {
			AllScores.all_scores.scores.Add ("pac", 0);
		} else {
			AllScores.all_scores.scores ["pac"] = 0;
		}
        numChildren = 0;
        //add each child object of 'pacdot' type to the array to track
        foreach (Transform child in transform)
        {
            numChildren++;
        }
	}
	
	// Update is called once per frame
	void Update () {
	  
        //pacVan wins if he has collected all of the pacdots
        if (numChildren <= 0)
        {
            Debug.Log("WIN");
			AllScores.all_scores.results = "Van Helsing Wins";
			SceneManager.LoadScene("Results");
        }
	}

    //this is called by children to report their deaths
    void LostChild()
    {
		AllScores.all_scores.scores["pac"] += 1;
        numChildren--;
    }

    
}
