Exemple #1
0
    public void TrySelect()
    {
        if (hovoredTile != null && hovoredTile.IsPassable() && currentPlayer.ControlsTile(hovoredTile))
        {
            if (hovoredTile.Equals(selectedTile))
            {
                //Deselect if clicking on a selected tile
                selectedTile.Deselect();
                selectedTile = null;
                hovoredTile.Highlight(highlightTile);
            }
            else
            {
                //Deselect old tile
                if (selectedTile != null)
                {
                    selectedTile.Deselect();
                    selectedTile = null;
                }

                //Select new tile
                selectedTile = hovoredTile;
                selectedTile.Select(selectTile);
            }
        }
    }
Exemple #2
0
    public void TryHover(Vector3 mousePosition)
    {
        Vector3Int cellLocation = terrainTileMap.WorldToCell(mousePosition);

        WorldTile currentTile;

        if (tiles.TryGetValue(cellLocation, out currentTile))
        {
            if (hovoredTile != null)
            {
                hovoredTile.Dehighlight();
                hovoredTile = null;
            }

            if (currentTile.IsPassable())
            {
                hovoredTile = currentTile;
                hovoredTile.Highlight(highlightTile);
            }
        }
    }