IEnumerator CoWaitDrag(Vector3 initPos) { isReady = false; while (true) { if (Input.GetMouseButtonUp(0)) { break; } var mousePos = InputEx.GetMouseWorld(); float distance = Vector3.Distance(initPos, mousePos); if (distance > Global.DRAG_DISTANCE) { //드래그 완료 Direction dir = BoardUtil.GetDirection(initPos, mousePos); Block changeBlock = BlockManager.instance.GetNeighbor(selectBlock, dir); if (changeBlock == null) { break; } //블록 스왑 yield return(StartCoroutine(BlockManager.instance.CoSwapBlock(selectBlock, changeBlock))); var selectInfos = MatchManager.instance.Check(selectBlock); var targetInfos = MatchManager.instance.Check(changeBlock); curMatchInfos = MatchUtil.Distinct(selectInfos.Union(targetInfos).ToList()); //스왑 실패 (Undo) if (curMatchInfos.Count == 0) { Debug.Log("Swap Fail"); yield return(StartCoroutine(BlockManager.instance.CoUndoSwap())); break; } //중력 적용 후 맵 생성 (추가 Match가 없을때까지 반복) while (true) { if (curMatchInfos.Count == 0) { break; } BlockManager.instance.DestoryBlocks(MatchUtil.GetCoordsAll(curMatchInfos)); yield return(StartCoroutine(BlockManager.instance.CoApplyGravityAndGenerateMap())); curMatchInfos = MatchManager.instance.CheckAll(); } break; } yield return(null); } if (BlockManager.instance.totalTopCount == 0) { Debug.Log("Win!"); } //초기화 selectBlock = null; isReady = true; }