private void ShowTooltipOnResources()
    {
        Vector3Int resourcesCell = MouseMoveController.GetMousePositionOnTileMap(resourcesTileMap);
        Vector3Int buildingsCell = MouseMoveController.GetMousePositionOnTileMap(buildingsTileMap);

        // Start inspect from building (it's less of them)
        InspectTile(resourcesCell, Helpers.GetBuildings());

        if (!isOverlapping)
        {
            // If no result, go to resources then
            InspectTile(buildingsCell, Helpers.GetResources());
        }

        if (details && isOverlapping && !EventSystem.current.IsPointerOverGameObject())
        {
            if (details.unit.type == UnitType.Building.ToString())
            {
                ShowBuildingTooltip();
            }
            else
            {
                ShowResourceTooltip();
            }
        }
        else
        {
            Tooltip.OnHideTooltip();
        }
    }
Beispiel #2
0
    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);
            }
        }
    }