Exemplo n.º 1
0
//		private void OnScenePinch (PinchGesture pPinchGesture)
//		{
//			switch (pPinchGesture.Phase) {
//			case ContinuousGesturePhase.Started:
//				isUGUITouched = CCCollider.IsTouchCollider (CocoMainController.UICamera, m_UICollider);
//				if (!isUGUITouched)
//					CCAction.Stop (Camera.main.gameObject);
//				break;
//			case ContinuousGesturePhase.Updated:
//				if (!isUGUITouched) {
//
//					float dis = Mathf.Abs (Camera.main.transform.eulerAngles.x - m_CameraOriginAngles.x);
//
//					if (dis > 0) {
//
//						CCAction.RotateToX (Camera.main.gameObject, m_CameraOriginAngles.x, 0.2f);
//
//					}
//
//					Vector3 NearPos = GetNearPos ();
//					Vector3 pCamPos = Camera.main.transform.localPosition;
//					pCamPos -= m_CameraMoveDir * pPinchGesture.Delta * Time.deltaTime * 0.15f;
//					pCamPos.x = CheckValue (pCamPos.x, NearPos.x, m_CameraFarPos.x);
//					pCamPos.y = CheckValue (pCamPos.y, NearPos.y, m_CameraFarPos.y);
//					pCamPos.z = CheckValue (pCamPos.z, NearPos.z, m_CameraFarPos.z);
//					Camera.main.transform.position = pCamPos;
//					CheckCameraPosY ();
//
//				}
//
//				break;
//			case ContinuousGesturePhase.Ended:
//				isUGUITouched = false;
//				break;
//			}
//		}

        void DragCamera(float DeltaY)
        {
            float pos_y = m_MainCamera.transform.position.y;

            pos_y -= DeltaY * Time.deltaTime * 0.08f;
            CCPosition.Set_Y(m_MainCamera.transform, pos_y);
            CheckCameraPosY();
        }
Exemplo n.º 2
0
        void CheckCameraPosY()
        {
            float persent = (m_CameraFarPos.z - Camera.main.transform.position.z) / (m_CameraFarPos.z - m_CameraNearPos.z);

            float pos_y = Camera.main.transform.position.y;

            float offset_y     = Drag_Max_Y - Drag_Min_Y;
            float Enable_Max_Y = Drag_Max_Y - (1 - persent) * (Drag_Max_Y - m_CameraFarPos.y);
            float Enable_Min_Y = Enable_Max_Y - offset_y * persent;

            pos_y = Mathf.Clamp(pos_y, Enable_Min_Y, Enable_Max_Y);
            CCPosition.Set_Y(Camera.main.transform, pos_y);
        }