void ApplayObstacleLightUpdate() { if (ScreenUpdateManager.GetChangeObstacleLight()) { var addSize = obstacleLight.layerData.SizeAdd; for (int i = 0; i < countTileX + 2 * addSize - 1; i++) { for (int j = 0; j < countTileY + 2 * addSize - 1; j++) { if (!ScreenUpdateManager.IsUpdateOffsetObstacleLight(i, j)) { continue; } var x = p1.x + i * tileSize - (tileSize * addSize); var y = p1.y + j * tileSize - (tileSize * addSize); var tileStructure = tileDataProvider.GetTileStructure(x, y); var frameStructure = tileDataProvider.GetFrameStructure(x, y, tileStructure, obstacleLight.layerData); obstacleLight.ChangeTile(j, i, frameStructure.TileCollection, frameStructure.FrameX, frameStructure.FrameY, frameStructure.DeltaHeight); ScreenUpdateManager.EndDrawObstacleLightTile(i, j); } } obstacleLight.RenderMesh(); ScreenUpdateManager.SetChangeObstacleLight(false); } }
void RenderLayerAddSize(IInfinityTileMap layer, int addSize, int deltaX, int deltaY) { //определяем свапнутую область var sizeX = countTileX + 2 * addSize; var sizeY = countTileY + 2 * addSize; int swapStartX = 0; int swapEndX = Mathf.CeilToInt(sizeX); int swapStartY = 0; int swapEndY = Mathf.CeilToInt(sizeY); if (deltaX > 0) { swapStartX = 0; swapEndX = Mathf.CeilToInt(sizeX - deltaX) - 2; } if (deltaX < 0) { swapStartX = -(int)deltaX; swapEndX = Mathf.CeilToInt(sizeX); } if (deltaY > 0) { swapStartY = 0; swapEndY = Mathf.CeilToInt(sizeY - deltaY) - 2; } if (deltaY < 0) { swapStartY = -(int)deltaY; swapEndY = Mathf.CeilToInt(sizeY); } // layer.ShiftCells((int)deltaX, (int)deltaY); //int swapCount = 0; for (int i = 0; i < sizeX - 1; i++) { for (int j = 0; j < sizeY - 1; j++) { bool inSwapRect = i >= swapStartX && i <= swapEndX && j >= swapStartY && j <= swapEndY; if (inSwapRect) { continue; } //swapCount++; var x = p1.x + i * tileSize - (tileSize * addSize); var y = p1.y + j * tileSize - (tileSize * addSize); var tileStructure = tileDataProvider.GetTileStructure(x, y); var frameStructure = tileDataProvider.GetFrameStructure(x, y, tileStructure, layer.layerData); layer.ChangeTile(j, i, frameStructure.TileCollection, frameStructure.FrameX, frameStructure.FrameY, frameStructure.DeltaHeight); } } //Debug.LogError("swap = " + swapCount + " sizeY = " + sizeY + "sizeX = " + sizeX); layer.RenderMesh(); }