Esempio n. 1
0
    public void CreateTiles(int amount)
    {
        for (int i = 0; i < amount; i++)
        {
            Tile_1_Tiles.Push(Instantiate(tilePrefabs[0]));
            Tile_1_Tiles.Peek().name = "Tile_1";
            Debug.Log("Tile 1");
            Tile_1_Tiles.Peek().SetActive(false);

            Tile_2_Tiles.Push(Instantiate(tilePrefabs[1]));
            Tile_2_Tiles.Peek().name = "Tile_2";
            Debug.Log("Tile 2");
            Tile_2_Tiles.Peek().SetActive(false);

            Tile_3_Tiles.Push(Instantiate(tilePrefabs[2]));
            Tile_3_Tiles.Peek().name = "Tile_3";
            Debug.Log("Tile 3");
            Tile_3_Tiles.Peek().SetActive(false);
        }
    }
Esempio n. 2
0
    public void SpawnTile()
    {
        if (Tile_1_Tiles.Count == 0 || Tile_2_Tiles.Count == 0 || Tile_3_Tiles.Count == 0)
        {
            Debug.Log("Create 3");
            CreateTiles(1);
        }

        int randomIndex = Random.Range(0, 3);

        //int randomIndex = Random.Range(0, 1);

        if (randomIndex == 0)
        {
            GameObject temp = Tile_1_Tiles.Pop();
            temp.SetActive(true);
            //temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position;
            currentTile             = temp;
        }
        else if (randomIndex == 1)
        {
            GameObject temp = Tile_2_Tiles.Pop();
            temp.SetActive(true);
            //temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position;
            currentTile             = temp;
        }
        else if (randomIndex == 2)
        {
            GameObject temp = Tile_3_Tiles.Pop();
            temp.SetActive(true);
            //temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position;
            currentTile             = temp;
        }

        //currentTile = (GameObject)Instantiate(tilePrefabs[randomIndex], currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position, Quaternion.identity);
    }