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(); }
public void OnInject() { tileDataProvider = TileDataProvider; //this.Inject(); UpdateScreenTiles(); Container.Inject(tileDataProvider); tileDataProvider.Init(this, tileSize); tixtuteGO = new GameObject("tixtuteGO"); foreach (var layer in LayerData.Layers) { GameObject layerGO = new GameObject(layer.Name); layerGO.transform.SetParent(tixtuteGO.transform, false); // layerGO.transform.localPosition = new Vector3(0, 0, /*-layer.Depth*/0); layerGO.layer = LayerMask.NameToLayer(layer.LayerName); IInfinityTileMap layerMesh = (IInfinityTileMap)Activator.CreateInstance(layer.RenderType); Container.Inject(layerMesh); if (layer == LayerData.ObstacleLightLayer) { obstacleLight = layerMesh; } else if (layer == LayerData.LightLayer) { lightLayer = layerMesh; } else { } if (layer != LayerData.ObstacleLightLayer) { layerMeshs.Add(layerMesh); } // layerMesh.LoadMesh(layerGO, (int)(countTileX) + 2 * layer.SizeAdd, (int)(countTileY) + 2 * layer.SizeAdd, tileSize, layer); layerMesh.SetLayer(layer.Depth); layerGO.transform.localPosition = new Vector3(-layer.SizeAdd * tileSize, -layer.SizeAdd * tileSize, 0); } SpriteManager.SetTileMap(layerMeshs[0]); var centerPos = MapGenerator.CenterPos; camera.transform.position = new Vector3(centerPos.x * tileSize, centerPos.y * tileSize, camera.transform.position.z); ScreenUpdateManager.Init((int)(countTileX), (int)(countTileY)); // Debug.LogErrorFormat("({0}, {1})",Screen.width, Screen.height); }
public void SetTileMap(IInfinityTileMap provider) { this.provider = provider; }