//часть логики, чтобы визуально собрать лабиринт. public void PostDestroyWall(Vector2Int pos, MapTileObjectType type) { GenericPreset[pos.x, pos.y] -= (int)type; }
void PlaceLabyrinth(int[,] Grid) { GenericPreset = Grid.Clone() as int[, ]; PlaceLabyrinthDetails(ref GenericPreset); GameObject WallInst = GameManager.Instance.WallInstance; GameObject CoinInst = GameManager.Instance.CoinInstance; GameObject PlayerInst = GameManager.Instance.PlayerInstance; GameObject WhiteEnemyInst = GameManager.Instance.WhiteEnemyInstance; GameObject BlueEnemyInst = GameManager.Instance.BlueEnemyInstance; GameObject RedEnemyInst = GameManager.Instance.RedEnemyInstance; GameObject newElem; //часть логики, чтобы визуально собрать лабиринт. WallInfo wi; for (int i = 0; i < 26; i++) { for (int b = 0; b < 26; b++) { MapTileObjectType probe = (MapTileObjectType)GenericPreset[i, b]; if (probe.HasFlag(MapTileObjectType.VerticalWall)) { Vector3 position = PositionRootObject.position + new Vector3(i, 0, b); newElem = Instantiate(WallInst, position, Quaternion.identity, WallsParent); //часть логики, чтобы визуально собрать лабиринт. wi = newElem.GetComponentInChildren <WallInfo>(); wi.pos = new Vector2Int(i, b); wi.myType = MapTileObjectType.VerticalWall; } if (probe.HasFlag(MapTileObjectType.HorizontalWall)) { Vector3 position = PositionRootObject.position + new Vector3(i, 0, b); newElem = Instantiate(WallInst, position, Quaternion.Euler(0f, 90f, 0f), WallsParent); //часть логики, чтобы визуально собрать лабиринт. wi = newElem.GetComponentInChildren <WallInfo>(); wi.pos = new Vector2Int(i, b); wi.myType = MapTileObjectType.HorizontalWall; } if (probe.HasFlag(MapTileObjectType.Coin)) { Vector3 position = PositionRootObject.position + new Vector3(i + 0.5f, 0, b + 0.5f); newElem = Instantiate(CoinInst, position, Quaternion.identity, CoinsParent); } if (probe.HasFlag(MapTileObjectType.Player)) { Vector3 position = PositionRootObject.position + new Vector3(i + 0.5f, 0.5f, b + 0.5f); newElem = Instantiate(PlayerInst, position, Quaternion.identity, EntitiesParent); PlayerPosition = newElem.transform; } if (probe.HasFlag(MapTileObjectType.WhiteEnemy)) { Vector3 position = PositionRootObject.position + new Vector3(i + 0.5f, 0.5f, b + 0.5f); newElem = Instantiate(WhiteEnemyInst, position, Quaternion.identity, EntitiesParent); } if (probe.HasFlag(MapTileObjectType.BlueEnemy)) { Vector3 position = PositionRootObject.position + new Vector3(i + 0.5f, 0.5f, b + 0.5f); newElem = Instantiate(BlueEnemyInst, position, Quaternion.identity, EntitiesParent); } if (probe.HasFlag(MapTileObjectType.RedEnemy)) { Vector3 position = PositionRootObject.position + new Vector3(i + 0.5f, 0.5f, b + 0.5f); newElem = Instantiate(RedEnemyInst, position, Quaternion.identity, EntitiesParent); } } } }