//カメラの移動(慣性付き) { protected void CameraMove(Vector3 offset) { if (offset != Vector3.zero) { //慣性を働かせる offset /= amount; Vector3 cPos = targetCamera.transform.position; bool isOut; Vector3 p = FuncBox.MoveArea(cPos, offset, area, out isOut); targetCamera.transform.position = p; //エリアからはみ出ているので移動量は0に if (isOut) { offset = Vector3.zero; } } }
//スワイプ操作 protected void Swipe(int input = 0) { if (Input.GetMouseButton(input)) { if (flagSwipe) { //マウスがどれだけ移動しているかを取得する prevPos = InverseMousePoint(); offset = startPos - prevPos; //カメラの移動 if (flagCameraMove) { Vector3 cPos = targetCamera.transform.position; bool isOut; Vector3 p = FuncBox.MoveArea(cPos, offset, area, out isOut); targetCamera.transform.position = p; if (isOut) { offset = Vector3.zero; } } //スプライト if (sprite) { //長さを求める distance = sprite.transform.localScale; distance.x = Vector3.Distance(prevPos, startPos); sprite.transform.localScale = distance; //角度を求める angle = FuncBox.TwoPointAngleD(startPos, prevPos); sprite.transform.eulerAngles = new Vector3(0f, 0f, angle); } } else { //マウスの位置を記憶しておく startPos = InverseMousePoint(); flagSwipe = true; //スプライト if (sprite) { //sprite.transform.localPosition = startPos; sprite.gameObject.SetActive(true); } } } else { //直前までスワイプしていた場合 if (flagSwipe) { Debug.Log("スワイプ終了"); if (sprite) { sprite.gameObject.SetActive(false); } //円形UIとの連携 if (circleUI) { string str = circleUI.GetCircleValue(angle, distance.x); if (activeDistance <= distance.x) { if (circleUIIventHandler) { circleUIIventHandler.SendMessage(circleUIIventName + str, angle); } } } } flagSwipe = false; } }