public static void Refresh() { if (PublicApiGateway == null) { throw new InvalidOperationException("Labyrinth has not been created yet"); } ActiveDeviceId = null; var deviceGroups = PublicApiGateway.GetDeviceGroups(); var devices = PublicApiGateway.GetDevices(); _installedApplications.Clear(); foreach (Device device in devices) { var installedApps = PublicApiGateway.GetInstalledApplications(device.DeviceId); _installedApplications.Add(device.DeviceId, installedApps); } _devices = devices.ToDictionary(d => d.DeviceId, d => d); TotalGroups = deviceGroups.Length; TotalDevices = devices.Length; _labyrinthMatrix = MapGenerator.GenerateMap(deviceGroups, devices); }
private void GenerateTiles(int mapWidth, int mapHeight, float tileWidth, float tileHeight) { var map = new MapGenerator(mapWidth, mapHeight, MinRoomRation); var level = map.GenerateMap(); _map = new TileMap(level); for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { var tile = level[i, j]; Transform newTransform = null; switch (tile) { case MapGenerator.TileType.Wall: newTransform = (Transform)Instantiate(WallTile, new Vector3(i * tileWidth, j * tileHeight, 0), Quaternion.identity); break; case MapGenerator.TileType.Room: newTransform = (Transform)Instantiate(GroudTile, new Vector3(i * tileWidth, j * tileHeight, 0), Quaternion.identity); break; } if (newTransform != null) { newTransform.transform.parent = _tilesGameObject.transform; _map[i, j].GameObject = newTransform.gameObject; _map[i, j].AfterVisibilityChanged = t => { var spriteRenderer = t.GameObject.GetComponent <SpriteRenderer>(); if (spriteRenderer != null) { spriteRenderer.enabled = t.IsVisible; } }; } } } }