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); } }
private void PlayPutAutoSkill() { rootAction = new OrderAction(); WaitActor waitActor = new WaitActor(200); rootAction.AddNode(waitActor); List <SkillEntityInfo> skillEntitys = SkillModel.Instance.GetNewSkillEntitys(); fightUI.ShowSkill(); if (lastTouchCell != null && skillEntitys.Count > 0) { ParallelAction parallelAction = new ParallelAction(); int holdIndex = 0; bool lastIsHump = lastTouchCell.IsHump(); for (int i = 0; i < skillEntitys.Count; i++) { OrderAction skillOrder = new OrderAction(); SkillEntityInfo skillEntity = skillEntitys[i]; Vector2 addPos = new Vector2(); for (int h = holdIndex; h < 19; h++) { Vector2 holePos = FightConst.GetHoleByLevel(h, lastIsHump); Vector2 checkPos = new Vector2(lastTouchCell.posX + holePos.x, lastTouchCell.posY - holePos.y); CellInfo checkCell = CellModel.Instance.GetCellByPos((int)checkPos.x, (int)checkPos.y); if (checkCell != null && checkCell.isBlank) { addPos = checkPos; holdIndex = h + 1; break; } } CellInfo addItem = CellModel.Instance.AddItem(skillEntity.seed.config_cell_item.id, (int)addPos.x, (int)addPos.y); SkillModel.Instance.ThrowSkillEntity(skillEntity, addItem); GameObject itemObj = CreateCellItem(addItem); itemObj.transform.SetParent(effectLayer.transform, false); Vector2 toPos = PosUtil.GetFightCellPos(addItem.posX, addItem.posY); PosUtil.SetCellPos(itemObj.transform, skillEntity.seed.seed_x, skillEntity.seed.seed_y, 1.0f); rootAction.AddNode(new PlaySoundActor("Useskill")); rootAction.AddNode(new ShowEffectActor(itemObj.transform, "effect_skill_fly")); rootAction.AddNode(new MoveActor((RectTransform)itemObj.transform, new Vector3(toPos.x, toPos.y, 0), 1200)); skillOrder.AddNode(new SetLayerActor(itemObj.transform, transform)); skillOrder.AddNode(new PlaySoundActor("PutAutoSkill")); skillOrder.AddNode(new ClearEffectActor(itemObj.transform, "effect_skill_fly")); skillOrder.AddNode(new ScaleActor((RectTransform)itemObj.transform, new Vector3(1.2f, 1.2f, 0), 0.2f)); skillOrder.AddNode(new ScaleActor((RectTransform)itemObj.transform, new Vector3(1, 1, 0), 0.1f)); parallelAction.AddNode(skillOrder); } rootAction.AddNode(parallelAction); } waitActor = new WaitActor(200); rootAction.AddNode(waitActor); ExecuteAction(FightStadus.auto_skill); }
private static bool RecursiveCheck(List <List <CellInfo> > tempAllCells) { CellInfo checkCenterInfo = null; int i; for (i = 0; i < tempAllCells.Count; i++) { List <CellInfo> xCells = tempAllCells[i]; for (int j = 0; j < xCells.Count; j++) { CellInfo cellInfo = xCells[j]; if (cellInfo != null && checkCenterInfo == null) { checkCenterInfo = cellInfo; ClearCellByPos(tempAllCells, checkCenterInfo.posX, checkCenterInfo.posY); break; } } } if (checkCenterInfo == null) { return(true); } else { //一轮查找 List <CellInfo> firstRingCells = new List <CellInfo>(); 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(tempAllCells, (int)offsetPos.x, (int)offsetPos.y); if (checkCell != null && checkCell.config.line_type == checkCenterInfo.config.line_type) { if (WallModel.Instance.CanLine(checkCenterInfo, checkCell)) { ClearCellByPos(tempAllCells, checkCell.posX, checkCell.posY); firstRingCells.Add(checkCell); } } if (firstRingCells.Count > 1) { return(false); } } if (firstRingCells.Count == 0) { return(RecursiveCheck(tempAllCells)); } else { checkCenterInfo = firstRingCells[0]; //二轮查找 for (i = 0; i < checkList.Count; i++) { Vector2 indexPos = FightConst.GetHoleByLevel(checkList[i], checkCenterInfo.IsHump()); Vector2 offsetPos = new Vector2(checkCenterInfo.posX + indexPos.x, checkCenterInfo.posY - indexPos.y); CellInfo checkCell = GetCellByPos(tempAllCells, (int)offsetPos.x, (int)offsetPos.y); if (checkCell != null && checkCell.config.line_type == checkCenterInfo.config.line_type) { if (WallModel.Instance.CanLine(checkCenterInfo, checkCell)) { return(false); } } } return(RecursiveCheck(tempAllCells)); } } }