private void SwapBlockProcess(HexaBlockUnit blockUnit) { if (blockUnit == null) { return; } if (startHexaBlockUnit == null) { startHexaBlockUnit = blockUnit; return; } if (startHexaBlockUnit == blockUnit) { return; } Block targetBlock = blockUnit.GetBlock(); Block startBlock = startHexaBlockUnit.GetBlock(); if (!startBlock.CheckAdjacencyBlock(targetBlock)) { return; } targetHexaBlockUnit = blockUnit; PlaySwapBlockProcess(isRevert: false); isSwapAnimation = true; }
public bool CheckSelectBlock() { #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { isTouch = true; } else if (Input.GetMouseButtonUp(0)) { isTouch = false; } #else if (Input.touchCount > 0) { isTouch = true; } else if (Input.touchCount == 0) { isTouch = false; } #endif if (!isTouch) { return(false); } #if UNITY_EDITOR Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); #else Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); #endif RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { Transform target = hit.collider.transform; HexaBlockUnit blockUnit = target.GetComponent <HexaBlockUnit>(); onEventRayHitBlock(blockUnit); } return(true); }
private void ClearBlockUnits() { startHexaBlockUnit = null; targetHexaBlockUnit = null; }
private IEnumerator BoomBlockProcess() { StopSwapAnimation(); RefreshBlockUnits(); Block startBlock = startHexaBlockUnit == null ? null : startHexaBlockUnit.GetBlock(); Block targetBlock = targetHexaBlockUnit == null ? null : targetHexaBlockUnit.GetBlock(); if (matchingModel.CheckUFOBlocksBoom(startBlock, targetBlock)) { RefreshBlockUnits(); yield return(new WaitForSeconds(BOOM_DELAY)); } if (matchingModel.CheckFirecrackerBoom()) { BoomBlockUnits(); yield return(new WaitForSeconds(BOOM_DELAY)); } BoomBlockUnits(); yield return(new WaitForSeconds(BOOM_DELAY)); startHexaBlockUnit = null; targetHexaBlockUnit = null; matchingModel.CheckBoomAftermath(); stageTopMenuUnit.RefreshQuestIcon(mapModel.GetQuestBlockCount()); matchingModel.FindingDownPathProcess(); yield return(MoveBlockProcess()); matchingModel.CreateBlockProcess(); while (true) { if (matchingModel.FindingWidthPathProcess()) { continue; } break; } yield return(new WaitForSeconds(0.1f)); yield return(MoveBlockProcess()); matchingModel.CreateBlockProcess(); matchingModel.ResetBlockBoomFlag(); RefreshBlockUnits(); ResultType resultType = matchingModel.GetResultType(moveCount); switch (resultType) { case ResultType.Complete: { objGameResult.SetActive(true); txtGameResult.text = "클리어!"; break; } case ResultType.Fail: { objGameResult.SetActive(true); txtGameResult.text = "실패!"; break; } default: { int loop = 0; while (true) { if (matchingModel.CheckAllMatchingProcess()) { StartCoroutine(BoomBlockProcess()); break; } else if (matchingModel.CheckPossibleSwapBlocks()) { ClearBlockUnits(); ClearTouchFlag(); break; } else { mapModel.RefreshBlocks(isCheck: false); } loop++; if (loop >= REFRESH_LOOP_MAX) { break; } } break; } } }