Exemplo n.º 1
0
    GameObject GetSkinPrefab(MapData.CELL cell, int x, int y)
    {
        switch (cell)
        {
        case MapData.CELL.FLOOR:
            return(skin.floor[Mathf.Clamp(Random.Range(0, skin.floor.Length), 0, skin.floor.Length - 1)]);

        case MapData.CELL.WALL:
            return(GetWallPrefab(x, y));
        }

        return(null);
    }
Exemplo n.º 2
0
    void CreateMap()
    {
        float offset = skin.snapInterval;

        byte[] mainLayer = mapData.mainLayer;
        for (int i = 0; i < mainLayer.Length; i++)
        {
            int x = i % collumns;
            int y = Mathf.FloorToInt(i / collumns);

            MapData.CELL cell   = (MapData.CELL)mainLayer[i];
            GameObject   prefab = GetSkinPrefab(cell, x, y);
            if (prefab != null)
            {
                grid[i] = Instantiate <GameObject>(prefab, transform);
                grid[i].transform.localPosition = new Vector3((float)x * offset, (float)y * offset, 0f);
            }
        }
    }