public TileMapConfig16 CreateNewLayer(string name, int order = 0) { TileMapConfig16 gml = Instantiate <TileMapConfig16>(prototypeMapLayer16, map.transform); gml.gameObject.name = name; gml.GetComponent <TilemapRenderer>().sortingOrder = order; //gml.level = levels.Count; return(gml); }
public IEnumerator AddLayers() { for (int i = 0; i < dataLevel.LayerCount(); i++) { yield return(AddLayer(i)); } improvement = CreateNewLayer32("Improvement", dataLevel.LayerCount()); overlay = CreateNewLayer("overlay", dataLevel.LayerCount() + 1); overlay.GetComponent <TilemapRenderer>().sortingLayerName = "Overlay"; yield return(AddBorder()); }
protected override void SetTile(TileMapConfig16 tile, NVector pos) { var b = S.Building().At(pos); if (b == null) { return; } //todo performance? tile.GetComponent <Tilemap>().SetTile(new Vector3Int(pos.x * 2 + 1, pos.y * 2, 0), Tile(b.Player())); }
protected override void SetTile(TileMapConfig16 tile, NVector pos) { if (S.ActPlayer().overlay.Get("res", pos) == 0) { return; } int align = 0; var rgk = GameMgmt.Get().data.map.levels[pos.level].ResGenKey(pos.x, pos.y); if (rgk == null) { return; } foreach (string key in rgk) { int act = GameMgmt.Get().data.map.ResGen(pos, key); var res = L.b.res[key]; //nothing to display? if (res.overlay.Count == 0 || act == 0) { continue; } string found = null; //find id foreach (var o in res.overlay) { var sp = SplitHelper.DelimiterInt(o); if (sp.value > act) { break; } found = sp.key; } //show it Tile t = GameMgmt.Get().newMap.tools.GetTile(found); tile.GetComponent <Tilemap>().SetTile(new Vector3Int(pos.x * 2 + (align % 2), pos.y * 2 + (align / 2), 0), t); align++; //full? if (align >= 4) { return; } } }