void Match3Lib.IGameEventsListener.OnCellMove(Match3Lib.Point oldPos, Match3Lib.Point newPos, int gameStep) { AddGameStepAction(gameStep, new System.Action(() => { try { var tempCell = cellItems[oldPos.x, oldPos.y]; cellItems[oldPos.x, oldPos.y] = cellItems[newPos.x, newPos.y]; cellItems[newPos.x, newPos.y] = tempCell; SetCellCallback(oldPos.x, oldPos.y, cellItems[oldPos.x, oldPos.y]); SetCellCallback(newPos.x, newPos.y, cellItems[newPos.x, newPos.y]); if (cellItems[oldPos.x, oldPos.y] != null) { var cellItemsAmin = cellItems[oldPos.x, oldPos.y].GetComponent <Animation>(); if (cellItemsAmin != null) { if (cellItemsAmin.GetClip(movingAnimationName) != null) { cellItemsAmin.RemoveClip(movingAnimationName); } var movingClip = GetMovingClip(newPos.x, newPos.y, oldPos.x, oldPos.y, Width, Height, moveDelay); cellItemsAmin.AddClip(movingClip, movingAnimationName); cellItemsAmin.Play(movingAnimationName); } } if (cellItems[newPos.x, newPos.y] != null) { var cellItemsAmin = cellItems[newPos.x, newPos.y].GetComponent <Animation>(); if (cellItemsAmin != null) { if (cellItemsAmin.GetClip(movingAnimationName) != null) { cellItemsAmin.RemoveClip(movingAnimationName); } var movingClip = GetMovingClip(oldPos.x, oldPos.y, newPos.x, newPos.y, Width, Height, moveDelay); cellItemsAmin.AddClip(movingClip, movingAnimationName); cellItemsAmin.Play(movingAnimationName); } } } finally { Invoke("GameStepActionDone", moveDelay); } })); }
void Match3Lib.IGameEventsListener.OnCellCreate(Match3Lib.Point point, int cellType, int gameStep) { AddGameStepAction(gameStep, new System.Action(() => { var movingDelay = createDelay * (Height + point.y); try { cellItems[point.x, point.y] = CopyCell(cellItemPrefabs[cellType], gameItemsPanel, point.x, point.y, Width, Height); SetCellCallback(point.x, point.y, cellItems[point.x, point.y]); MoveCellByAnim(point.x, Height + point.y, point.x, point.y, Width, Height, movingDelay, cellItems[point.x, point.y]); } finally { Invoke("GameStepActionDone", movingDelay); } })); }
void Match3Lib.IGameEventsListener.OnCellDestroy(Match3Lib.Point point, int gameStep) { AddGameStepAction(gameStep, new System.Action(() => { try { var bangItem = Instantiate(cellBangItemPrefab); var bangItemTransform = bangItem.GetComponent <RectTransform>(); bangItemTransform.parent = bangItemsPanel; bangItemTransform.offsetMin = cellItems[point.x, point.y].GetComponent <RectTransform>().offsetMin; bangItemTransform.offsetMax = cellItems[point.x, point.y].GetComponent <RectTransform>().offsetMax; MoveToCell(point.x, point.y, Width, Height, ref bangItemTransform); Destroy(cellItems[point.x, point.y]); } finally { Invoke("GameStepActionDone", destroyDelay); } })); }