IEnumerator OnMouseClicked() { #if UNITY_ANDROID int touchCount = Input.touchCount; if (touchCount == 0) { yield return(null); } else { for (int j = 0; j < touchCount; j++) { Touch touch = Input.GetTouch(j); Vector2 touchPos = touch.position; if (touch.phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay(touchPos); RaycastHit2D hit = Physics2D.GetRayIntersection(ray, 100f); if (hit.collider && hit.transform.CompareTag("Block")) { Block hitBlock = hit.transform.GetComponent <Block>(); StartCoroutine(GettingAchievement()); if (hitBlock.IsBreakable) { hitBlock.Hp--; iTween.ShakePosition(hitBlock.gameObject, iTween.Hash("name", "blockShake" , "x", 0.1f , "y", 0.1f , "time", 0.05f , "oncomplete", "hitBlock.ResetInitPos" , "oncompletetarget", hitBlock.gameObject)); StartCoroutine(PlaySfx(hitSound)); if (hitBlock.Hp <= 0) { BlockFloor hitBlockFloor = hitBlock.GetComponentInParent <BlockFloor>(); for (int i = 0; i < hitBlockFloor.Block.Length; i++) { iTween.StopByName(hitBlockFloor.Block[i].gameObject, "blockShake"); } hitBlockFloor.ResetLocalPosition(); hitBlockFloor.SetBlocksBreakable(false); hitBlock.gameObject.SetActive(false); if (hitBlock.BlockProperty == BlockType.bomb) { UIMgr.OnGameOver(); } blockStack.Push(BlockMove()); } } } } } } #endif #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.GetRayIntersection(ray, 100f); if (hit.collider && hit.transform.CompareTag("Block")) { Block hitBlock = hit.transform.GetComponent <Block>(); if (hitBlock.IsBreakable) { hitBlock.Hp--; iTween.ShakePosition(hitBlock.gameObject, iTween.Hash("name", "blockShake" , "x", 0.1f , "y", 0.1f , "time", 0.05f , "oncomplete", "hitBlock.ResetInitPos" , "oncompletetarget", hitBlock.gameObject)); StartCoroutine(PlaySfx(hitSound)); if (hitBlock.Hp <= 0) { BlockFloor hitBlockFloor = hitBlock.GetComponentInParent <BlockFloor>(); for (int i = 0; i < hitBlockFloor.Block.Length; i++) { iTween.StopByName(hitBlockFloor.Block[i].gameObject, "blockShake"); } hitBlockFloor.ResetLocalPosition(); hitBlockFloor.SetBlocksBreakable(false); hitBlock.gameObject.SetActive(false); if (hitBlock.BlockProperty == BlockType.bomb) { UIMgr.OnGameOver(); } blockStack.Push(BlockMove()); } } } } #endif yield return(null); }