GetNeighbours() публичный Метод

public GetNeighbours ( List cells ) : List
cells List
Результат List
Пример #1
0
    private void FindOtherHexagons(out Vector2 first, out Vector2 second)
    {
        Hexagon.NeighbourHexes neighbours = selectedHexagon.GetNeighbours();
        bool breakLoop = false;

        do
        {
            switch (selectionStatus)
            {
            case 0: first = neighbours.up; second = neighbours.upRight; break;

            case 1: first = neighbours.upRight; second = neighbours.downRight; break;

            case 2: first = neighbours.downRight; second = neighbours.down; break;

            case 3: first = neighbours.down; second = neighbours.downLeft; break;

            case 4: first = neighbours.downLeft; second = neighbours.upLeft; break;

            case 5: first = neighbours.upLeft; second = neighbours.up; break;

            default: first = Vector2.zero; second = Vector2.zero; break;
            }

            if (first.x < 0 || first.x >= gridWidth || first.y < 0 || first.y >= gridHeight || second.x < 0 || second.x >= gridWidth || second.y < 0 || second.y >= gridHeight)
            {
                selectionStatus = (++selectionStatus) % STATUS_COUNT;
            }
            else
            {
                breakLoop = true;
            }
        } while (!breakLoop);
    }
Пример #2
0
    /* Helper function for FindHexagonGroup() to locate neighbours of selected hexagon */
    private void FindOtherHexagons(out Vector2 first, out Vector2 second)
    {
        Hexagon.NeighbourHexes neighbours = selectedHexagon.GetNeighbours();
        bool breakLoop = false;


        /* Picking correct neighbour according to selection position */
        do
        {
            switch (selectionStatus)
            {
            case 0: first = neighbours.up; second = neighbours.upRight; break;

            case 1: first = neighbours.upRight; second = neighbours.downRight; break;

            case 2: first = neighbours.downRight; second = neighbours.down; break;

            case 3: first = neighbours.down; second = neighbours.downLeft; break;

            case 4: first = neighbours.downLeft; second = neighbours.upLeft; break;

            case 5: first = neighbours.upLeft; second = neighbours.up; break;

            default: first = Vector2.zero; second = Vector2.zero; break;
            }

            /* Loop until two neighbours with valid positions are found */
            if (first.x < ZERO || first.x >= gridWidth || first.y < ZERO || first.y >= gridHeight || second.x < ZERO || second.x >= gridWidth || second.y < ZERO || second.y >= gridHeight)
            {
                selectionStatus = (++selectionStatus) % SELECTION_STATUS_COUNT;
            }
            else
            {
                breakLoop = true;
            }
        } while (!breakLoop);
    }