public WallInfo GetNeighborWallByDir(CellInfo cellInfo, CellDirType dirType) { bool isHump = cellInfo.IsHump(); switch (dirType) { case CellDirType.left_up: case CellDirType.up: case CellDirType.right_up: return(GetWallByPos(cellInfo.posY, cellInfo.posX, (int)dirType)); case CellDirType.left_down: if (cellInfo.posX > 0) { if (isHump) { return(GetWallByPos(cellInfo.posY, cellInfo.posX - 1, 2)); } else { if (cellInfo.posY < (BattleModel.Instance.crtBattle.battle_height - 1)) { return(GetWallByPos(cellInfo.posY + 1, cellInfo.posX - 1, 2)); } } } break; case CellDirType.down: if (cellInfo.posY < (BattleModel.Instance.crtBattle.battle_height - 1)) { return(GetWallByPos(cellInfo.posY + 1, cellInfo.posX, 1)); } break; case CellDirType.right_down: if (cellInfo.posX < (BattleModel.Instance.crtBattle.battle_width - 1)) { if (isHump) { return(GetWallByPos(cellInfo.posY, cellInfo.posX + 1, 0)); } else { if (cellInfo.posY < (BattleModel.Instance.crtBattle.battle_height - 1)) { return(GetWallByPos(cellInfo.posY + 1, cellInfo.posX + 1, 0)); } } } break; } return(null); }
public static int GetDirWithRotate(CellDirType dirType, int rotate) { int dir = (int)dirType; int offRotate = rotate % 6; dir = dir + offRotate; if (dir >= 6) { dir = dir - 6; } return(dir); }
public static int GetRotateByDir(CellDirType dirType) { switch (dirType) { case CellDirType.right_up: return(1 * FightConst.ROTATE_BASE); case CellDirType.right_down: return(2 * FightConst.ROTATE_BASE); case CellDirType.down: return(3 * FightConst.ROTATE_BASE); case CellDirType.left_down: return(4 * FightConst.ROTATE_BASE); case CellDirType.left_up: return(5 * FightConst.ROTATE_BASE); default: return(0); } }
private static bool HasBlindBarrier(CellInfo blankCell, CellDirType dir) { int cellX, cellY, wallX, wallY, wallN; bool isHump = blankCell.IsHump(); switch (dir) { case CellDirType.left_up: cellX = blankCell.posX - 1; if (isHump) { cellY = blankCell.posY - 1; } else { cellY = blankCell.posY; } break; case CellDirType.right_up: cellX = blankCell.posX + 1; if (isHump) { cellY = blankCell.posY - 1; } else { cellY = blankCell.posY; } break; default: cellX = blankCell.posX; cellY = blankCell.posY - 1; break; } wallX = blankCell.posX; wallY = blankCell.posY; wallN = (int)dir; CellInfo cellInfo = CellModel.Instance.GetCellByPos(cellX, cellY); WallInfo wallInfo = WallModel.Instance.GetWallByPos(wallY, wallX, wallN); if (cellY < 0 && wallInfo.CanPass()) { return(false); } if (cellX < 0 || cellX >= BattleModel.Instance.crtBattle.battle_width) { return(true); } if (cellInfo == null) { return(true); } if (cellInfo.isBlindBlank) { return(true); } if (cellInfo.isMonsterHold) { return(true); } bool isCoverOpen = CoverModel.Instance.IsOpen(cellInfo.posX, cellInfo.posY); if (!isCoverOpen) { return(true); } if (cellInfo.isBlank == false && !cellInfo.CanMove()) { return(true); } if (!wallInfo.CanPass()) { return(true); } return(false); }
private void UnlockMonster(bool isJet = false) { List <int> unLockIds = MonsterModel.Instance.UnLock(isJet); MonsterModel.Instance.BackUpUnLockMonster(unLockIds); rootAction = new OrderAction(); for (int j = 0; j < unLockIds.Count; j++) { int monsterRunId = unLockIds[j]; FightMonsterItem monsterItem = monsterLayer.GetItemByRunId(monsterRunId); rootAction.AddNode(new SetLayerActor(monsterItem.transform, effectLayer.transform)); CellInfo monsterCell = new CellInfo(); monsterCell.posX = monsterItem.monsterInfo.posX; monsterCell.posY = monsterItem.monsterInfo.posY; if (isJet) { if (monsterItem.monsterInfo.IsNull()) { CellDirType dirType = WallModel.Instance.GetGapWallDir(monsterCell); int zrotate = PosUtil.GetRotateByDir(dirType); rootAction.AddNode(new RoatateActor((RectTransform)monsterItem.transform, new Vector3(0, 0, zrotate), 0.25f)); } else { rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(1.15f, 1.15f, 1f), 0.2f)); } } List <CellInfo> releaseList = MonsterModel.Instance.ReleaseList(monsterRunId); if (releaseList.Count > 0) { ParallelAction paralle = new ParallelAction(); for (int i = 0; i < releaseList.Count; i++) { CellInfo cellInfo = releaseList[i]; FightCellItem item = GetItemByRunId(cellInfo.runId); if (item == null) { GameObject itemObj = CreateCellItem(cellInfo); item = itemObj.GetComponent <FightCellItem>(); } OrderAction order = new OrderAction(); order.AddNode(new PlaySoundActor("Refresh")); order.AddNode(new ShowEffectLineActor(effectLayer, cellInfo, monsterCell, monsterItem.monsterInfo.releaseId)); order.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0, 0, 0), 0.1f)); order.AddNode(new ChangeCellActor(item, cellInfo, monsterItem.monsterInfo.releaseId)); paralle.AddNode(order); } rootAction.AddNode(paralle); } if (monsterItem.monsterInfo.IsNull()) { rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(1.25f, 1.25f, 0), 0.15f)); if (j == 0) { rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(0, 0, 0), 0.25f)); } else { rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(0, 0, 0), 0.15f)); } } else { rootAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(1, 1, 1), 0.05f)); CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(monsterItem.monsterInfo.posY, monsterItem.monsterInfo.posX); FightCoverItem coverItem = coverLayer.GetItemByRunId(coverInfo.runId); rootAction.AddNode(new ChangeCoverActor(coverLayer, coverItem, coverInfo)); rootAction.AddNode(new ProgressMonsterActor(monsterItem, monsterItem.monsterInfo.progress)); rootAction.AddNode(new SetLayerActor(monsterItem.transform, monsterLayer.transform)); } } if (isJet) { ExecuteAction(FightStadus.jet_monster); } else { ParallelAction paralleTimer = new ParallelAction(); List <CellInfo> timerCells = CellModel.Instance.Timing(); for (int i = 0; i < timerCells.Count; i++) { CellInfo cellInfo = timerCells[i]; FightCellItem item = GetItemByRunId(cellInfo.runId); if (item != null) { OrderAction order = new OrderAction(); order.AddNode(new PlaySoundActor("Refresh")); order.AddNode(new ChangeCellActor(item, cellInfo)); if (cellInfo.isBlank) { order.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0, 0, 0), 0.2f)); order.AddNode(new DestroyActor(item.gameObject)); } paralleTimer.AddNode(order); } } List <CoverInfo> timerCovers = CoverModel.Instance.Timing(); for (int i = 0; i < timerCovers.Count; i++) { CoverInfo coverInfo = timerCovers[i]; FightCoverItem item = coverLayer.GetItemByRunId(coverInfo.runId); OrderAction order = new OrderAction(); order.AddNode(new PlaySoundActor("Refresh")); order.AddNode(new ChangeCoverActor(coverLayer, item, coverInfo)); if (coverInfo.IsNull()) { order.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0, 0, 0), 0.2f)); order.AddNode(new DestroyActor(item.gameObject)); List <CoverInfo> covers = CoverModel.Instance.GetNeighbors(coverInfo); for (int n = 0; n < covers.Count; n++) { CoverInfo cover = covers[n]; if (cover != null) { item = coverLayer.GetItemByRunId(cover.runId); order.AddNode(new ChangeCoverActor(coverLayer, item, cover)); if (cover.config != null) { coverFlowInterrupt = true; } } } } paralleTimer.AddNode(order); } rootAction.AddNode(paralleTimer); if (coverFlowInterrupt) { rootAction.AddNode(new FuncActor(coverLayer.ShowList)); //todo 爆后流动导致多出蜘蛛网 } ExecuteAction(FightStadus.unlock_monster); } }
public List <CellInfo> ReleaseList(int monsterId) { List <CellInfo> releaseList = new List <CellInfo>(); MonsterInfo monster = GetMonsterInfoByRunId(monsterId); if (monster != null && monster.releaseList.Count > 0) { TIVInfo tiv = monster.releaseList[0]; CellModel.Instance.anims = new List <List <CellAnimInfo> >(); List <CellInfo> waitList = new List <CellInfo>(); if ((int)tiv.value <= 0) { CellInfo centerCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY); CellDirType dirType = WallModel.Instance.GetGapWallDir(centerCell); if (dirType != CellDirType.no) { waitList = CellModel.Instance.GetDirCells(centerCell, dirType); } for (int i = 0; i < waitList.Count; i++) { CellInfo cellInfo = waitList[i]; if (cellInfo != null && cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five) { cellInfo.SetConfig((int)tiv.id); releaseList.Add(cellInfo); } } } else { if (monster.progress > 0) { if (monster.progress >= 1) { monster.progress = 0; CellInfo centerCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY); waitList = CellModel.Instance.GetNeighbors(centerCell); for (int i = 0; i < waitList.Count; i++) { CellInfo cellInfo = waitList[i]; if (cellInfo != null && cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five) { cellInfo.SetConfig((int)tiv.id); releaseList.Add(cellInfo); } } } } else if (monster.banCount >= 0) { if (monster.banCount == 0) { CellInfo domnCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY + 1); if (domnCell != null) { if (domnCell.isBlank) { domnCell.SetConfig(monster.releaseId); CellModel.Instance.RemoveFromLines(domnCell.posX, domnCell.posY); releaseList.Add(domnCell); } else { if (domnCell.config.id != monster.releaseId && domnCell.config.cell_type != (int)CellType.terrain) { config_cell_item config_cell = (config_cell_item)ResModel.Instance.config_cell.GetItem(monster.releaseId); bool inHide = false; List <int> hides = config_cell.GetHides(); for (int h = 0; h < hides.Count; h++) { if (domnCell.config.id == hides[h]) { inHide = true; } } if (inHide == false) { domnCell.SetConfig(monster.releaseId); CellModel.Instance.RemoveFromLines(domnCell.posX, domnCell.posY); releaseList.Add(domnCell); } } } } } } else { for (int i = 0; i < BattleModel.Instance.crtBattle.ShowHeight(); i++) { List <CellInfo> xCells = CellModel.Instance.allCells[i]; for (int j = 0; j < xCells.Count; j++) { CellInfo cellInfo = xCells[j]; if (cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five && cellInfo.changer == 0) { if (tiv.id != cellInfo.config.id) { waitList.Add(cellInfo); } } } } int minCount = Mathf.Min((int)tiv.value, waitList.Count); for (int i = 0; i < minCount; i++) { int rangeIndex = Random.Range(0, waitList.Count); CellInfo cellInfo = waitList[rangeIndex]; cellInfo.SetConfig((int)tiv.id); waitList.RemoveAt(rangeIndex); releaseList.Add(cellInfo); } } } } return(releaseList); }
public void RecursionRandomCrawl() { if (crawlCount > 0) { CellInfo centerCell = CellModel.Instance.GetCellByPos(posX, posY); CellInfo findCellPoint = null; List <CellDirType> priorityDirList = PosMgr.PriorityDirList((int)randomCrawlDir, true); for (int i = 0; i < priorityDirList.Count; i++) { CellDirType dir = priorityDirList[i]; CellInfo dirCell = CellModel.Instance.GetDirCell(centerCell, dir); if (dirCell == null) { continue; } if (dirCell.CanCrawl() == false) { continue; } CoverInfo coverInfo = CoverModel.Instance.GetCoverByPos(dirCell.posY, dirCell.posY); if (coverInfo != null && coverInfo.IsOpen() == false) { continue; } WallInfo wall = WallModel.Instance.GetWall(centerCell, dirCell); if (wall.IsNull() == false) { continue; } randomCrawlDir = dir; findCellPoint = dirCell; break; } if (findCellPoint != null) { Hold(false); MonsterInfo toMonsterInfo = MonsterModel.Instance.GetMonsterByPos(findCellPoint.posY, findCellPoint.posX); MonsterModel.Instance.SwitchPos(this, toMonsterInfo); this.SwitchPos(toMonsterInfo); Hold(); crawlCount--; MonsterModel.Instance.AddCrawAnim(this, findCellPoint); if (crawlCount > 0) { //RecursionRandomCrawl(); } } else { crawlCount--; MonsterModel.Instance.AddCrawAnim(this, centerCell); } } }