Example #1
0
 //-------------------------------------------------------------------------
 void OnDrag(DragGesture gesture)
 {
     if (onFingerDragMove != null)
     {
         onFingerDragMove(gesture.Position);
     }
 }
Example #2
0
 // Handle Gesture Event (sent by the DragRecognizer component)
 void OnDrag( DragGesture gesture )
 {
     if( gesture.Phase != ContinuousGesturePhase.Ended )
         dragGesture = gesture;
     else
         dragGesture = null;
 }
        /*
        // TODO: Impliment Swipe

        public void OnSwipe(SwipeGesture swipe)
        {
            Vector2 velocity = new Vector2();

            switch (swipe.Direction) {
                case FingerGestures.SwipeDirection.Right:
                    velocity = Vector2.right * swipe.Velocity;
                    break;
                case FingerGestures.SwipeDirection.Left:
                    velocity = Vector2.right * -swipe.Velocity;
                    break;
                case FingerGestures.SwipeDirection.Up:
                    velocity = Vector2.up * swipe.Velocity;
                    break;
                case FingerGestures.SwipeDirection.Down:
                    velocity = Vector2.up * -swipe.Velocity;
                    break;
            }

            HandleDragMoveEvent(swipe.Position, velocity, _swipeZones, true);
        }

        */
        public void OnDrag(DragGesture drag)
        {
            InputMessage.MessageTypes type = InputMessage.MessageTypes.Failed;

            switch (drag.Phase) {
                case ContinuousGesturePhase.Started:
                    type = InputMessage.MessageTypes.Begin;
                    break;
                case ContinuousGesturePhase.Updated:
                    type = InputMessage.MessageTypes.Update;
                    break;
                case ContinuousGesturePhase.Ended:
                    type = InputMessage.MessageTypes.End;
                    break;
                default:
                    break;

            }

            _updates.Add(new InputMessage(
                InputMessage.InputTypes.OneFingerDrag,
                type,
                drag.Fingers.Select(f => f.Position).ToList(),
                drag.Fingers.Select(f => f.DeltaPosition).ToList()
            ));
        }
Example #4
0
 // Handle Gesture Event (sent by the DragRecognizer component)
 void OnDrag( DragGesture gesture )
 {
     if( gesture.Phase != ContinuousGesturePhase.Ended && !bIsInsideKeyRec)
         dragGesture = gesture;
     else
         dragGesture = null;
 }
Example #5
0
    void OnDrag(DragGesture gesture)
    {
        if (!Game.Instance.IsPlaying) return;

        // Drag/displacement since last frame
        Vector2 deltaMove = gesture.DeltaMove;
        player.Move(deltaMove.y * moveFactor, -deltaMove.x * moveFactor);
    }
Example #6
0
    void OnDrag( DragGesture gesture )
    {
        dragGesture = ( gesture.State == GestureRecognitionState.Ended ) ? null : gesture;
		if (dragGesture != null) {
			if ((dragGesture.Fingers.Count > 1) || IgnoreDrag)
				dragGesture = null;
		}
    }
	void OnDragDrop(DragGesture gesture) {
		Vector3 newPos = Camera.main.ScreenToWorldPoint (gesture.TotalMove);
		newPos.z = -5f;
		newPos.y += 5f;
		transform.position = newPos;

		Debug.Log (Camera.main.ScreenToWorldPoint (gesture.TotalMove));
	}
Example #8
0
 void OnDrag(DragGesture gesture)
 {
     if(model == EModel.Move){
         Vector3 move = gesture.DeltaMove * 0.05f;
         parent.transform.Translate(move, Space.World);
     }else if(model == EModel.Rotate){
         Vector3 move = gesture.DeltaMove * 0.3f;
         parent.transform.Rotate(move.y, -1 * move.x, 0f, Space.World);
     }
 }
Example #9
0
    void OnDrag( DragGesture gesture )
    {
        if (gesture.DeltaMove.SqrMagnitude() > 0)
        {
            Vector2 screenSpaceMove = sensitivity * gesture.DeltaMove;
            Vector3 worldSpaceMove = screenSpaceMove.x * cachedTransform.right + screenSpaceMove.y * cachedTransform.up;
            idealPos -= worldSpaceMove;

            if (OnPan != null)
                OnPan(this, worldSpaceMove);
        }
    }
        void DragingStart(DragGesture gesture)
        {
            if (!GlobalManager.FurnitureOperationSwitch)
                return;
            if (gesture.Selection != GlobalManager.Selection)
                return;

            GestureRunning = IsTargetNull() ? false : true;
            if (!GestureRunning)
                return;

            StartChange();
        }
Example #11
0
	/// <summary>
	/// 拖拽时调用
	/// </summary>
	/// <param name="gesture"></param>
    void OnDrag(DragGesture gesture)
	{
        ///< UI层不做处理
        if (null != UICamera.hoveredObject)
        {
            gameObject.GetComponent<TBDragView>().enabled = false;
            //return;
        }
        else
        {
            gameObject.GetComponent<TBDragView>().enabled = true;
        }

        ///<判断手指的数量与旋转区分开,如果大于两个手指则不旋转
        if (fingerNumber >= 1)
		{
			return;
		}

        ///<拖动的位置
        dragPosition = gesture.Position;
        if ((downPosition.x - dragPosition.x) > SunmConstant.offDistance)
		{
			//           Debug.LogError("left");
			bIsMovePress = true;
		}

        if ((dragPosition.x - downPosition.x) > SunmConstant.offDistance)
		{
			//            Debug.Log("right");
			bIsMovePress = true;
		}

        if ((dragPosition.y - downPosition.y) > SunmConstant.offDistance)
		{
			//           Debug.Log("up");
			bIsMovePress = true;
		}

		if ((downPosition.y - dragPosition.y) > SunmConstant.offDistance)
		{
			//            Debug.LogError("down");
			bIsMovePress = true;
		}

		downPosition = dragPosition;
	}
Example #12
0
    void OnDrag( DragGesture gesture )
    {
        if( gesture.Phase == ContinuousGesturePhase.Started )
        {
            // initialize the line renderer
            lineRenderer.enabled = true;
            lineRenderer.SetPosition( 0, transform.position );
            lineRenderer.SetPosition( 1, transform.position );

            // keep end point width in sync with object's current scale
            lineRenderer.SetWidth( 0.01f, transform.localScale.x );
        }
        else if( gesture.Phase == ContinuousGesturePhase.Ended )
        {
            lineRenderer.enabled = false;
        }
    }
        void DragingUpdate(DragGesture gesture)
        {
            if (!GestureRunning)
                return;

            Vector3 fingerPos3d, prevFingerPos3d;

            ///calculate distance between previous finger position and new position
            /// and position of finger is in or out of screen
            if (ProjectScreenPointOnDragPlane(TargetTransform.position, gesture.Fingers [0].PreviousPosition, out prevFingerPos3d) &&
                ProjectScreenPointOnDragPlane(TargetTransform.position, gesture.Fingers [0].Position, out fingerPos3d))
            {

                Vector3 move = fingerPos3d - prevFingerPos3d;

                TargetTransform.position += move;
            }
        }
Example #14
0
    void OnDrag( DragGesture gesture )
    {
        // first finger
        FingerGestures.Finger finger = gesture.Fingers[0];

        if( gesture.Phase == ContinuousGesturePhase.Started )
        {
            Debug.Log("sex");
            // dismiss this event if we're not interacting with our drag object
            if( gesture.Selection != dragObject )
                return;

            UI.StatusText = "Started dragging with finger " + finger;

            // remember which finger is dragging dragObject
            dragFingerIndex = finger.Index;

            // spawn some particles because it's cool.
            SpawnParticles( dragObject );
        }
        else if( finger.Index == dragFingerIndex )  // gesture in progress, make sure that this event comes from the finger that is dragging our dragObject
        {
            if( gesture.Phase == ContinuousGesturePhase.Updated )
            {
                // update the position by converting the current screen position of the finger to a world position on the Z = 0 plane
                dragObject.transform.position = GetWorldPos( gesture.Position );
            }
            else
            {
                UI.StatusText = "Stopped dragging with finger " + finger;

                // reset our drag finger index
                dragFingerIndex = -1;

                // spawn some particles because it's cool.
                SpawnParticles( dragObject );

            }
        }
    }
Example #15
0
    void OnDrag(DragGesture gesture)
    {
        ContinuousGesturePhase phase = gesture.Phase;
        Vector2 deltaMove = gesture.DeltaMove;
        if(controller == TouchControllerType.FRAME)
        {
            if(phase == ContinuousGesturePhase.Started)
            {
                float relativeObjectPosX = 0;
                if(is_right_user)
                    relativeObjectPosX = (player.transform.localPosition.x - 30f) / 175f; // max value is 1
                else
                    relativeObjectPosX = -(player.transform.localPosition.x + 30f) / 175f; // min value is -1
                //Initialize touch Frame's cursor
                touchFrame = new TouchFrame();
                touchFrame.cursor_x = relativeObjectPosX * touchFrame.size_x;
                touchFrame.cursor_y = 0;
                //Initialize touch Frame's boundary
                touchFrame.boundary_minus_x = gesture.Position.x - touchFrame.cursor_x;
                touchFrame.boundary_minus_y = gesture.Position.y;
                touchFrame.boundary_plus_x = touchFrame.boundary_minus_x + touchFrame.size_x;
                touchFrame.boundary_plus_y = touchFrame.boundary_minus_y + touchFrame.size_y;
                is_touching = true;
                Debug.Log(GameObject.Find("VollyBallCamera").GetComponent<Camera>().ScreenToWorldPoint(new Vector3(gesture.Position.x , gesture.Position.y, 0)) - new Vector3(216,153,0));
                //Debug.Log("Touch!");
            }
            else if(phase == ContinuousGesturePhase.Updated)
          			{
                float movePos = 0; // player's move position which is on x-axis
                float mst = 1;		//player's moving direction ( + : move right, - : move left)
                if(is_right_user)
                {
                    movePos = 30f + ((touchFrame.touch_pos.x - touchFrame.boundary_minus_x) / touchFrame.size_x * 175f);
                }

                else
                {
                    movePos = -30f - ((touchFrame.boundary_plus_x - touchFrame.touch_pos.x) / touchFrame.size_x * 175f);
                }
                    gameManager.FrameP1Walking(movePos);

                //update touch Frame's cursor and touch Frame's boundary
                touchFrame.touch_pos = gesture.Position;
                touchFrame.cursor_x = touchFrame.touch_pos.x - touchFrame.boundary_minus_x;
                touchFrame.cursor_y = touchFrame.touch_pos.y - touchFrame.boundary_minus_y;

                /*move touch frame if cursors get out of this frame*/
                if(touchFrame.touch_pos.x > touchFrame.boundary_plus_x)
                {
                    touchFrame.boundary_plus_x += touchFrame.cursor_x - touchFrame.size_x;
                    touchFrame.boundary_minus_x += touchFrame.cursor_x - touchFrame.size_x;
                    touchFrame.cursor_x = touchFrame.size_x;
                }else if(touchFrame.touch_pos.x < touchFrame.boundary_minus_x)
                {
                    touchFrame.boundary_minus_x += touchFrame.cursor_x;
                    touchFrame.boundary_plus_x += touchFrame.cursor_x;
                    touchFrame.cursor_x = 0;
                }
                if(touchFrame.touch_pos.y > touchFrame.boundary_plus_y)
                {
                    touchFrame.boundary_plus_y += touchFrame.cursor_y - touchFrame.size_y;
                    touchFrame.boundary_minus_y += touchFrame.cursor_y - touchFrame.size_y;
                    touchFrame.cursor_y = touchFrame.size_y;
                }
                else if(touchFrame.touch_pos.y < touchFrame.boundary_minus_y)
                {
                    touchFrame.boundary_plus_y += touchFrame.cursor_y;
                    touchFrame.boundary_minus_y += touchFrame.cursor_y;
                    touchFrame.cursor_y = 0;
                }
                //Debug.Log("Touch Pos : " + touchFrame.touch_pos.x +"/t/tCursor : " + touchFrame.cursor + "\nbndMinus : " + touchFrame.boundary_minus_x + "/t/tbndPlus : " + touchFrame.boundary_plus_x);

                if(player1.can_swipe)
                {
                    if(player1.pMotion == MotionType.WALK)//if(!player1.jumping && !player1.leftSliding && !player1.rightSliding &&!is_jumped)
                    {
                        if(touchFrame.touch_pos.y - touchFrame.boundary_minus_y > jump_touch_dist)//jump touch event
                        {
                            gameManager.P1Jumping();
                        }
                        else if(deltaMove.x < -40) // left sliding touch event
                        {
                            gameManager.P1Sliding(false);
                        }
                        else if(deltaMove.x > 40) // right sliding touch event
                        {
                            gameManager.P1Sliding(true);
                        }
                    }
                    else if(player1.pMotion == MotionType.JUMP)//(player1.jumping && !player1.upperSpike && !player1.middleSpike && !player1.lowerSpike)
                    {
                        if(deltaMove.y > 25 )//&& deltaMove.x < 10 && deltaMove.x > -10)//upper spike
                        {
                            gameManager.P1Spiking(SpikeType.HIGH, false);
                        }
                        else if(deltaMove.y < -25)// && deltaMove.x < 10 && deltaMove.x > -10)//lower spike
                        {
                            gameManager.P1Spiking(SpikeType.LOW, false);
                        }
                        else if(deltaMove.x > 20)// && deltaMove.y < 10 && deltaMove.y > -10)//middle spike
                        {
                            gameManager.P1Spiking(SpikeType.MID, false);
                        }
                        else if(deltaMove.x < -20)// && deltaMove.y < 10 && deltaMove.y > -10)//middle spike
                        {
                            gameManager.P1Spiking(SpikeType.MID, true);
                        }
                    }
                }

            }
            else // it is called when user get off the hand from screen
            {
                is_touching = false;
            }
        }
        else if(controller == TouchControllerType.BUTTON)
        {
         	FingerGestures.Finger finger = gesture.Fingers[0];
            if(gesture.Phase == ContinuousGesturePhase.Started)
            {
                if(gesture.Selection == bt_left && player1.can_swipe)
                {
                    if(is_left_clckd && Time.time - touched_time < 0.5f)
                    {
                        touchEvent = TouchEvent.NONE;
                        gameManager.P1Sliding(false);
                        is_left_clckd = false;
                        if(is_right_clckd)
                            is_right_clckd = false;
                        Debug.Log("left Sliding!");
                    }
                    else
                    {
                        touchEvent = TouchEvent.LEFT;
                        sprite_bt_left.SetSprite("bubble_orange");
                        //GameObject particle = touchEffect.spawnParticle(new Vector3(gesture.Position.x, gesture.Position.y, -3));

                        is_left_touching = true;
                        touched_time = Time.time;
                        is_left_clckd = true;
                        if(is_right_clckd)
                            is_right_clckd = false;
                        Debug.Log("left walking!!!");
                    }
                    dragFingerIdx = finger.Index;
                }
                else if(gesture.Selection == bt_right && player1.can_swipe)
                {
                    if(is_right_clckd && Time.time - touched_time < 0.5f)
                    {
                        touchEvent = TouchEvent.NONE;
                        gameManager.P1Sliding(true);
                        is_right_clckd = false;
                        if(is_left_clckd)
                        is_left_clckd = false;
                        Debug.Log("right Sliding!");
                    }
                    else
                    {
                        touchEvent = TouchEvent.RIGHT;
                        sprite_bt_right.SetSprite("bubble_orange");
                        is_right_touching = true;
                        Debug.Log("right Button is selected!");
                        touched_time = Time.time;
                            is_right_clckd = true;
                        if(is_left_clckd)
                            is_left_clckd = false;
                    }
                    dragFingerIdx = finger.Index;
                }
            }

            else if(dragFingerIdx == finger.Index && gesture.Phase == ContinuousGesturePhase.Ended)
            {
                if(touchEvent == TouchEvent.LEFT)
                {
                    sprite_bt_left.SetSprite("bubble_red");
                    is_left_touching = false;
                    touchEvent = TouchEvent.NONE;
                }
                if(touchEvent == TouchEvent.RIGHT)
                {
                    sprite_bt_right.SetSprite("bubble_red");
                    is_right_touching = false;
                    touchEvent = TouchEvent.NONE;
                }
                else
                {
                    sprite_bt_left.SetSprite("bubble_red");
                    is_left_touching = false;
                    sprite_bt_right.SetSprite("bubble_red");
                    is_right_touching = false;
                }
            }
        }
        else
        {
            //FingerGestures.Finger finger = gesture.Fingers[0];
            Vector3 pos = Vector3.zero;
            if(is_right_user)
                pos = cam.camera.ScreenToWorldPoint(new Vector3(gesture.Position.x, gesture.Position.y, 0)) - new Vector3(432/2 - 130, 306/2 - 50, -7);
            else
                pos = cam.camera.ScreenToWorldPoint(new Vector3(gesture.Position.x, gesture.Position.y, 0)) - new Vector3(432/2 + 130, 306/2 + 50, -7);
            Debug.Log(pos);
            if(gesture.Phase == ContinuousGesturePhase.Started)
            {
                if(gesture.Selection == joystick_bg || gesture.Selection == joystick_bar)
                {
                    joystick_bar.transform.localPosition = pos;
                    is_touching_joypad = true;
                }
                //dragFingerIdx = finger.Index;
            }
            else if(is_touching_joypad)
            {
                if(gesture.Phase == ContinuousGesturePhase.Updated )
                {
                    joystick_bar.transform.localPosition = SetJoyPaddlePos(pos);
                    Vector3 paddlePos = joystick_bar.transform.localPosition;

                    if(paddlePos.y >= 15 && player1.pMotion == MotionType.WALK && player1.can_swipe)
                    {
                        gameManager.P1Jumping();
                    }
                    else if(paddlePos.x < -15)
                    {
                        gameManager.JoypadP1Walking(true);
                    }
                    else if(paddlePos.x > 15)
                    {
                        gameManager.JoypadP1Walking(false);
                    }
                    else if(paddlePos.x <=15 && paddlePos.x >= -15 && paddlePos.y < 15)
                    {
                        gameManager.P1NoneTouching();
                    }

                }
                else
                {
                    joystick_bar.transform.localPosition = new Vector3(0,0,-3);
                    gameManager.P1NoneTouching();
                    is_touching_joypad = false;
                }
            }
        }
    }
Example #16
0
void HandleDrag( DragGesture gesture )
{
    if( !enabled )
        return;

    if( gesture.Phase == ContinuousGesturePhase.Started )
    {
        Dragging = true;
        draggingFinger = gesture.Fingers[0];
    }
    else if( Dragging )
    {
        // make sure this is the finger we started dragging with
        if( gesture.Fingers[0] != draggingFinger )
            return;

        if( gesture.Phase == ContinuousGesturePhase.Updated )
        {
            Transform tf = transform;
            Vector3 move = Vector3.zero;

            if( DragFromObjectCenter )
            {
                Vector3 fingerPos3d;
                if( ProjectScreenPointOnDragPlane( tf.position, draggingFinger.Position, out fingerPos3d ) )
                {
                    move = fingerPos3d - tf.position;
                }
            }
            else
            {
                // figure out our previous screen space finger position
                Vector3 fingerPos3d, prevFingerPos3d;

                // convert these to world-space coordinates, and compute the amount of motion we need to apply to the object
                if( ProjectScreenPointOnDragPlane( tf.position, draggingFinger.PreviousPosition, out prevFingerPos3d ) &&
                    ProjectScreenPointOnDragPlane( tf.position, draggingFinger.Position, out fingerPos3d ) )
                {
                    move = fingerPos3d - prevFingerPos3d;
                }
            }

            if( rigidbody )
                physxDragMove += move; // this will be used in FixedUpdate() to properly move the rigidbody
            else
                tf.position += move;
        }
        else
        {
            Dragging = false;
        }
    }
}
Example #17
0
 void OnDrag( DragGesture gesture )
 {
     HandleDrag( gesture );
 }
Example #18
0
	void OnDrag(DragGesture gesture){
		if(gesture.Phase == ContinuousGesturePhase.Updated){
			//拖动屏幕
			GameController.GetInstance().deltaMove =  gesture.DeltaMove;
		}
		if(gesture.Phase == ContinuousGesturePhase.Ended){
			//结束拖动屏幕,向量恢复为(0f,0f)
			GameController.GetInstance().deltaMove = new Vector2(0f,0f);
		}
	}
	/// <summary>
	/// Raises the drag gesture event. This event is raised by FingerGestures's DragRecognizer component.
	/// Determine the selected tile and in which direction the user dragged it and tell the <see cref="Match3BoardGameLogic"/>
	/// that we've started moving that tile in that direction.
	/// </summary>
	/// <param name='eventData'>
	/// Event data.
	/// </param>
	public void OnDragGesture(DragGesture eventData) {		
		if (dragLock > 0) {
			tapSelectedTile = null;
			return;
		}
		
		// Check if we've selected any tile.
		if (eventData.StartSelection != null && eventData.StartSelection.layer == Match3Globals.Instance.layerBoardTile) {
			if (eventData.Phase == ContinuousGesturePhase.Started) {
				// Cancel the tap selected tile if we've done a drag gesture.
				tapSelectedTile = null;
				
				AbstractTile dragSelectedTile = eventData.StartSelection.GetComponent<AbstractTile>();
				TileMoveDirection moveDirection = Match3BoardGameLogic.GetTileMoveDirection(eventData.TotalMove);
				
				if (InputFilter == null || InputFilter(dragSelectedTile, null, moveDirection)) {
//					Debug.Log("Drag event started! Start Selection: " + eventData.StartSelection + " -> totalMove = " + eventData.TotalMove);
					if (boardGameLogic.TryToMoveTile(dragSelectedTile, moveDirection)) {
						//boardGameLogic.loseConditions.NewMove();
					}
				}
			}
		}
	}
Example #20
0
    void OnTwoFingerDrag( DragGesture gesture )
    {
        //Debug.Log( "OnTwoFingerDrag " + e.Phase + " @ Frame " + Time.frameCount );

        if( allowPanning )
        {
            Vector3 move = -0.02f * panningSensitivity * 
				( panningPlane.right * gesture.DeltaMove.x + panningPlane.up * gesture.DeltaMove.y );
            
            if( invertPanningDirections )
                IdealPanOffset -= move; 
            else
                IdealPanOffset += move;

            nextDragTime = Time.time + 0.25f;
        }
    }
 void DragingEnd(DragGesture gesture)
 {
     if (!GestureRunning)
         return;
     RecordChange();
 }
Example #22
0
    void OnTwoFingerDrag( DragGesture gesture )
    {
        if( allowPanning )
        {
            Vector3 move = -panningSensitivity * ( panningPlane.right * gesture.DeltaMove.x.Centimeters() + panningPlane.up * gesture.DeltaMove.y.Centimeters() );

            if( invertPanningDirections )
                IdealPanOffset -= move;
            else
                IdealPanOffset += move;

            nextDragTime = Time.time + 0.25f;
        }
    }
Example #23
0
    void OnDrag( DragGesture gesture )
    {
        // dont apply drag rotation if more than one touch is on the screen
        //if( FingerGestures.Touches.Count > 1 )
        //    return;
        
        // wait for drag cooldown timer to wear off
        //  used to avoid dragging right after a pinch or pan, when lifting off one finger but the other one is still on screen
        if( Time.time < nextDragTime )
            return;

        if( target )
        {
            IdealYaw += gesture.DeltaMove.x * yawSensitivity * 0.02f;
            IdealPitch -= gesture.DeltaMove.y * pitchSensitivity * 0.02f;
        }
    }
Example #24
0
 void OnDrag( DragGesture gesture )
 {
     //if(pausing.isPaused == false)
     HandleDrag( gesture );
 }
Example #25
0
    void OnDrag( DragGesture gesture )
    {
        // don't rotate unless the drag started on our target object
        if( OnlyRotateWhenDragStartsOnObject )
        {
            if( gesture.Phase == ContinuousGesturePhase.Started )
            {
                if( !gesture.Recognizer.Raycaster )
                {
                    Debug.LogWarning( "The drag recognizer on " + gesture.Recognizer.name + " has no ScreenRaycaster component set. This will prevent OnlyRotateWhenDragStartsOnObject flag from working." );
                    OnlyRotateWhenDragStartsOnObject = false;
                    return;
                }

                if( target && !target.collider )
                {
                    Debug.LogWarning( "The target object has no collider set. OnlyRotateWhenDragStartsOnObject won't work." );
                    OnlyRotateWhenDragStartsOnObject = false;
                    return;
                }
            }

            if( !target || gesture.StartSelection != target.gameObject )
                return;
        }

        // wait for drag cooldown timer to wear off
        //  used to avoid dragging right after a pinch or pan, when lifting off one finger but the other one is still on screen
        if( Time.time < nextDragTime )
            return;

        if( target )
        {
            IdealYaw += gesture.DeltaMove.x.Centimeters() * yawSensitivity;
            IdealPitch -= gesture.DeltaMove.y.Centimeters() * pitchSensitivity;
        }
    }
Example #26
0
 void OnDrag(DragGesture gesture)
 {
     if(!HasUI()){
         Vector3 move = gesture.DeltaMove * 0.3f;
         camera.transform.Rotate(-1 * move.y, move.x, 0f);
         Vector3 angle = camera.transform.eulerAngles;
         angle.z = 0;
         camera.transform.eulerAngles = angle;
     }
     //		if(model == EModel.Move){
     //			Vector3 move = gesture.DeltaMove * 0.05f;
     //			camera.transform.Translate(move, Space.World);
     //		}else if(model == EModel.Rotate){
     //
     //		}
 }
Example #27
0
 void OnDrag( DragGesture gesture )
 {
     dragGesture = ( gesture.State == GestureRecognitionState.Ended ) ? null : gesture;
 }
Example #28
0
	void OnDrag ( DragGesture e ) {
		if ( unitToCreate == null || !canCreate ) return;
		
		if ( !unitToCreate.Recharged ) return;
		
		switch ( e.State ) {
		case GestureRecognitionState.Started:
			if ( instiantedUnit == null ) {
				instiantedUnit = Instantiate ( unitToCreate.gameObject ) as GameObject;
				instiantedUnit.renderer.enabled = false;
			}
			
			break;
			
		case GestureRecognitionState.InProgress:
			selectedTerrainBlockGO = e.Selection;
			
			if ( selectedTerrainBlockGO == null ) {
				if ( instiantedUnit != null )
					instiantedUnit.renderer.enabled = false;
				return;
			}
			
			selectedTerrainBlock = selectedTerrainBlockGO.GetComponent<TerrainBlock>();
			if ( selectedTerrainBlock == null ) { 
				if ( instiantedUnit != null )
					instiantedUnit.renderer.enabled = false;
				return;
			}
			
			if ( instiantedUnit != null )
				instiantedUnit.renderer.enabled = true;
			
			if ( highlightedTerrainBlocks != null )
			foreach ( TerrainBlock block in highlightedTerrainBlocks )
				block.SpriteRenderer.VertexColor = block.DefaultColor;
			
			// Highlight selection of the row and column from the terrain block.
			highlightedTerrainBlocks = TerrainManager.GetTerrainRowAndColumn (selectedTerrainBlock);
			
			foreach ( TerrainBlock block in highlightedTerrainBlocks ) {
				block.SpriteRenderer.VertexColor = Color.red;
			}
			
			if ( instiantedUnit != null )
				instiantedUnit.SetXY ( selectedTerrainBlockGO.GetX(), selectedTerrainBlockGO.GetY() );
			
			break;
			
		case GestureRecognitionState.Ended:
			if ( highlightedTerrainBlocks != null )
				foreach ( TerrainBlock block in highlightedTerrainBlocks )
					block.SpriteRenderer.VertexColor = block.DefaultColor;
			
			selectedTerrainBlockGO = e.Selection;
			if ( selectedTerrainBlockGO == null ) {
				if ( instiantedUnit != null ) {
					Destroy ( instiantedUnit );
				}
				return; 
			}
			
			selectedTerrainBlock = selectedTerrainBlockGO.GetComponent<TerrainBlock>();
			if ( selectedTerrainBlock == null ) { 
				if ( instiantedUnit != null ) {
					instiantedUnit.renderer.enabled = false;
					Destroy ( instiantedUnit );
				}
				return;
			}
			
			if ( selectedTerrainBlock.HasUnit )
				Destroy ( instiantedUnit );
			else {
				if ( selectedTerrainBlock == null )
					return;
				
				selectedTerrainBlock.unitOnTerrain = instiantedUnit.GetComponent<Unit>();
				selectedTerrainBlock.unitOnTerrain.terrainBlock = selectedTerrainBlock;
				selectedTerrainBlock.unitOnTerrain.UnitPlaced = true;
			}
			
			selectedTerrainBlockGO = null;
			selectedTerrainBlock = null;
			instiantedUnit = null;
			UnitToCreate.LastUsedTime = Time.time;
			
			break;
		}
	}
Example #29
0
    //public static void moveCenter( Vector3 _mov )
    //{

    //}
    /// <summary>
    /// 重新设置旋转中心点
    /// </summary>
    /// <param name="_center"></param>
    /// 
    //public static void changeCenter(Vector3 _center)
    //{
    //    rotateCenter = rotateCenter + _center;
    //}

    void OnDrag(DragGesture gesture)
    {
        ///< UI层不做处理
        if (null != UICamera.hoveredObject)
        {
            return;
        }

        ///< 判断手指的数量与旋转区分开,如果大于两个手指则不旋转
        if (fingerNumber >= 1)
        {
            return;
        }

        //< 如果正在操作按键,则不处理//
        if (SunmRTKeyControl.bIsMoving || bIsKeying)
        {
            return;
        }

        //< 拖动的位置//
        dragPosition = gesture.Position;
        dragPoint3 = map2Sphere(dragPosition);
        float theta = Mathf.Acos(Mathf.Min(1.0f, Vector3.Dot(startPoint3, dragPoint3))) * CNCRotation;
        Vector3 axis = Vector3.Cross(startPoint3, dragPoint3).normalized;
        Quaternion rot = Quaternion.Inverse(Quaternion.AngleAxis(theta * 180.0f / Mathf.PI, axis));//当前拖动得到的四元数//
        currentRotation = currentRotation * rot;//当前相机的四元数//
        transform.position = currentRotation * (initPosition - rotateCenter) + rotateCenter;//当前相机所在位置//
        transform.rotation = currentRotation;
        //transform.LookAt (rotateCenter);
        if ((downPosition.x - dragPosition.x) > SunmConstant.offDistance)
        {
            //           Debug.LogError("left");
            bIsMovePress = true;
        }

        if ((dragPosition.x - downPosition.x) > SunmConstant.offDistance)
        {
            //            Debug.Log("right");
            bIsMovePress = true;
        }

        if ((dragPosition.y - downPosition.y) > SunmConstant.offDistance)
        {
            //           Debug.Log("up");
            bIsMovePress = true;
        }

        if ((downPosition.y - dragPosition.y) > SunmConstant.offDistance)
        {
            //            Debug.LogError("down");
            bIsMovePress = true;
        }

        downPosition = dragPosition;
        startPoint3 = dragPoint3;
    }
Example #30
0
    void OnDrag(DragGesture drag)
    {
        //		Vector2 deltaMove = drag.DeltaMove * 0.1f;
        //		hero.transform.Rotate(0f, deltaMove.x, 0f, Space.World);
        //
        //		CameraControll camealControll = main_camera.GetComponent<CameraControll>();
        //		camealControll.OnDrag(drag);

        //		main_camera.transform.Rotate(deltaMove.y, 0, 0f, Space.World);
        //		Vector3 cameraAngle = main_camera.transform.eulerAngles;
        //		cameraAngle.z = 0;
        //		cameraAngle.y = hero.transform.eulerAngles.y;
        //		main_camera.transform.eulerAngles = cameraAngle;
    }