public static CellLineType Line(CellInfo cellInfo, bool isHead = false) { if (cellInfo.isBlank) { return(CellLineType.failure); } if (cellInfo.isMonsterHold) { return(CellLineType.failure); } if (isHead) { if (CellModel.Instance.lineCells.Count > 0) { return(CellLineType.failure); } } if (CellModel.Instance.lineCells.Count == 0) { if (cellInfo.CanLineTo() == false) { return(CellLineType.failure); } if (CoverModel.Instance.CanLine(cellInfo.posX, cellInfo.posY)) { LineAdd(cellInfo); MonsterModel.Instance.Absorb(cellInfo.config.id); CellModel.Instance.Absorb(cellInfo.config.id); return(CellLineType.success); } else { return(CellLineType.failure); } } CellInfo lastInfo = CellModel.Instance.lineCells [CellModel.Instance.lineCells.Count - 1]; //lastInfo倒数第一个 if (lastInfo == cellInfo) { return(CellLineType.failure); } if (lastInfo.CanLineTo(cellInfo) == false) { return(CellLineType.failure); } if (cellInfo.IsNeighbor(lastInfo)) { if (CellModel.Instance.lineCells.Count > 1) { CellInfo beforeInfo = CellModel.Instance.lineCells [CellModel.Instance.lineCells.Count - 2]; //beforeInfo倒数第二个 if (beforeInfo == cellInfo) { CellModel.Instance.rollbackCell = lastInfo; CellModel.Instance.rollbackCell.isLink = false; CellModel.Instance.lineCells.RemoveAt(CellModel.Instance.lineCells.Count - 1); MonsterModel.Instance.UnAbsorb(lastInfo.config.id); CellModel.Instance.UnAbsorb(lastInfo.config.id); return(CellLineType.rollback); } else { if (cellInfo.isLink == false) { if (WallModel.Instance.CanLine(lastInfo, cellInfo)) { if (CoverModel.Instance.CanLine(cellInfo.posX, cellInfo.posY)) { LineAdd(cellInfo); MonsterModel.Instance.Absorb(cellInfo.config.id); CellModel.Instance.Absorb(cellInfo.config.id); return(CellLineType.success); } else { return(CellLineType.failure); } } return(CellLineType.failure); } else { return(CellLineType.failure); } } } else { if (cellInfo.isLink == false) { if (WallModel.Instance.CanLine(lastInfo, cellInfo)) { if (CoverModel.Instance.CanLine(cellInfo.posX, cellInfo.posY)) { LineAdd(cellInfo); MonsterModel.Instance.Absorb(cellInfo.config.id); CellModel.Instance.Absorb(cellInfo.config.id); return(CellLineType.success); } else { return(CellLineType.failure); } } return(CellLineType.failure); } else { return(CellLineType.failure); } } } return(CellLineType.failure); }
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); } }