public FlickGestureDetector() { this.MinSpeed = 0.4f * UISystem.Dpi; this.MaxSpeed = 8f * UISystem.Dpi; this.Direction = FlickDirection.All; this.Initialize(); }
private void FlickCLC() // 入力内容からフリック方向を計算 { Vector2 _work = new Vector2((new Vector3(InputEND.x, 0, 0) - new Vector3(InputMOVE.x, 0, 0)).magnitude, (new Vector3(0, InputEND.y, 0) - new Vector3(0, InputMOVE.y, 0)).magnitude); if (_work.x <= FlickMinRange.x && _work.y <= FlickMinRange.y) { NowFlick = FlickDirection.TAP; } else { float _angle = Mathf.Atan2(InputEND.y - InputMOVE.y, InputEND.x - InputMOVE.x) * Mathf.Rad2Deg; if (-22.5f <= _angle && _angle < 22.5f) { NowFlick = FlickDirection.RIGHT; } else if (22.5f <= _angle && _angle < 67.5f) { NowFlick = FlickDirection.UP_RIGHT; } else if (67.5f <= _angle && _angle < 112.5f) { NowFlick = FlickDirection.UP; } else if (112.5f <= _angle && _angle < 157.5f) { NowFlick = FlickDirection.UP_LEFT; } else if (157.5f <= _angle || _angle < -157.5f) { NowFlick = FlickDirection.LEFT; } else if (-157.5f <= _angle && _angle < -112.5f) { NowFlick = FlickDirection.DOWN_LEFT; } else if (-112.5f <= _angle && _angle < -67.5f) { NowFlick = FlickDirection.DOWN; } else if (-67.5f <= _angle && _angle < -22.5f) { NowFlick = FlickDirection.DOWN_RIGHT; } } if (SwipeRange.x > SwipeRange.y) { flickSpeedFirst = SwipeRange.x; flickSpeed = SwipeRange.x; } else { flickSpeedFirst = SwipeRange.y; flickSpeed = SwipeRange.y; } }
public FlickedAwayEventArgs(FlickDirection direction) { Direction = direction; }
public FlickingEventArgs(FlickDirection direction, ManipulationDelta delta) { Direction = direction; Delta = delta; CanContinue = true; }
// フリックの開始時にリクエストを検知し、ビューの建て増しと削除が可能になる。 public bool OnFlickRequestFromFlickableCorner(FlickableCorner flickingCorner, ref Corner cornerFromLeft, ref Corner cornerFromRight, ref Corner cornerFromTop, ref Corner cornerFromBottom, FlickDirection plannedFlickDir) { Debug.Log("OnFlickRequestFromFlickableCorner:" + Time.frameCount); // leftが空なFlickableCornerに対して右フリックをした際、左側にコンテンツを偽造する if (plannedFlickDir == FlickDirection.RIGHT && cornerFromLeft == null) { // cornerFromLeftに代入する var newCorner = Instantiate(FlickableCornerPrefab, this.transform).GetComponent <FlickableCorner>(); // 作成したcornerを、現在flick操作中のcornerの左側にくるようにセット newCorner.currentRectTransform().anchoredPosition = new Vector2(flickingCorner.currentRectTransform().anchoredPosition.x - flickingCorner.currentRectTransform().sizeDelta.x, flickingCorner.currentRectTransform().anchoredPosition.y); newCorner.CornerFromRight = flickingCorner; cornerFromLeft = newCorner; count++; // ボタンにカウント表示をセットする if (newCorner.TryExposureContents <Button>(out var buttons)) { var text = buttons[0].GetComponentInChildren <Text>(); text.text = text.text + ":" + count; } else { Debug.LogError("ボタンがない 1"); } return(true); } // rightが空なFlickableCornerに対して左フリックをした際、右側にコンテンツを偽造する if (plannedFlickDir == FlickDirection.LEFT && cornerFromRight == null) { // cornerFromRightに代入する var newCorner = Instantiate(FlickableCornerPrefab, this.transform).GetComponent <FlickableCorner>(); // 作成したcornerを、現在flick操作中のcornerの右側にくるようにセット newCorner.currentRectTransform().anchoredPosition = new Vector2(flickingCorner.currentRectTransform().anchoredPosition.x + flickingCorner.currentRectTransform().sizeDelta.x, flickingCorner.currentRectTransform().anchoredPosition.y); newCorner.CornerFromLeft = flickingCorner; cornerFromRight = newCorner; count++; // ボタンにカウント表示をセットする if (newCorner.TryExposureContents <Button>(out var buttons)) { var text = buttons[0].GetComponentInChildren <Text>(); text.text = text.text + ":" + count; } else { Debug.LogError("ボタンがない 2"); } return(true); } return(true); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void CameraPosotionControlMobile() //携帯端末のタッチパネルで矢印キーでメインカメラを動かす { Vector3 pos = mainCameraTransform.position; float _work; switch (GetNowSwipe()) { case SwipeDirection.TAP: flickFlug = false; NowFlick = FlickDirection.NONE; break; case SwipeDirection.UP: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosDown(pos, _work); break; case SwipeDirection.RIGHT: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosLeft(pos, _work); break; case SwipeDirection.DOWN: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosUp(pos, _work); break; case SwipeDirection.LEFT: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosRight(pos, _work); break; case SwipeDirection.UP_LEFT: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosRight(CulPosDown(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); break; case SwipeDirection.UP_RIGHT: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosLeft(CulPosDown(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); break; case SwipeDirection.DOWN_LEFT: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosRight(CulPosUp(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); break; case SwipeDirection.DOWN_RIGHT: _work = GetSwipeRange() * Time.deltaTime * swipeSpeed; mainCameraTransform.position = CulPosLeft(CulPosUp(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); break; } if (NowFlick != FlickDirection.NONE) { flickFlug = true; } if (flickFlug) { switch (GetNowFlick()) { case FlickDirection.UP: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosDown(pos, _work); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.RIGHT: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosLeft(pos, _work); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.DOWN: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosUp(pos, _work); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.LEFT: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosRight(pos, _work); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.UP_LEFT: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosRight(CulPosDown(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.UP_RIGHT: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosLeft(CulPosDown(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.DOWN_LEFT: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosRight(CulPosUp(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; case FlickDirection.DOWN_RIGHT: _work = flickSpeed * Time.deltaTime * 0.002f; mainCameraTransform.position = CulPosLeft(CulPosUp(pos, _work / Mathf.Sqrt(2)), _work / Mathf.Sqrt(2)); flickSpeed = Mathf.Max(flickSpeed - flickSpeedFirst * Time.deltaTime / flickTime, 0f); if (flickSpeed == 0f) { flickFlug = false; NowFlick = FlickDirection.NONE; } //Debug.Log(NowFlick + " " + flickSpeed);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// break; } } mainCameraTransform.LookAt(center, Vector3.up); }
// flicableCorner関連 public bool OnFlickRequestFromFlickableCorner(FlickableCorner flickableCorner, ref Corner cornerFromLeft, ref Corner cornerFromRight, ref Corner cornerFromTop, ref Corner cornerFromBottom, FlickDirection plannedFlickDir) { return(true); }
/// <summary> /// 入れ替え先のブロックを取得する関数 /// 取得できたらSwtichBlock関数を呼ぶ /// </summary> /// <param name="dir"></param> public void OnFlicked(FlickDirection dir, ref Block selectedBlock, ref Block destBlock) { print("dir?" + dir); switch (dir) { case FlickDirection.UP: // 配列の外,またはブロックが存在しない場合return if (selectedBlock.BlockPosition.X - 1 < 0 || stage[selectedBlock.BlockPosition.X - 1, selectedBlock.BlockPosition.Y] == null) { return; } destBlock = stage[selectedBlock.BlockPosition.X - 1, selectedBlock.BlockPosition.Y].GetComponent <Block>(); // BlockStatusがNORMALじゃなければreturn if (destBlock.BlockStatus != BlockStatus.NORMAL) { return; } break; case FlickDirection.LEFT: if (selectedBlock.BlockPosition.Y - 1 < 0 || stage[selectedBlock.BlockPosition.X, selectedBlock.BlockPosition.Y - 1] == null) { return; } destBlock = stage[selectedBlock.BlockPosition.X, selectedBlock.BlockPosition.Y - 1].GetComponent <Block>(); if (destBlock.BlockStatus != BlockStatus.NORMAL) { return; } break; case FlickDirection.DOWN: if (selectedBlock.BlockPosition.X + 1 >= stage.GetLength(0) || stage[selectedBlock.BlockPosition.X + 1, selectedBlock.BlockPosition.Y] == null) { return; } destBlock = stage[selectedBlock.BlockPosition.X + 1, selectedBlock.BlockPosition.Y].GetComponent <Block>(); if (destBlock.BlockStatus != BlockStatus.NORMAL) { return; } break; case FlickDirection.RIGHT: if (selectedBlock.BlockPosition.Y + 1 >= stage.GetLength(1) || stage[selectedBlock.BlockPosition.X, selectedBlock.BlockPosition.Y + 1] == null) { return; } destBlock = stage[selectedBlock.BlockPosition.X, selectedBlock.BlockPosition.Y + 1].GetComponent <Block>(); if (destBlock.BlockStatus != BlockStatus.NORMAL) { return; } break; default: return; } // 盤面(stage[,])上でのGameObjectを入れ替え if (selectedBlock.BlockStatus == BlockStatus.NORMAL && destBlock.BlockStatus == BlockStatus.NORMAL) { StartCoroutine(SwitchBlock(selectedBlock, destBlock)); } }