Example #1
0
    public void Update()
    {
        LeapInputEx.Update();

        //if (== Gesture.GestureType.TYPEKEYTAP)
        //if (pointables[0].activeSelf){
        //	position = pointables[0].transform.position;
        //}

        if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1))
        {
            attack = shoot.AttackMethod.Fire;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
        {
            attack = shoot.AttackMethod.Lightning;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3))
        {
            attack = shoot.AttackMethod.Water;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4))
        {
            attack = shoot.AttackMethod.Wind;
        }
    }
Example #2
0
    void Update()
    {
        // Process the Leap message pump
        LeapInputEx.Update();

        Vector3    targetPosition = originalCamera.position;
        Quaternion targetRotation = originalCamera.rotation;

        if (useOverheadCamera)
        {
            // Smoothly move over to the overhead camera if it has been selected
            targetPosition = overheadCamera.position;
            targetRotation = overheadCamera.rotation;
        }
        Transform cam = Camera.main.transform;

        cam.position = Vector3.Lerp(cam.position, targetPosition, Time.deltaTime);
        cam.rotation = Quaternion.Slerp(cam.rotation, targetRotation, Time.deltaTime * kRotationalSmoothingSpeed);
    }
Example #3
0
    private void Update()
    {
        LeapInputEx.Update();

        trayOffset += trayScrollSpeed * Time.deltaTime;

        // Slow the scroll speed over time (similar to touch devices)
        trayScrollSpeed = Mathf.SmoothDamp(trayScrollSpeed, 0f, ref traySeekVelocity, 1f);

        // Handle the two cases where we overscroll or underscroll the list
        if (trayOffset < 0f)
        {
            trayOffset = Mathf.SmoothDamp(trayOffset, 0f, ref trayOffsetVelocity, 1f);
        }
        if (trayOffset > (trayHeight - Screen.height))
        {
            trayOffset = Mathf.SmoothDamp(trayOffset, trayHeight - Screen.height, ref trayOffsetVelocity, 1f);
        }

        Debug.DrawLine(swipeStart, swipeEnd, Color.red);
    }
Example #4
0
    private void Update()
    {
        LeapInputEx.Update();

        if (webCamPics.Ready)
        {
            snapshotCountdown -= Time.deltaTime;
            if (!webCamPics.snapshotTaken && snapshotCountdown < 0f)
            {
                webCamPics.TakeSnapshot();
            }
        }

        if (selectedPiece)
        {
            Vector3 position         = Vector3.zero;
            int     activePointables = 0;
            foreach (GameObject pointable in pointables)
            {
                if (pointable.active)
                {
                    position += pointable.transform.position;
                    activePointables++;
                }
            }

            if (activePointables > 0)
            {
                position   = position * 1f / activePointables;
                position.y = selectedPiece.transform.position.y;
                position  += pieceTargetOffset;
                if (!collider.bounds.Contains(position))
                {
                    position = collider.ClosestPointOnBounds(position);
                }
                pieceTargetPosition = position;
            }

            selectedPiece.transform.position = Vector3.Lerp(selectedPiece.transform.position, pieceTargetPosition, Time.deltaTime);

            if (selected)
            {
                // If the object is also selected, then we need to update the outline rect
                GenerateSelectedRect();
            }
        }

        if (selected)
        {
            // The switch is a special case where we only want to handle a tap
            if (selected.GetComponent <Switch>())
            {
                selectedTime = hoverTime;
            }
            else
            {
                switch (selectionMethod)
                {
                case SelectionMethod.Hover:
                    selectedTime = Mathf.Clamp(selectedTime + Time.deltaTime, 0f, hoverTime);
                    if (selectedTime >= hoverTime)
                    {
                        TriggerSelected();
                    }
                    break;

                default:
                    selectedTime = hoverTime;
                    break;
                }
            }
        }

        // Pinch is handled separately as a piece can be de-selected even when the pointables are not inside the volume
        if (selectionMethod == SelectionMethod.Pinch)
        {
            selectedTime = hoverTime;
            GameObject firstPointable = null;
            if (Time.time >= nextPinch)
            {
                foreach (GameObject p in pointables)
                {
                    if (!p.active)
                    {
                        continue;
                    }

                    if (firstPointable)
                    {
                        pinchDistance = Vector3.Distance(firstPointable.transform.position, p.transform.position);
                        if (pinchDistance <= pinchRadius)
                        {
                            if (selected)
                            {
                                TriggerSelected();
                            }
                            else if (selectedPiece)
                            {
                                // Allow for a selected piece to be de-selected even if we are not inside the collision volume
                                selectedPiece = null;
                            }
                            nextPinch = Time.time + pinchCoolOff;
                        }
                        break;
                    }
                    else
                    {
                        firstPointable = p;
                    }
                }
            }
        }
    }
Example #5
0
 void Update()
 {
     //process the Leap message pump
     LeapInputEx.Update();
 }