Beispiel #1
0
    public void SelectCell(int column, int row)
    {
        if (gameState.IsBlocked)
        {
            return;
        }

        int     index = GetCellIndex(column, row);
        HexCell cell  = cells[index];

        if (!cell.IsPassable())
        {
            return;
        }

        List <HexCell> path = MakePath(selectedCell, cell);

        // Our path is in reverse order for player
        path.Reverse();

        // This may happen if we're already moving. Kind of error
        if (!gameState.MovePlayerThroughPath(path))
        {
            return;
        }

        selectedCell = cell;
        cell.Draw(cell.activeSprite);
        RemoveSelection();
    }
Beispiel #2
0
    public void RemoveSelection()
    {
        foreach (HexCell cell in cells)
        {
            cell.Clear();
        }

        if (selectedCell)
        {
            selectedCell.Draw(selectedCell.activeSprite);
        }
    }
Beispiel #3
0
    public void HiglightCell(int column, int row)
    {
        if (gameState.IsBlocked)
        {
            return;
        }

        int     index = GetCellIndex(column, row);
        HexCell cell  = cells[index];

        higlightedCell = cell;

        if (cell == selectedCell)
        {
            GetComponentInChildren <CursorManager>().SetCursor(CursorManager.CursorType.Arrow);
            return;
        }

        RemoveSelection();

        if (selectedCell)
        {
            List <HexCell> path = MakePath(selectedCell, cell);

            // Remove active cell
            if (path.Count > 0)
            {
                path.RemoveAt(path.Count - 1);
            }

            foreach (HexCell pathCell in path)
            {
                pathCell.Draw(cell.pathSprite);
            }
        }

        if (cell.IsPassable())
        {
            GetComponentInChildren <CursorManager>().SetCursor(CursorManager.CursorType.Walk);
            cell.Clear();
            cell.Draw(cell.outlineSprite);
        }
        else
        {
            GetComponentInChildren <CursorManager>().SetCursor(CursorManager.CursorType.Stop);
        }
    }