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

public class getCollectable : MonoBehaviour {
    bool[,] collection;
    GameObject[,] tresor = new GameObject[3,3];
	int cont = 0;
	int cooldown = 120;
	// Use this for initialization
	void Start(){
		PlayerScript pl = (PlayerScript)GameObject.Find("Player").GetComponent(typeof(PlayerScript));
		collection = pl.getCollectable();
		for(int i = 1; i < 4; i++)
		{
			string s = "sp_chariot" + i;    //Niveau , Objet
			Debug.Log(GameObject.Find("sp_chariot1"));
			tresor[i - 1, 0] = GameObject.Find(s).gameObject;
			s = "sp_gemme_bleu" + i;    //Niveau , Objet
			tresor[i - 1, 1] = GameObject.Find(s).gameObject;
			s = "sp_gemme_rose" + i;    //Niveau , Objet
			tresor[i - 1, 2] = GameObject.Find(s).gameObject;
		}

		for (int i = 0; i < 3; i++)
		{
			for (int i2 = 0; i2 < 3; i2++)
			{
				tresor[i, i2].SetActive(false);
			}
		}
	}

	public void draw () {
        for (int i = 0; i < 3; i++)
        {
            for (int i2 = 0; i2 < 3; i2++)
            {
                if (collection[i, i2])
                {
                    tresor[i, i2].SetActive(true);
                }
            }
        }
    }

	void Update(){
		if (cont < cooldown) {
			cont++;
		}
		if (cont == cooldown) {
			cont++;
			draw ();
		}
	}
}
