public CmdSetTile(TileInfos tilemap, Vector2Int pos, ushort srcId, ushort dstId) { this.tilemap = tilemap; this.pos = pos; this.srcId = srcId; this.dstId = dstId; }
public void DoAfterInit() { for (int i = 0; i < this.gridInfo.tileMaps.Length; i++) { TileInfos tileInfos = this.gridInfo.tileMaps[i]; bool isTagMap = tileInfos.isTagMap; if (!isTagMap) { LVector2Int min = tileInfos.min; LVector2Int size = tileInfos.size; this.mapDataMin.x = LMath.Min(this.mapDataMin.x, min.x); this.mapDataMin.y = LMath.Min(this.mapDataMin.y, min.y); this.mapDataMax.x = LMath.Max(this.mapDataMax.y, min.x + size.x); this.mapDataMax.y = LMath.Max(this.mapDataMax.y, min.y + size.y); } } this.mapDataSize = this.mapDataMax - this.mapDataMin + LVector2Int.one; this.mapDataIds = new ushort[this.mapDataSize.x, this.mapDataSize.y]; for (int j = 0; j < this.mapDataSize.x; j++) { for (int k = 0; k < this.mapDataSize.y; k++) { LVector2Int pos = new LVector2Int(mapDataMin.x + j, mapDataMin.y + k); this.mapDataIds[j, k] = this.RawPos2TileId(pos, false); } } }
private void OnReplaceTile(LVector2Int pos, ushort srcId, ushort dstId) { for (int i = 0; i < this.gridInfo.tileMaps.Length; i++) { TileInfos tileInfos = this.gridInfo.tileMaps[i]; ushort tileID = tileInfos.GetTileID(pos); bool flag = tileID == srcId; if (flag) { this.cmdBuffer.Execute(base.CurTick, new BaseMap2DService.CmdSetTile(tileInfos, pos, srcId, dstId)); } } }
public ushort RawPos2TileId(LVector2Int pos, bool isCollider) { for (int i = 0; i < this.gridInfo.tileMaps.Length; i++) { TileInfos tileInfos = this.gridInfo.tileMaps[i]; bool isTagMap = tileInfos.isTagMap; if (!isTagMap) { bool flag = isCollider && !tileInfos.hasCollider; if (!flag) { ushort tileID = tileInfos.GetTileID(pos); bool flag2 = tileID > 0; if (flag2) { return(tileID); } } } } return(0); }
public static void BindMapView(Grid grid, GridInfo info) { bool flag = grid != null; if (flag) { foreach (Tilemap tilemap in grid.GetComponentsInChildren <Tilemap>()) { TileInfos mapInfo = info.GetMapInfo(tilemap.name); bool flag2 = mapInfo == null; if (!flag2) { tilemap.ClearAllTiles(); TileInfosView tileInfosView = new TileInfosView(); mapInfo.view = tileInfosView; tileInfosView.tilemap = tilemap; int num = mapInfo.tileIDs.Length; TileBase[] array = new TileBase[num]; for (int j = 0; j < num; j++) { array[j] = UnityMap2DUtil.ID2Tile(mapInfo.tileIDs[j]); } tilemap.SetTiles((from t in mapInfo.GetAllPositions() select t.ToVector3Int()).ToArray <Vector3Int>(), array); bool isPlaying = Application.isPlaying; if (isPlaying) { bool isTagMap = mapInfo.isTagMap; if (isTagMap) { tilemap.GetComponent <TilemapRenderer>().enabled = false; } } } } } }