bool QueryAxisFire2() { if (VirtualAxisManager.GetAxisDown("Fire2")) { prevMousePos = currentMousePos = originalMousePos = GetMousePos(); fire2TouchTimer = 0; Rotating = false; return(true); } else if (VirtualAxisManager.GetAxis("Fire2")) { currentMousePos = GetMousePos(); if (Rotating) { var dirVector = currentMousePos - prevMousePos; var xRot = -dirVector[1] * rotateSpeed * Time.deltaTime; var newEulerAngle0 = Camera.main.transform.localRotation.eulerAngles[0] + xRot; Camera.main.transform.RotateAround(pivotPos, Vector3.up, dirVector[0] * rotateSpeed * Time.deltaTime); if (newEulerAngle0 <= 90 || newEulerAngle0 >= 270) { Camera.main.transform.RotateAround(pivotPos, Camera.main.transform.right, xRot); } } if (fire2TouchTimer >= 0) { fire2TouchTimer += Time.deltaTime; if (fire2TouchTimer > fire2TouchTime || Mathf.Abs(currentMousePos[0] - originalMousePos[0]) > fire2TouchOffset || Mathf.Abs(currentMousePos[1] - originalMousePos[1]) > fire2TouchOffset) { fire2TouchTimer = -1; Rotating = true; } } prevMousePos = currentMousePos; return(true); } else if (VirtualAxisManager.GetAxisUp("Fire2")) { fire2TouchTimer = -1; return(true); } return(false); }
bool QueryAxisFire3() { if (VirtualAxisManager.GetAxisDown("Fire3")) { prevMousePos = currentMousePos = originalMousePos = GetMousePos(); fire3TouchTimer = 0; Dragging = false; return(true); } else if (VirtualAxisManager.GetAxis("Fire3")) { currentMousePos = GetMousePos(); if (Dragging) { var prevCamPos = Camera.main.transform.position; var temp = currentMousePos - prevMousePos; var dirVector = Camera.main.transform.right * temp[0] + Camera.main.transform.up * temp[1]; Camera.main.transform.position -= dirVector * (dragSpeed * Time.deltaTime); pivotPos += Camera.main.transform.position - prevCamPos; pivot.transform.position = pivotPos; } if (fire3TouchTimer >= 0) { fire3TouchTimer += Time.deltaTime; if (fire3TouchTimer > fire3TouchTime || Mathf.Abs(currentMousePos[0] - originalMousePos[0]) > fire3TouchOffset || Mathf.Abs(currentMousePos[1] - originalMousePos[1]) > fire3TouchOffset) { fire3TouchTimer = -1; Dragging = true; } } prevMousePos = currentMousePos; return(true); } else if (VirtualAxisManager.GetAxisUp("Fire3")) { fire3TouchTimer = -1; return(true); } return(false); }
void HandleBlockCloning(EnumCloningMode _mode = EnumCloningMode.alongCol) { RaycastHit raycastHit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out raycastHit)) { var target = raycastHit.collider.gameObject; if (target.CompareTag("Block")) { var block = target.GetComponent <Block>(); if (VirtualAxisManager.GetAxisUp("Fire1")) { CloneMapAnotherHalf(block, _mode); } if (Block.SelectedBlock != null && block == Block.SelectedBlock) { return; } Block.SelectedBlock = block; Block.UnhighlightAll(); HighlightMapHalf(block, _mode); }// if (target.CompareTag("Block")) else { Block.SelectedBlock = null; Block.UnhighlightAll(); } } else { Block.SelectedBlock = null; Block.UnhighlightAll(); } }
void HandleBlockPlacing() { RaycastHit raycastHit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out raycastHit)) { var target = raycastHit.collider.gameObject; if (target.CompareTag("Block")) { var block = target.GetComponent <Block>(); if (VirtualAxisManager.GetAxis("Fire1")) { blockPlacingTimer += Time.deltaTime; if (blockPlacingTimer > blockPlacingTime) { blockPlacingTimer = 0; } else { goto Proc0; } var targetBlock = target.GetComponent <Block>(); var downRay = Utility.GetBlockDownwardRay(targetBlock, raycastHit.point, GapWidth); if (Physics.Raycast(downRay, out raycastHit)) { var target0 = raycastHit.collider.gameObject; if (target0.CompareTag("Block")) { var targetBlock0 = target0.GetComponent <Block>(); int row, col, height; if (targetBlock.Row == targetBlock0.Row && targetBlock.Col == targetBlock0.Col) { if (targetBlock.Height == targetBlock0.Height) { row = targetBlock.Row; col = targetBlock.Col; height = targetBlock.Height + 1; } else { row = targetBlock.Row; col = targetBlock.Col; height = targetBlock.Height - 1; } } else { row = targetBlock0.Row; col = targetBlock0.Col; height = targetBlock.Height; } if (Block.Occupied(row, col, height)) { goto Proc0; } target = PlaceBlock(row, col, height, CurrentBlockIndex).gameObject; } // if (target0.CompareTag("Block")) } // if (Physics.Raycast(downRay, out raycastHit)) } // if (VirtualAxisManager.GetAxis("Fire1")) else if (VirtualAxisManager.GetAxisUp("Fire2")) { if (CameraManager.Ins.Rotating || target.GetComponent <Block>().Height == 0) { goto Proc0; } block.GetDestroyed(); } else { blockPlacingTimer = blockPlacingTime; } Proc0: if (Block.SelectedBlock == block) { return; } if (Block.SelectedBlock != null) { Block.SelectedBlock.GetUnhighlighted(); } if (target != null) { (Block.SelectedBlock = target.GetComponent <Block>()).GetHighlighted(); } }// if (target.CompareTag("Block")) else { DeselectAllBlocks(); } } else { DeselectAllBlocks(); } }