示例#1
0
    static void BuildMapLayers()
    {
        GameObject ThisLayer;

        foreach (MapLayer Layer in MapLayers)
        {
            Debug.Log(Layer.LayerId);

            if (MapContainer.transform.Find("MapLayer_" + Layer.LayerId) != null)
            {
                ThisLayer = MapContainer.transform.Find("MapLayer_" + Layer.LayerId).gameObject;
            }
            else
            {
                ThisLayer = new GameObject("MapLayer_" + Layer.LayerId);
                ThisLayer.transform.parent        = MapContainer.transform;
                ThisLayer.transform.localPosition = new Vector3(0, 0, Layer.LayerId);
            }

            AllTiles          = Resources.LoadAll <Sprite>(TilesetDataFolder + Layer.Tilesheet);
            TilesetCollisions = MapPropertiesReader.GetCSVProperties(TilesetDataFolder + Layer.Tilesheet + "_collisions");

            TossTilesheetErrors(Layer.Tilesheet);
            BuildLayer(ThisLayer, Layer);
        }
    }
示例#2
0
    static void BuildLayer(GameObject container, MapLayer layer)
    {
        List <List <string> > TextMap;
        GameObject            currentTile;

        TextMap = MapPropertiesReader.GetTextMap(MapPath + "_layer_" + layer.Name);

        TextMap.Reverse();

        int posX = 0;
        int posY = 0;

        foreach (List <string> mapRow in TextMap)
        {
            posX = 0;

            foreach (string mapCel in mapRow)
            {
                currentTile = BuildTile(mapCel, layer);

                if (currentTile != null)
                {
                    currentTile.transform.parent        = container.transform;
                    currentTile.transform.localPosition = new Vector3(X + posX, Y + posY, 0);
                    currentTile.GetComponent <SpriteRenderer>().sortingLayerName = "map_" + layer;
                }

                posX++;
            }

            posY++;
        }
    }
示例#3
0
    static public void BuildMap(string mapName, float x, float y)
    {
        MapPath       = MapDataFolder + mapName;
        MapName       = mapName;
        mapProperties = MapPropertiesReader.GetMapProperties(MapPath);
        MapLayers     = mapProperties.Layers;
        MapViews      = mapProperties.Views;
        X             = x;
        Y             = y;

        CreateMapContainer();

        BuildMapViews();
        BuildMapLayers();
    }