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

public class GenerateMap : MonoBehaviour
{

    public List<GameObject> pVillage = new List<GameObject>();
    public List<GameObject> pBoutique = new List<GameObject>();
    public List<GameObject> pUsine = new List<GameObject>();
    public int nb_of_plot = 8;

    public Object[,] plot=new Object[3,3];
    public int where;

    //Les coordonées x dans l'ordre
    private int[] xs=new int[]{-17,0,17}; //colonne

    //Les coordonées y dans l'ordre
    private int[] ys=new int[]{26,13,0}; //ligne
    // Start is called before the first frame update
    void Start()
    {
        generateVillage();
    }

    //Place les 8 prefabs aux bons endroits 
    public void generateVillage()
    {/*
        for (int i=0;i< nb_of_plot; i++)
        {
            plot[i] = Instantiate(pVillage[Random.Range(0, pVillage.Count)], new Vector3(xs[i], ys[i], 0), Quaternion.identity);
        }*/

        for(int x = 0; x < xs.Length; x++)
        {
            for(int y = 0; y<ys.Length; y++)
            {
                plot[x,y] = Instantiate(pVillage[Random.Range(0, pVillage.Count)], new Vector3(xs[x], ys[y], 0), Quaternion.identity);
            }
        }

    }

    public void generateBoutique(int column, int line)
    {
        Destroy(plot[column, line]);
        plot[column, line] = Instantiate(pBoutique[Random.Range(0, pBoutique.Count)], new Vector3(xs[column], ys[line], 0), Quaternion.identity);
    }

    public void generateUsine(int column, int line)
    {
        Destroy(plot[column, line]);
        plot[column, line] = Instantiate(pUsine[Random.Range(0, pUsine.Count)], new Vector3(xs[column], ys[line], 0), Quaternion.identity);
    }

    public void generateBoutiqueTest()
    {
        // COLONNE, LIGNE
        generateBoutique(0, 0);
        generateUsine(1, 0);
    }



    void Update()
    {
        
    }
}