public void InitRoadCrawl() { CellInfo centerCell = CellModel.Instance.GetCellByPos(posX, posY); List <CellInfo> cellNeighbors = CellModel.Instance.GetNeighbors(centerCell); CellInfo findCellPoint = null; for (int i = 0; i < cellNeighbors.Count; i++) { CellInfo cellNeighbor = cellNeighbors[i]; if (cellNeighbor == null) { continue; } BattleCellInfo bcellInfo = BattleModel.Instance.crtBattle.GetBattleCellByPos(cellNeighbor.posX, cellNeighbor.posY); if (bcellInfo.bg_id != special1) { continue; } findCellPoint = cellNeighbor; Vector2 fromPos = PosUtil.GetFightCellPos(posX, posY); Vector2 toPos = PosUtil.GetFightCellPos(findCellPoint.posX, findCellPoint.posY); rotate = PosUtil.VectorAngle(new Vector2(fromPos.x, fromPos.y), new Vector2(toPos.x, toPos.y)) / FightConst.ROTATE_BASE; break; } }
public void ShowLine(CellInfo cellA, CellInfo cellB) { GameObject item = list.NewItem(); item.name = cellA.posX + "_" + cellA.posY + "_" + cellB.posX + "_" + cellB.posY; PosUtil.SetFightCellPos(item.transform, cellA.posX, cellA.posY); item.transform.Rotate(0, 0, PosUtil.VectorAngle(PosUtil.GetFightCellPos(cellA.posX, cellA.posY), PosUtil.GetFightCellPos(cellB.posX, cellB.posY))); }
public GameObject ShowLine(CellInfo cellA, CellInfo cellB) { list.ForceChangeItemPrefab(lineItem); GameObject item = list.NewItem(); item.name = cellA.posX + "_" + cellA.posY + "_" + cellB.posX + "_" + cellB.posY; PosUtil.SetFightCellPos(item.transform, cellB.posX, cellB.posY); item.transform.Rotate(0, 0, PosUtil.VectorAngle(PosUtil.GetFightCellPos(cellB.posX, cellB.posY), PosUtil.GetFightCellPos(cellA.posX, cellA.posY))); return(item); }
private void BuggerAppear() { float angle = PosUtil.VectorAngle(pos.fromPos, pos.toPos); cellRect.localRotation = Quaternion.Euler(0, 0, angle - 90); RectTransform rectTransform = (RectTransform)transform; rectTransform.anchoredPosition = new Vector2(pos.fromPos.x, pos.fromPos.y); if (iconId > 0) { icon.overrideSprite = ResModel.Instance.GetSprite("icon/cell/cell_" + iconId); } else { int randomValue = UnityEngine.Random.Range(10101, 10106); icon.overrideSprite = ResModel.Instance.GetSprite("icon/cell/cell_" + randomValue); } LeanTween.move(rectTransform, pos.toPos, move.appearTime).onComplete = AppearComplete; }
private void Crawl() { rootAction = new OrderAction(); if (!isDeductStep) { MonsterModel.Instance.Crawl(); List <MonsterCrawlInfo> crawAnims = MonsterModel.Instance.crawAnims; rootAction = new OrderAction(); ParallelAction paralle = new ParallelAction(); for (int i = 0; i < crawAnims.Count; i++) { MonsterCrawlInfo crawAnim = crawAnims[i]; OrderAction orderAction = new OrderAction(); paralle.AddNode(orderAction); FightMonsterItem monsterItem = monsterLayer.GetItemByRunId(crawAnim.monster.runId); for (int j = 0; j < crawAnim.pathCells.Count; j++) { CellInfo pathCell = crawAnim.pathCells[j]; Vector2 toPos = PosUtil.GetFightCellPos(pathCell.posX, pathCell.posY); float zrotate = 0; if (j > 0) { Vector2 fromPos = PosUtil.GetFightCellPos(crawAnim.pathCells[j - 1].posX, crawAnim.pathCells[j - 1].posY); zrotate = PosUtil.VectorAngle(new Vector2(fromPos.x, fromPos.y), new Vector2(toPos.x, toPos.y)); } else { Vector2 anchoredPos = ((RectTransform)monsterItem.transform).anchoredPosition; zrotate = PosUtil.VectorAngle(new Vector2(anchoredPos.x, anchoredPos.y), new Vector2(toPos.x, toPos.y)); } orderAction.AddNode(new RotationActor((RectTransform)monsterItem.transform, zrotate)); float speed = 600; orderAction.AddNode(new MoveActor((RectTransform)monsterItem.transform, new Vector3(toPos.x, toPos.y, 0), speed)); if (pathCell.isBlank == false) { FightCellItem cellItem = GetItemByRunId(pathCell.runId); pathCell.SetConfig((int)crawAnim.monster.releaseList[0].id); pathCell.changer = 0; orderAction.AddNode(new ChangeCellActor(cellItem, pathCell)); } } if (crawAnim.roadEnd) { orderAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(0, 0, 0), 0.3f)); orderAction.AddNode(new ChangeMonsterActor(monsterItem, crawAnim.monster)); } } rootAction.AddNode(paralle); } ExecuteAction(FightStadus.crawl); }