Example #1
0
    void fillItem(GameObject[] itemRange, RandomRange itemCountRange)
    {
        int        numberOfItems = itemCountRange.getRand();
        GameObject instance;

        for (int i = 0; i < numberOfItems; i++)
        {
            int        itemPositionIndex = new RandomRange(0, layout.Count - 1).getRand();
            Vector3    itemPosition      = layout[itemPositionIndex];
            GameObject itemType          = itemRange[new RandomRange(0, itemRange.Length - 1).getRand()];
            instance = Instantiate(itemType, itemPosition, Quaternion.identity) as GameObject;
            instance.transform.SetParent(boardHolder);
            layout.RemoveAt(itemPositionIndex);
        }
    }
Example #2
0
    void fillFloor()
    {
        RandomRange floorRange      = new RandomRange(0, floorTiles.Length - 1);
        RandomRange outerWallsRange = new RandomRange(0, outerWallTiles.Length - 1);
        GameObject  instance;

        for (int i = 0; i < columns; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                if ((i == 0 || i == columns - 1) || (j == 0 || j == rows - 1))
                {
                    instance = Instantiate(outerWallTiles[outerWallsRange.getRand()], new Vector3(i, j, 0), Quaternion.identity) as GameObject;
                    instance.transform.SetParent(boardHolder);
                }
                else
                {
                    instance = Instantiate(floorTiles[floorRange.getRand()], new Vector3(i, j, 0), Quaternion.identity) as GameObject;
                    instance.transform.SetParent(boardHolder);
                }
            }
        }
    }