// сабтест проверяющий границы генерируемого поля
    bool SubTest1_1(int xSize, int ySize)
    {
        bool result = true;

        for (int x = 0; x < xSize; x++)
        {
            for (int y = 0; y < ySize; y++)
            {
                // проверяем границы по Х
                if (x == 0)
                {
                    ROAD_CONNECTION_STATUS status = m_blockRoadRulesDescriptor[x, y].RoadConnections[(int)Base.DIREC.LEFT];
                    if (status != ROAD_CONNECTION_STATUS.BLOCKED)
                    {
                        result = false;
                    }
                }
                else if (x == xSize - 1)
                {
                    ROAD_CONNECTION_STATUS status = m_blockRoadRulesDescriptor[x, y].RoadConnections[(int)Base.DIREC.RIGHT];
                    if (status != ROAD_CONNECTION_STATUS.BLOCKED)
                    {
                        result = false;
                    }
                }


                // проверяем границы по У
                if (y == 0)
                {
                    ROAD_CONNECTION_STATUS status = m_blockRoadRulesDescriptor[x, y].RoadConnections[(int)Base.DIREC.DOWN];
                    if (status != ROAD_CONNECTION_STATUS.BLOCKED)
                    {
                        result = false;
                    }
                }
                else if (y == ySize - 1)
                {
                    ROAD_CONNECTION_STATUS status = m_blockRoadRulesDescriptor[x, y].RoadConnections[(int)Base.DIREC.UP];
                    if (status != ROAD_CONNECTION_STATUS.BLOCKED)
                    {
                        result = false;
                    }
                }
            }
        }


        return(result);
    }
Example #2
0
    /**********************************************************************************/
    // маркируем клетку по статусу проходимости
    //
    /**********************************************************************************/
    private void MarkCellWayStatus(int xPoint, int yPoint, bool cellIsFree)
    {
        // маркеруем соседние проходы в соответсвии со статусом текущей клетки
        ROAD_CONNECTION_STATUS status = ROAD_CONNECTION_STATUS.POSSIBLE;

        if (cellIsFree == false)
        {
            status = ROAD_CONNECTION_STATUS.BLOCKED;
        }

        // верхняя точка
        BlockDescriptorImitation bdi = GetGlobalConnectionCell(xPoint, yPoint + 1);

        if (bdi != null)
        {
            bdi.RoadConnections[(int)Base.DIREC.DOWN] = status;
        }

        // нижняя точка
        bdi = GetGlobalConnectionCell(xPoint, yPoint - 1);
        if (bdi != null)
        {
            bdi.RoadConnections[(int)Base.DIREC.UP] = status;
        }

        // левая точка
        bdi = GetGlobalConnectionCell(xPoint - 1, yPoint);
        if (bdi != null)
        {
            bdi.RoadConnections[(int)Base.DIREC.RIGHT] = status;
        }

        // правая точка
        bdi = GetGlobalConnectionCell(xPoint + 1, yPoint);
        if (bdi != null)
        {
            bdi.RoadConnections[(int)Base.DIREC.LEFT] = status;
        }
    }