Beispiel #1
0
    public void switchRangeState(int rangeWidth, HexCell.CellState cellState,
                                 HexCoordinates centerCoordinates)
    {
        // Set up range of moving state
        var cells = getCircleRange(centerCoordinates, rangeWidth);

        foreach (var cell in cells)
        {
            if (cell != null && cell.state != HexCell.CellState.StateBlocked)
            {
                if (cell == this.cellSelected && cellState == HexCell.CellState.StateMoveRange)
                {
                    continue;                     // Selected cell shouldn't be set to move range state
                }
                cell.changeState(cellState);
                if (cellState == HexCell.CellState.StateDefault &&
                    cell.owner == null)                       // Hide ranges, disable them
                {
                    cell.disableCell();
                }
            }
        }

        // todo: Set up range of attacking
    }
Beispiel #2
0
    public void drawPath(HexCoordinates start, HexCoordinates goal, HexCell.CellState cellState)
    {
        AStarSearch    pathSearcher = new AStarSearch(this, start, goal);
        HexCoordinates node         = pathSearcher.cameFrom [goal] as HexCoordinates;

        do
        {
            HexCell cell = getCellByCubeCoordinates(node.X, node.Y);
            cell.changeState(cellState);
            node = pathSearcher.cameFrom[node] as HexCoordinates;
        } while (!node.Equals(start));
        getCellByCubeCoordinates(start.X, start.Y).changeState(cellState);
    }