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

public class mapManagement : MonoBehaviour
{
    public List<GameObject> cubes;
    public List<float> unreachableCoord = new List<float>();
    public GameObject[] levelGrids;
    [HideInInspector]
    public GameObject UC, C;
    //public GameObject[] unreachableGrid;
    public List<GameObject> unreachableGrid;
    public List<GameObject> collectibles;
    public ScoreCount sC;

    // Start is called before the first frame update
    void Start()
    {
        //SetUnreachableCubes(cubes);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void SetUnreachableCubes(List<GameObject> cubes)
    {
        foreach (GameObject g in cubes)
        {
            int xz = (int)g.transform.position.x * 1000 + (int)g.transform.position.z;
            Debug.Log(xz);
            unreachableCoord.Add(xz);
        }
    }

    public void ResetLevel(int i)
    {   
        for(int k=0; k<levelGrids.Length; k++)
        {
            levelGrids[k].SetActive(false);
        }

        unreachableCoord.Clear();
        unreachableGrid.Clear();
        levelGrids[i-1].SetActive(true);
        UC = levelGrids[i-1].transform.GetChild(1).gameObject;
        for (int j = 0; j<UC.transform.childCount-1;j++)
        {
            unreachableGrid.Add(UC.transform.GetChild(j).gameObject);
        }
        SetUnreachableCubes(unreachableGrid);
    }

    public void ResetCollectibles(int i)
    {
        C = levelGrids[i - 1].transform.GetChild(2).gameObject;
        for (int j = 0; j < C.transform.childCount - 1; j++)
        {
            C.transform.GetChild(j).gameObject.SetActive(true) ;
        }
        sC.maxDiamond = C.transform.childCount - 1;

    }

}
