Exemple #1
0
    void HandleRotation()
    {
        if (Input.GetMouseButtonDown(1))
        {
            dragStart = Input.mousePosition;
        }

        if (Input.GetMouseButton(1))
        {
            float d     = Vector2.Distance(dragStart, Input.mousePosition);
            float delta = GlowEngine.RemapValue(d, 0, 50, 0, rotateSpeed);

            if (Input.mousePosition.x < dragStart.x)
            {
                rotateAmount = -delta;
            }
            else if (Input.mousePosition.x > dragStart.x)
            {
                rotateAmount = delta;
            }
            else
            {
                rotateAmount = 0;
            }

            transform.DORotate(new Vector3(0, rotateAmount, 0), rotateDuration, RotateMode.WorldAxisAdd);
            dragStart = Input.mousePosition;
        }
    }
Exemple #2
0
    void HandleZoom()
    {
        float axis = Input.GetAxis("Mouse ScrollWheel");
        float y    = cam.transform.localPosition.y;

        // scroll up
        if (axis > 0f)
        {
            if (y - .2f >= 3f)
            {
                targetZoom = cam.transform.localPosition - new Vector3(0, .2f, 0);
            }
        }
        // scroll down
        else if (axis < 0f)
        {
            if (y + .2f <= 6f)
            {
                targetZoom = cam.transform.localPosition + new Vector3(0, .2f, 0);
            }
        }

        float fdScalar = GlowEngine.RemapValue(y, 3, 6, focusDistMin, focusDistMax);

        targetDOF.Set(fdScalar, fdScalar, fdScalar);
        targetLookAt.y = 26.87f;
        //30.58
        targetLookAt.x = GlowEngine.RemapValue(targetZoom.y, .2f, 6f, 50f, 55f);
    }
Exemple #3
0
    void HandleDragging()
    {
        if (Input.GetMouseButtonDown(0))
        {
            dragOrigin = Input.mousePosition;
            return;
        }

        if (!Input.GetMouseButton(0) || dClickCount > 1)
        {
            dragging = false;
            return;
        }

        dragging = true;
        float scalar = Vector3.Distance(dragOrigin, Input.mousePosition);

        scalar = GlowEngine.RemapValue(scalar, 0, 30, 0, .7f);

        //Vector3 pos = cam.ScreenToViewportPoint( Input.mousePosition - dragOrigin );
        Vector3 direction = Input.mousePosition - dragOrigin;

        direction = Vector3.Normalize(direction);

        Vector3 move = new Vector3(direction.x * scalar, 0, direction.y * scalar);

        transform.Translate(-move, Space.Self);
        targetPos  = transform.position;
        dragOrigin = Input.mousePosition;
    }
Exemple #4
0
    void AddThresholdTick()
    {
        if (threatStack.Count == 0)
        {
            nextTickObject = null;
            return;
        }

        Threat t = threatStack.Peek();

        GameObject go    = Instantiate(tickPrefab, tickParent);
        float      angle = GlowEngine.RemapValue(t.threshold, 0, threatMax, 0, 360);

        go.transform.DORotate(new Vector3(0, 0, -angle), 1).SetEase(Ease.OutBounce);
        Text text = go.transform.GetComponentInChildren <Text>();

        text.text = t.threshold.ToString();
        text.transform.Rotate(new Vector3(0, 0, angle));
        go.AddComponent <ThresholdMeta>();
        go.GetComponent <ThresholdMeta>().threshold = t.threshold;

        nextTickObject = go;
    }