Пример #1
0
    public bool CanLine(int posx, int posy)
    {
        CoverInfo cover = GetCoverByPos(posy, posx);

        if (cover == null)
        {
            return(true);
        }
        return(cover.CanLine());
    }
Пример #2
0
    //是否僵局
    public static bool IsDead()
    {
        List <List <CellInfo> > allCells     = CellModel.Instance.allCells;
        List <List <CellInfo> > tempAllCells = new List <List <CellInfo> >();

        int i;

        for (i = 0; i < BattleModel.Instance.crtBattle.ShowHeight(); i++)
        {
            List <CellInfo> xCells = allCells[i];
            tempAllCells.Add(new List <CellInfo>());
            for (int j = 0; j < xCells.Count; j++)
            {
                CellInfo cellInfo = xCells[j];

                if (cellInfo.isBlank == false && cellInfo.isMonsterHold == false && cellInfo.config.line_type > 0)
                {
                    CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(cellInfo.posY, cellInfo.posX);
                    if (coverInfo.CanLine())
                    {
                        tempAllCells[i].Add(cellInfo.Copy());
                    }
                    else
                    {
                        tempAllCells[i].Add(null);
                    }
                }
                else
                {
                    tempAllCells[i].Add(null);
                }

                if (cellInfo.isBlank == false && cellInfo.isMonsterHold == false && cellInfo.config.cell_type == (int)CellType.radiate)
                {
                    if (!RadiateCheck(allCells, cellInfo))
                    {
                        return(false);
                    }
                }
            }
        }
        return(RecursiveCheck(tempAllCells));
    }
Пример #3
0
    private static bool RadiateCheck(List <List <CellInfo> > allCells, CellInfo radiateCell)
    {
        CellInfo checkCenterInfo = radiateCell;
        //一轮查找
        List <CellInfo> firstRingCells = new List <CellInfo>();
        int             i;

        for (i = 0; i < checkList.Count; i++)
        {
            Vector2 indexPos;

            indexPos = FightConst.GetHoleByLevel(checkList[i], checkCenterInfo.IsHump());

            Vector2 offsetPos = new Vector2(checkCenterInfo.posX + indexPos.x, checkCenterInfo.posY - indexPos.y);

            CellInfo checkCell = GetCellByPos(allCells, (int)offsetPos.x, (int)offsetPos.y);

            if (checkCell != null && checkCell.isBlank == false && checkCell.isMonsterHold == false &&
                (checkCell.config.line_type > 0 || checkCell.config.cell_type == (int)CellType.radiate))
            {
                CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(checkCell.posY, checkCell.posX);
                if (coverInfo.CanLine())
                {
                    if (WallModel.Instance.CanLine(checkCenterInfo, checkCell))
                    {
                        firstRingCells.Add(checkCell);
                    }
                }
            }
            if (firstRingCells.Count > 1)
            {
                for (int j = 0; j < (firstRingCells.Count - 1); j++)
                {
                    CellInfo checkA = firstRingCells [j];
                    for (int n = (j + 1); n < firstRingCells.Count; n++)
                    {
                        CellInfo checkB = firstRingCells [n];
                        if (checkA.IsNeighbor(checkB))
                        {
                            if (WallModel.Instance.CanLine(checkA, checkB))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
        }

        if (firstRingCells.Count == 0)
        {
            return(true);
        }
        else
        {
            for (int b = 0; b < firstRingCells.Count; b++)
            {
                CellInfo checkCenterInfo2 = firstRingCells[b];
                //二轮查找
                List <CellInfo> secondRingCells = new List <CellInfo>();
                for (i = 0; i < checkList.Count; i++)
                {
                    Vector2 indexPos = FightConst.GetHoleByLevel(checkList[i], checkCenterInfo2.IsHump());

                    Vector2 offsetPos = new Vector2(checkCenterInfo2.posX + indexPos.x, checkCenterInfo2.posY - indexPos.y);

                    CellInfo checkCell = GetCellByPos(allCells, (int)offsetPos.x, (int)offsetPos.y);

                    if (checkCell != null && checkCell.isBlank == false && checkCell.isMonsterHold == false &&
                        checkCenterInfo != checkCell && checkCell.config.line_type == checkCenterInfo.config.line_type)
                    {
                        CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(checkCell.posY, checkCell.posX);
                        if (coverInfo.CanLine())
                        {
                            if (WallModel.Instance.CanLine(checkCenterInfo2, checkCell))
                            {
                                secondRingCells.Add(checkCell);
                            }
                        }
                    }
                    if (secondRingCells.Count > 1)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
    }