//移动 public static List <CellMoveInfo> Move(List <int> newPos) { List <CellMoveInfo> moveAnims = new List <CellMoveInfo>(); //fill int n = newPos.Count - 1; for (; n >= 0; n--) { int newIndex = newPos[n]; CellInfo moveCell = blanckCells[newIndex]; moveCell.isBlank = false; blanckCells.RemoveAt(newIndex); moveCells.Add(moveCell); AddMoveAnim(moveCell, moveAnims); } RecursionMove(moveAnims); for (n = 0; n < moveAnims.Count; n++) { CellMoveInfo moveAnim = moveAnims[n]; moveAnim.CutTail(); } return(moveAnims); }
private void Filling(FightStadus fightState = FightStadus.move, int waitmillisecond = 0) { CellModel.Instance.anims = new List <List <CellAnimInfo> >(); FunMove.Move(false, isDeductStep); List <CellMoveInfo> moveAnims = CellModel.Instance.moveAnims; rootAction = new OrderAction(); ParallelAction paralle = new ParallelAction(); Dictionary <int, int> newStartPos = new Dictionary <int, int>(); for (int i = 0; i < moveAnims.Count; i++) { CellMoveInfo cellMoveInfo = moveAnims[i]; OrderAction orderAction = new OrderAction(); paralle.AddNode(orderAction); FightCellItem item = GetItemByRunId(cellMoveInfo.cellInfo.runId); if (item == null) { item = CreateCellItem(cellMoveInfo.cellInfo).GetComponent <FightCellItem>(); int xKey = (int)cellMoveInfo.paths[0].x; if (newStartPos.ContainsKey(xKey)) { int preIndex = newStartPos[xKey]; newStartPos[xKey] = preIndex - 1; } else { newStartPos.Add(xKey, -1); } PosUtil.SetFightCellPos(item.transform, xKey, newStartPos[xKey]); } for (int j = 0; j < cellMoveInfo.paths.Count; j++) { Vector2 pathPoint = cellMoveInfo.paths[j]; Vector2 toPos = PosUtil.GetFightCellPos((int)pathPoint.x, (int)pathPoint.y); float speed = isDeductStep ? 1750 : 1350; orderAction.AddNode(new MoveActor((RectTransform)item.transform, new Vector3(toPos.x, toPos.y, 0), speed)); } FightEffectItem effectItem = effectLayer.GetEffectItemByPos(cellMoveInfo.cellInfo.posX, cellMoveInfo.cellInfo.posY); orderAction.AddNode(new PlayCellMoveEndActor(item, effectItem, cellMoveInfo.cellInfo)); } if (waitmillisecond > 0) { rootAction.AddNode(new WaitActor(waitmillisecond)); } rootAction.AddNode(paralle); ExecuteAction(fightState); }
private static void AddMoveAnim(CellInfo cellInfo, List <CellMoveInfo> moveAnims) { int i; for (i = 0; i < moveAnims.Count; i++) { CellMoveInfo cellMoveInfo = moveAnims[i]; if (cellMoveInfo.cellInfo.runId == cellInfo.runId) { cellMoveInfo.AddFixPath(cellInfo.posX, cellInfo.posY); return; } } CellMoveInfo addMoveInfo = new CellMoveInfo(); addMoveInfo.cellInfo = cellInfo; addMoveInfo.AddFixPath(cellInfo.posX, cellInfo.posY); moveAnims.Add(addMoveInfo); }
private void Filling(List <CellMoveInfo> moveAnims, FightStadus fightState = FightStadus.move, int waitmillisecond = 0) { rootAction = new OrderAction(); ParallelAction paralle = new ParallelAction(); for (int i = 0; i < moveAnims.Count; i++) { CellMoveInfo cellMoveInfo = moveAnims[i]; OrderAction orderAction = new OrderAction(); paralle.AddNode(orderAction); GameObject item = ballLayer.CreateBaseItem((int)cellMoveInfo.paths[0].x, -1); for (int j = 0; j < cellMoveInfo.paths.Count; j++) { ParallelAction paralleMove = new ParallelAction(); orderAction.AddNode(paralleMove); Vector2 pathPoint = cellMoveInfo.paths[j]; Vector2 toPos = PosMgr.GetFightCellPos((int)pathPoint.x, (int)pathPoint.y); paralleMove.AddNode(new MoveActor((RectTransform)item.transform, new Vector3(toPos.x, toPos.y, 0), 0, 0.2f)); if (j > 0) { Vector2 fromPoint = cellMoveInfo.paths[j - 1]; Vector2 fromPos = PosMgr.GetFightCellPos((int)fromPoint.x, (int)fromPoint.y); OrderAction orderRot = new OrderAction(); GameObject itembarrier = barrierLayer.GetItemByPos((int)fromPoint.x, (int)fromPoint.y); if (itembarrier != null) { if (fromPos.x > toPos.x) { orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, -60), 0.15f)); orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, 0), 0.05f)); paralleMove.AddNode(orderRot); paralleMove.AddNode(new RoatateActor((RectTransform)item.transform, new Vector3(0, 0, -30), 0.2f)); } if (fromPos.x < toPos.x) { orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, 60), 0.15f)); orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, 0), 0.05f)); paralleMove.AddNode(orderRot); paralleMove.AddNode(new RoatateActor((RectTransform)item.transform, new Vector3(0, 0, 30), 0.2f)); } } List <TIVInfo> p = new List <TIVInfo>(); TIVInfo px = new TIVInfo(); px.value = pathPoint.x; TIVInfo py = new TIVInfo(); py.value = pathPoint.y; p.Add(px); p.Add(py); if (fromPos.x > toPos.x) { paralleMove.AddNode(new FuncTIVActor(Harvest, p)); } if (fromPos.x < toPos.x) { paralleMove.AddNode(new FuncTIVActor(Harvest, p)); } } } BallBaseItem itemCtr = item.GetComponent <BallBaseItem>(); orderAction.AddNode(new PlayBallMoveEndActor(itemCtr)); } if (waitmillisecond > 0) { rootAction.AddNode(new WaitActor(waitmillisecond)); } rootAction.AddNode(paralle); ExecuteAction(fightState); }