Skip to content
Snippets Groups Projects
GenerateMap.cs 1.05 KiB
Newer Older
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GenerateMap : MonoBehaviour
{
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
    //Les 8 prefabs
    public GameObject[] maps = new GameObject[8];
    public GameObject[] shopFactory = new GameObject[8];
    

    public Object[] objects=new Object[8];
    public int where;
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
    //Les coordonées x dans l'ordre
    private int[] xs=new int[]{-17,0,17,-17,0,17,-17,0};

    //Les coordonées y dans l'ordre
    private int[] ys=new int[]{26,26,26,13,13,13,0,0};
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
    // Start is called before the first frame update
    void Start()
    {
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
        generateMap();
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
    //Place les 8 prefabs aux bons endroits 
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
    public void generateMap()
    {
nyvlemacul@gmail.com's avatar
nyvlemacul@gmail.com committed
        for(int i=0;i<8;i++)
            objects[i]=Instantiate(maps[i], new Vector3(xs[i], ys[i], 0), Quaternion.identity);
    public void generateShopFactory()
    {
        Destroy(objects[where]);
        Instantiate(shopFactory[where], new Vector3(xs[where], ys[where], 0), Quaternion.identity);

    }