public void Installation() { Vector3 touchStartPos = GodTouch.GetPosition(); GameObject copyObj = Instantiate(Gameobj, touchStartPos, Quaternion.identity); copyObj.GetComponent <MouseStalker>().touchStartPos = touchStartPos; }
private void Update() { var phase = GodTouch.GetPhase(); var pos = GodTouch.GetPosition(); var delta = GodTouch.GetDeltaPosition(); switch (phase) { case GodPhase.Began: newPosition = MainCamera.transform.position; lastMousePosition = Input.mousePosition; break; case GodPhase.Moved: newPosition.x -= (Input.mousePosition.x - lastMousePosition.x) * 0.1f; newPosition.z -= (Input.mousePosition.y - lastMousePosition.y) * 0.1f; newPosition.x = Mathf.Clamp(newPosition.x, x_Min, x_Max); newPosition.z = Mathf.Clamp(newPosition.z, z_Min, z_Max); MainCamera.gameObject.transform.position = newPosition; lastMousePosition = Input.mousePosition; break; } }
// プレイヤーがピースを選択しているときの処理、入力終了を検知したらReleaseWaitに移行する private void BlockMove() { if (remainTime == 0) { ReleaseBlock(); } else { if (replay) { if (replayIdx < replayData[0].InputCount && replayData[0].InputFrame[replayIdx] == frame) { if (replayData[0].InputType[replayIdx] == (byte)InputType.Move) { // ボードの処理 Vector3 inputPos = board.GetBlockWorldPos(new Vector2(replayData[0].InputData1[replayIdx], replayData[0].InputData2[replayIdx])); Block block = board.board[replayData[0].InputData1[replayIdx], replayData[0].InputData2[replayIdx]]; board.SwitchBlock(selectedBlock, block); movingBlockObject.transform.position = inputPos + Vector3.up * 10; replayIdx++; } else if (replayData[0].InputType[replayIdx] == (byte)InputType.Release) { ReleaseBlock(); replayIdx++; } } } else { GodPhase phase = GodTouch.GetPhase(); if (phase == GodPhase.Moved) { Block block = board.GetNearestBlock(GodTouch.GetPosition()); if (block != selectedBlock) { // リプレイの処理 inputFrame.Add(frame); inputType.Add((int)InputType.Move); Vector2 pos = board.GetBlockBoardPos(block); inputData1.Add((byte)pos.x); inputData2.Add((byte)pos.y); // ボードの処理 board.SwitchBlock(selectedBlock, block); } movingBlockObject.transform.position = GodTouch.GetPosition() + Vector3.up * 10; } else if (phase == GodPhase.Ended) { ReleaseCount = 0; currentState = PuzzleState.ReleaseWait; } } } board.HasMatch(); }
// ピースを選択する処理 private void SelectBlock() { Vector3 inputPos; if (replay) { inputPos = board.GetBlockWorldPos(new Vector2(replayData[0].InputData1[replayIdx], replayData[0].InputData2[replayIdx])); selectedBlock = board.board[replayData[0].InputData1[replayIdx], replayData[0].InputData2[replayIdx]]; replayIdx++; } else { // クリック位置取得 inputPos = GodTouch.GetPosition(); // 盤外なら処理しない if (board.IsInputOut(inputPos)) { return; } // 近くのブロックを取得 selectedBlock = board.GetNearestBlock(inputPos); // 練習の書込モードの場合、書き込んで処理終了 if (writeBlock) { selectedBlock.SetKind(writeBlockKind); selectedBlock.garbageKind = writeGarbageKind; return; } // お邪魔は選択できない if (selectedBlock.garbageKind != GarbageKind.None) { return; } // リプレイの処理 inputFrame.Add(frame); inputType.Add((int)InputType.Select); Vector2 pos = board.GetBlockBoardPos(selectedBlock); inputData1.Add((byte)pos.x); inputData2.Add((byte)pos.y); } // ボードの処理 selectedBlock.SetBlockAlpha(0f); selectedBlock.selectFlag = true; var block = board.InstantiateBlock(inputPos); block.SetKind(selectedBlock.GetKind()); block.SetSize((int)(board.blockWidth * 1.2f)); movingBlockObject = block.gameObject; currentState = PuzzleState.BlockMove; }
public void TouchJudg() { var phase = GodTouch.GetPhase(); var pos = GodTouch.GetPosition(); switch (phase) //if(Input.GetMouseButtonDown(0)) { case GodPhase.Began: // 押された RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (EventSystem.current.IsPointerOverGameObject()) { break; } if (Input.touchCount > 0 && EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) { // かぶさってるので処理キャンセル(タップver) break; } if (Physics.Raycast(ray, out hit, maxDistance)) { // レイに当たったオブジェクトに何かをする if (hit.transform.tag == "Test" && gimmick != Gimmick.Normal && remaining[(int)gimmick] != 0) { hit.transform.tag = tag; hit.collider.GetComponent <Renderer>().material = mat; remaining[(int)gimmick]--; text[(int)gimmick].text = remaining[(int)gimmick].ToString(); sound1.PlayOneShot(sound1.clip); if (remaining[(int)gimmick] == 0) { selecting[(int)gimmick].GetComponentInChildren <Image>().color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 100.0f / 255.0f); } else { selecting[(int)gimmick].GetComponentInChildren <Image>().color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f); } gimmick = Gimmick.Normal; tag = gimmick.ToString(); mat = matArray[(int)gimmick]; tutorialPlayer.StopReset(); } } break; } }
/// ******************************************************* /// <summary>更新処理</summary> /// ******************************************************* void Update() { GodPhase phase = GodTouch.GetPhase(); Vector3 pos = Camera.main.ScreenToWorldPoint(GodTouch.GetPosition()); pos.z = 0; switch (phase) { case GodPhase.Began: EnableButton = false; Vector3 press = pos - Center; float distance = (press.x * press.x) + (press.y * press.y); if (distance < (ButtonWidth * ButtonWidth)) { StartPos = pos; Position = Center; EnableButton = true; } break; case GodPhase.Stationary: case GodPhase.Moved: if (EnableButton) { Vector3 move = pos - StartPos; float movepos = (move.x * move.x) + (move.y * move.y); if (movepos > (MoveWidth * MoveWidth)) { move = Vector3.Normalize(move) * MoveWidth; } Position = Center + move; float dst = move.magnitude / MoveWidth; float rad = Mathf.Atan2(move.x, move.y); PlayerControll.Instance.OnShot(rad, dst); } break; case GodPhase.Ended: EnableButton = false; Position = Center; break; } UpdateBombCount(); }