private void RefreshBuildingsTouchingWarningsTile(BuildingsSummary buildingsSummary, Tile tile) { const string buildingsTouchingWarningText = "Buildings sharing corner.\nTwo buildings cannot share any corner."; Building building = buildingsSummary.GetBuildingAtTile(tile); if (building == null) { return; } Building leftTop = buildingsSummary.GetBuildingAtCoords(tile.X - 1, tile.Y + 1); if (leftTop != null && building != leftTop) { warningsList.Add(CreateWarningString(tile, buildingsTouchingWarningText)); } Building rightTop = buildingsSummary.GetBuildingAtCoords(tile.X + 1, tile.Y + 1); if (rightTop != null && building != rightTop) { warningsList.Add(CreateWarningString(tile, buildingsTouchingWarningText)); } }
private void RefreshTokenInsideBuildingWarningsTile(BuildingsSummary buildingsSummary, Tile tile) { const string tokenInsideBuildingWarningText = "Deed token inside building.\nTokens must be placed outside."; Decoration centralDecoration = tile.GetCentralDecoration(); // TODO: update the objects.xml schema to not require ShortName lookup here if (centralDecoration && centralDecoration.Data.ShortName == "token" && buildingsSummary.GetBuildingAtTile(tile) != null) { warningsList.Add(CreateWarningString(tile, tokenInsideBuildingWarningText)); } }
private void Update() { if (currentTool != ToolType.MaterialsCalculator) { // we need to react to actions on map only when calculating materials return; } RaycastHit raycast = LayoutManager.Instance.CurrentCamera.CurrentRaycast; if (!raycast.transform) { return; } OverlayMesh overlayMesh = raycast.transform.GetComponent <OverlayMesh>(); if (!overlayMesh) { return; } if (Input.GetMouseButtonDown(0)) { int floor = LayoutManager.Instance.CurrentCamera.Floor; int x = Mathf.FloorToInt(raycast.point.x / 4f); int y = Mathf.FloorToInt(raycast.point.z / 4f); Map map = GameManager.Instance.Map; Tile clickedTile = map[x, y]; if (buildingAllLevelsMaterialsToggle.isOn) { BuildingsSummary surfaceGroundSummary = new BuildingsSummary(map, 0); Materials materials = new Materials(); Building building = surfaceGroundSummary.GetBuildingAtTile(clickedTile); if (building == null) { ShowMaterialsWindow("No valid building on clicked tile"); return; } foreach (TileSummary tileSummary in building.AllTiles) { Tile tile = map[tileSummary.X, tileSummary.Y]; materials.Add(tile.CalculateTileMaterials(tileSummary.TilePart)); } StringBuilder summary = new StringBuilder(); summary.Append("Carpentry needed: ").Append(building.GetCarpentryRequired()).AppendLine(); summary.Append("Total tiles: ").Append(building.TilesCount).AppendLine(); summary.AppendLine(); summary.Append(materials); ShowMaterialsWindow(summary.ToString()); if (Debug.isDebugBuild) { Debug.Log(building.CreateSummary()); } } else if (buildingCurrentLevelMaterialsToggle.isOn) { BuildingsSummary surfaceGroundSummary = new BuildingsSummary(map, floor); Materials materials = new Materials(); Building building = surfaceGroundSummary.GetBuildingAtTile(clickedTile); if (building == null) { ShowMaterialsWindow("No valid building on clicked tile"); return; } foreach (TileSummary tileSummary in building.AllTiles) { Tile tile = map[tileSummary.X, tileSummary.Y]; materials.Add(tile.CalculateFloorMaterials(floor, tileSummary.TilePart)); } StringBuilder summary = new StringBuilder(); if (floor == 0 || floor == -1) { summary.Append("Carpentry needed: ").Append(building.GetCarpentryRequired()).AppendLine(); } else { summary.AppendLine("To calculate carpentry needed, please use this option on a ground floor"); } summary.Append("Rooms on this level: ").Append(building.RoomsCount).AppendLine(); summary.Append("Tiles on this level: ").Append(building.TilesCount).AppendLine(); summary.AppendLine(); summary.Append(materials); ShowMaterialsWindow(summary.ToString()); if (Debug.isDebugBuild) { Debug.Log(building.CreateSummary()); } } else if (roomCurrentLevelMaterialsToggle.isOn) { BuildingsSummary surfaceGroundSummary = new BuildingsSummary(map, floor); Materials materials = new Materials(); Room room = surfaceGroundSummary.GetRoomAtTile(clickedTile); if (room == null) { ShowMaterialsWindow("No valid room on clicked tile"); return; } foreach (TileSummary tileSummary in room.Tiles) { Tile tile = map[tileSummary.X, tileSummary.Y]; materials.Add(tile.CalculateFloorMaterials(floor, tileSummary.TilePart)); } StringBuilder summary = new StringBuilder(); summary.Append("Tiles in this room: ").Append(room.Tiles.Count).AppendLine(); summary.AppendLine(); summary.Append(materials); ShowMaterialsWindow(summary.ToString()); if (Debug.isDebugBuild) { Debug.Log(room.CreateSummary()); } } } }