예제 #1
0
    private void OnTouchHeld()
    {
        if (pieceStatus != "locked" && Touched == true && Placed == false && NotTouched == true)
        {
            Vector3 currentMousePosition            = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector3 dragAmount                      = (currentMousePosition - touchPoint);
            Vector3 directionToCurrentMousePosition = currentMousePosition - selectedObject.transform.position;

            DragSummary dragSummary = new DragSummary();
            dragSummary.position  = currentMousePosition;
            dragSummary.amount    = dragAmount;
            dragSummary.direction = directionToCurrentMousePosition;

            if (dragAmount.magnitude > minimumDragDistance)
            {
                selectedObject.SendMessage("OnDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
            }

            if (Mathf.Abs(dragAmount.x) > minimumDragDistance)
            {
                selectedObject.SendMessage("OnHorizontalDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
            }

            if (Mathf.Abs(dragAmount.y) > minimumDragDistance)
            {
                selectedObject.SendMessage("OnVerticalDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
예제 #2
0
    private void OnTouchHeld()
    {
        foreach (Camera usedCamera in usedCameras)
        {
            Vector3 currentTouchPosition = usedCamera.ScreenToWorldPoint(Input.mousePosition);
            Vector3 dragAmount           = (currentTouchPosition - touchPoint);

            DragSummary dragSummary = new DragSummary();
            dragSummary.position     = usedCamera.ScreenToWorldPoint(currentTouchPosition);
            dragSummary.cameraSource = usedCamera;
            dragSummary.direction    = currentTouchPosition - selectedObject.transform.position;

            dragSummary.amount = dragAmount;

            selectedObject.SendMessage("OnDrag", dragSummary, SendMessageOptions.DontRequireReceiver);

            if (Mathf.Abs(dragAmount.x) > minimumDragDistance)
            {
                selectedObject.SendMessage("OnHorizontalDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
                DispatchMessage("OnHorizontalDrag", dragSummary);
            }

            if (Mathf.Abs(dragAmount.y) > minimumDragDistance)
            {
                selectedObject.SendMessage("OnVerticalDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
예제 #3
0
 public void OnVerticalDrag(DragSummary dragSummary)
 {
     if (dragSummary.cameraSource.GetComponent <CameraTypes>().cameraType == CameraTypes.CameraType.UICAMERA)
     {
         if (scrollType == ScrollType.VERTICAL && canBeScrolled)
         {
             this.scrollableUIObjectManager.MoveVertical(dragSummary.amount * scrollSpeed);
         }
     }
 }
예제 #4
0
 public override void OnDrag(DragSummary dragSummary)
 {
     if (usesTopDownView)
     {
         lineDrawer.AddLine(new Vector3(dragSummary.position.x, this.transform.position.y, dragSummary.position.z));
     }
     else
     {
         lineDrawer.AddLine(new Vector3(dragSummary.position.x, dragSummary.position.y, this.transform.position.z));
     }
 }
예제 #5
0
 public virtual void OnDrag(DragSummary dragSummary)
 {
     if (this.canBeDragged)
     {
         if (usesTopDownView)
         {
             this.transform.position = new Vector3(dragSummary.position.x, this.transform.position.y, dragSummary.position.z);
         }
         else
         {
             this.transform.position = new Vector3(dragSummary.position.x, dragSummary.position.y, this.transform.position.z);
         }
     }
 }
예제 #6
0
    private void OnMouseDown()
    {
        foreach (Camera usedCamera in usedCameras)
        {
            Vector3 currentMousePosition = Input.mousePosition;
            Vector3 drag = (mouseClickPoint - currentMousePosition);

            mouseClickPoint -= (drag / dragFriction);

            DragSummary dragSummary = new DragSummary();
            dragSummary.position     = usedCamera.ScreenToWorldPoint(currentMousePosition);
            dragSummary.cameraSource = usedCamera;
            dragSummary.amount       = drag;

            if (selectedObject != null)
            {
                selectedObject.SendMessage("OnDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
            }

            if (Mathf.Abs(drag.x) > dragDistance)
            {
                if (selectedObject != null)
                {
                    selectedObject.SendMessage("OnHorizontalDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
                }
                DispatchMessage("OnHorizontalDrag", dragSummary);
            }

            if (Mathf.Abs(drag.y) > dragDistance)
            {
                if (selectedObject != null)
                {
                    selectedObject.SendMessage("OnVerticalDrag", dragSummary, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
예제 #7
0
 public void OnDrag(DragSummary dragSummary)
 {
     this.transform.position += onTouchMoveSpeed * new Vector3(dragSummary.direction.x, dragSummary.direction.y, 0f);
 }