void Update() { if (!IsPlaying) { return; } CountTime += Time.deltaTime; if (IsLock) { return; } if (Input.GetMouseButtonDown(0)) { if (_tapTheBlockToRotate.activeSelf) { HideTabTheBlockToRotate(); } if (_theHiddenBlockCanBeRotated.activeSelf) { _theHiddenBlockCanBeRotated.SetActive(false); } _mouseDownPosition = GetMousePosition(); } else if (Input.GetMouseButton(0)) { if (_curBlock == null) { //Debug.Log("_mouseDownPosition" + _mouseDownPosition); float leng = Vector2.Distance(_mouseDownPosition, GetMousePosition()); if (leng >= .05f) { RaycastHit2D hit = Physics2D.Raycast(GetMousePosition(), Vector3.zero, 10, _setPositionLayer); if (hit.collider != null) { if (hit.collider.transform.childCount > 0) { // get block _curBlock = hit.collider.transform.GetChild(0).GetComponent <Block>(); if (_curBlock.CanUse) { _curBlock.ActiveBlock(); SoundController.Instance.PlaySoundEffect(SoundController.Instance.PickItem); } else { _curBlock = null; } } } } } if (_curBlock != null) { _mousePosition = GetMousePosition(); _curBlock.transform.position = _mousePosition + _moveOffset; _curBlock.UpdateBlock(); // Display can clear DisplayCanClear(); } } if (Input.GetMouseButtonUp(0)) { if (_curBlock != null) { if (_curBlock.IsPlacable && _curBlock.transform.localScale.x >= BigScale.x) { _curBlock.ApplyBlock(); CountBlock++; //Debug.Log("CountBlock " + CountBlock); //ShakeCam2(); IsLock = true; DOVirtual.DelayedCall(.3f, () => { // Check full CheckFull(); if (CheckEmptySet()) { SaveGame.instance.deleteList(); // New new three blocks CreateThreeBlock(); } else { // Check gameover if (CheckGamever()) { SaveGame.instance.deleteList(); // Show gameover Debug.Log("GAMEOVER"); _theHiddenBlockCanBeRotated.SetActive(false); ShowGameover(); } } IsLock = false; }); } else { _curBlock.MoveToContainer(); } _curBlock = null; } else { float leng = Vector2.Distance(_mouseDownPosition, GetMousePosition()); if (leng < .5f) { RaycastHit2D hit = Physics2D.Raycast(GetMousePosition(), Vector3.zero, 10, _setPositionLayer); if (hit.collider != null) { if (hit.collider.transform.childCount > 0) { // get block var block = hit.collider.transform.GetChild(0).GetComponent <Block>(); if (!block.IsRotate) { if (NumRotate > 0 && block.Items.Count > 1) { block.IsRotate = true; block.RotateIcon.SetActive(true); NumRotate--; block.RotateBlock(); // Check numrotate if (NumRotate <= 0) { _btnGetMoveRotate.SetActive(true); _getMoreRotateAnim.Play("Start"); } } else { _getMoreRotateAnim.Play("Show", 0, 0); } } else { block.RotateBlock(); } } } } } } }