// Update is called once per frame
    void Update()
    {
        //if (Input.touchCount > 0 && !MouseSlice.slicedAny)
        if (Input.GetButtonDown("Fire1") && !MouseSlice.slicedAny)
        {
            start = new Vector3(0.5f, 0.0f, 0.0f);
            end   = new Vector3(0.5f, 1.0f, 0.0f);
            //dragging = true;
            //print(cam.ScreenToViewportPoint(Input.mousePosition));
            split = false;

            // Finished dragging. We draw the line segment
            //end = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = false;

            var startRay = cam.ViewportPointToRay(start);
            var endRay   = cam.ViewportPointToRay(end);

            // Raise OnLineDrawnEvent
            OnLineDrawn?.Invoke(
                startRay.GetPoint(cam.nearClipPlane),
                endRay.GetPoint(cam.nearClipPlane),
                endRay.direction.normalized);
        }
    }
    void Update()
    {
        if (mouseSlice.IsObjectDragNow)
        {
            dragging = false;
            return;
        }

        if (!dragging && Input.GetMouseButtonDown(0))
        {
            start    = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = true;
        }

        if (dragging)
        {
            end = cam.ScreenToViewportPoint(Input.mousePosition);
        }

        if (dragging && Input.GetMouseButtonUp(0))
        {
            end      = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = false;

            var startRay = cam.ViewportPointToRay(start);
            var endRay   = cam.ViewportPointToRay(end);

            OnLineDrawn?.Invoke(
                startRay.GetPoint(cam.nearClipPlane),
                endRay.GetPoint(cam.nearClipPlane),
                endRay.direction.normalized);
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    // 이 부분을 동작 실행될 때 칼날 지점 .
    void Update()
    {
        if (!dragging && Input.GetMouseButtonDown(0))
        {
            start    = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = true;
        }
        // 이 부분은 칼날 움직이는 거 .
        if (dragging)
        {
            end = cam.ScreenToViewportPoint(Input.mousePosition);
        }
        // 이 부분은 칼날 끝날때 .
        if (dragging && Input.GetMouseButtonUp(0))
        {
            // Finished dragging. We draw the line segment
            end      = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = false;

            var startRay = cam.ViewportPointToRay(start);
            var endRay   = cam.ViewportPointToRay(end);

            // Raise OnLineDrawnEvent
            OnLineDrawn?.Invoke(
                startRay.GetPoint(cam.nearClipPlane),
                endRay.GetPoint(cam.nearClipPlane),
                endRay.direction.normalized);
        }
    }
Exemplo n.º 4
0
    void DragStyleCutting()
    {
        if (allowCutting == false)
        {
            return;
        }
        if (!dragging && Input.GetMouseButtonDown(0))
        {
            start    = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = true;
        }

        if (dragging)
        {
            end = cam.ScreenToViewportPoint(Input.mousePosition);
        }

        if (Input.GetMouseButtonDown(0))
        {
            // Finished dragging. We draw the line segment


            end      = cam.ScreenToViewportPoint(Input.mousePosition);
            dragging = false;

            var startRay = cam.ViewportPointToRay(start);
            var endRay   = cam.ViewportPointToRay(end);

            // Raise OnLineDrawnEvent
            if (objectCounter.CountSlicedObjects() < 50)
            {
                OnLineDrawn?.Invoke(
                    startRay.GetPoint(cam.nearClipPlane),
                    endRay.GetPoint(cam.nearClipPlane),
                    endRay.direction.normalized);
            }
            else
            {
                allowCutting = false;
                Debug.Log("limit reached");
                GameSequencer.Instance.OnItemCutFinish();
            }
        }
    }
Exemplo n.º 5
0
    void CutOnClick()
    {
        if (allowCutting == false)
        {
            return;
        }


        start = cam.WorldToViewportPoint(bladeStartpoint.transform.position);
        end   = cam.WorldToViewportPoint(bladeEndPoint.transform.position);

        Debug.DrawLine(start, end, Color.black);

        dragging = false;

        var startRay = cam.ViewportPointToRay(start);
        var endRay   = cam.ViewportPointToRay(end);

        Debug.DrawLine(startRay.origin, startRay.direction * 3);
        Debug.DrawLine(endRay.origin, endRay.direction * 3);

        // Raise OnLineDrawnEvent
        if (objectCounter.CountSlicedObjects() < 50)
        {
            OnLineDrawn?.Invoke(
                startRay.GetPoint(cam.nearClipPlane),
                endRay.GetPoint(cam.nearClipPlane),
                endRay.direction.normalized);
        }
        else
        {
            allowCutting = false;
            Debug.Log("limit reached");
            GameSequencer.Instance.OnItemCutFinish();
        }
    }
Exemplo n.º 6
0
    void CutOnClick_02()
    {
        if (allowCutting == false)
        {
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            start = bladeStartpoint.transform.position;
            end   = bladeEndPoint.transform.position;



            Debug.DrawLine(start, end, Color.black);

            dragging = false;

            var startRay = cam.ViewportPointToRay(start);
            var endRay   = cam.ViewportPointToRay(end);

            Debug.DrawLine(startRay.origin, startRay.direction * 3);
            Debug.DrawLine(endRay.origin, endRay.direction * 3);

            // Raise OnLineDrawnEvent
            if (objectCounter.CountSlicedObjects() < 50)
            {
                OnLineDrawn?.Invoke(start, end, Vector3.right);
            }
            else
            {
                allowCutting = false;
                Debug.Log("limit reached");
                GameSequencer.Instance.OnItemCutFinish();
            }
        }
    }