public void RefreshBuildBound() { // mark current position as old previousCell = currentCell; // set new position currentCell = MouseMoveController.GetMousePositionOnTileMap(hoverTileMap); // build rectangles previousArea = CreateRectangleArea(previousCell); currentArea = CreateRectangleArea(currentCell); // clear build flag canBuild = true; bool isInBuildingsPositions = false; foreach (Vector2Int previousAreaCell in previousArea.allPositionsWithin) { foreach (Vector2Int currentAreaCell in currentArea.allPositionsWithin) { isInBuildingsPositions = GameStore.GetAllBuildingsPositions().Contains(currentAreaCell); if (isInBuildingsPositions) { canBuild = false; break; } } hoverTileMap.SetTile((Vector3Int)previousAreaCell, null); if (isInBuildingsPositions || !Economy.CanBuy(selectedBuildingUnit.price)) { TileHelper.SetTiles(hoverTileMap, hoverTileDenied, currentArea); } else { hoverTileMap.SetTile(currentCell, currentBuildingTile); } } }