public override bool processInput(GestureProfile profile)
    {
        if (Input.touchCount > 0)
        {
            //
            //Check for adding new touches
            //
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.touches[i];
                if (touch.phase == TouchPhase.Began)
                {
                    touchDatas.Add(touch.fingerId, new TouchData(touch));
                    origTouchCenter           = TouchCenter;
                    origCameraZoom            = Managers.Camera.ZoomLevel;
                    origAvgDistanceFromCenter = AverageDistanceFromCenter;
                }
            }
            maxTouchCount = Mathf.Max(maxTouchCount, Input.touchCount);

            //
            // Gesture Identification
            //

            if (touchEvent == TouchEvent.UNKNOWN)
            {
                if (maxTouchCount == 1)
                {
                    Touch     touch = Input.touches[0];
                    TouchData data  = touchDatas[touch.fingerId];
                    //Drag Gesture
                    if (Vector2.Distance(data.origPosScreen, touch.position) >= dragThreshold)
                    {
                        touchEvent = TouchEvent.DRAG;
                    }
                    //Hold Gesture
                    if (Time.time - data.origTime >= holdThreshold)
                    {
                        touchEvent = TouchEvent.HOLD;
                    }
                }
                //If more than one touch
                else if (maxTouchCount > 1)
                {
                    touchEvent = TouchEvent.CAMERA;
                }
            }
            //If converting from a player gesture to a camera gesture,
            else if (touchEvent != TouchEvent.CAMERA && maxTouchCount > 1)
            {
                //End the current player gesture
                //(No need to process tap gesture,
                //because it requires that all input stops to activate)
                Touch     touch = Input.touches[0];
                TouchData data  = touchDatas[touch.fingerId];
                switch (touchEvent)
                {
                //DRAG
                case TouchEvent.DRAG:
                    profile.processDragGesture(
                        data.origPosWorld,
                        Utility.ScreenToWorldPoint(touch.position),
                        DragType.DRAG_PLAYER,
                        true
                        );
                    break;

                //HOLD
                case TouchEvent.HOLD:
                    profile.processHoldGesture(
                        Utility.ScreenToWorldPoint(touch.position),
                        Time.time - data.origTime,
                        true
                        );
                    break;
                }
                //Convert to camera gesture
                touchEvent = TouchEvent.CAMERA;
            }

            //
            //Main Processing
            //

            if (maxTouchCount == 1)
            {
                Touch     touch = Input.touches[0];
                TouchData data  = touchDatas[touch.fingerId];
                switch (touchEvent)
                {
                //DRAG
                case TouchEvent.DRAG:
                    profile.processDragGesture(
                        data.origPosWorld,
                        Utility.ScreenToWorldPoint(touch.position),
                        DragType.DRAG_PLAYER,
                        touch.phase == TouchPhase.Ended
                        );
                    break;

                //HOLD
                case TouchEvent.HOLD:
                    profile.processHoldGesture(
                        Utility.ScreenToWorldPoint(touch.position),
                        Time.time - data.origTime,
                        touch.phase == TouchPhase.Ended
                        );
                    break;
                }

                //
                // Check for tap end
                //
                if (touch.phase == TouchPhase.Ended)
                {
                    //If it's unknown,
                    if (touchEvent == TouchEvent.UNKNOWN)
                    {
                        //Then it's a tap
                        profile.processTapGesture(Utility.ScreenToWorldPoint(touch.position));
                    }
                }
            }
            else if (maxTouchCount > 1)
            {
                //Get the center and drag the camera to it
                profile.processDragGesture(
                    origTouchCenterWorld,
                    Utility.ScreenToWorldPoint(TouchCenter),
                    DragType.DRAG_CAMERA,
                    Input.touches
                    .Where(t =>
                           t.phase != TouchPhase.Ended &&
                           t.phase != TouchPhase.Canceled
                           ).ToArray()
                    .Length == 0
                    );
                //Get the change in scale and zoom the camera
                float adfc = AverageDistanceFromCenter;
                if (adfc > 0)
                {
                    float scaleFactor = origAvgDistanceFromCenter / adfc;
                    Managers.Camera.ZoomLevel = origCameraZoom * scaleFactor;
                }
            }

            //
            //Check for removing touches
            //
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.touches[i];
                if (touch.phase == TouchPhase.Ended)
                {
                    touchDatas.Remove(touch.fingerId);
                    origTouchCenter           = TouchCenter;
                    origCameraZoom            = Managers.Camera.ZoomLevel;
                    origAvgDistanceFromCenter = AverageDistanceFromCenter;
                }
            }
            return(true);
        }
        //If there is no input,
        else
        {
            //Reset gesture variables
            touchEvent                = TouchEvent.UNKNOWN;
            maxTouchCount             = 0;
            origTouchCenter           = Vector2.zero;
            origCameraZoom            = Managers.Camera.ZoomLevel;
            origAvgDistanceFromCenter = 0;
            touchDatas.Clear();
            return(false);
        }
    }
Beispiel #2
0
 public override bool processInput(GestureProfile profile)
 {
     if (InputOngoing)
     {
         float horizontal = Input.GetAxis("Horizontal");
         float vertical   = Input.GetAxis("Vertical");
         if (Input.GetButton("Jump"))
         {
             vertical = 1;
         }
         Vector2 dir = (horizontal != 0 || vertical != 0)
             ? (
             (Vector2)((Camera.main.transform.up * vertical)
                       + (Camera.main.transform.right * horizontal)
                       ).normalized)
             : Vector2.zero;
         bool isInputNow   = dir != Vector2.zero;
         bool wasInputPrev = prevDir != Vector2.zero;
         if (isInputNow || wasInputPrev)
         {
             if (!wasInputPrev && isInputNow)
             {
                 //Gesture Start
                 gestureStartTime = Time.time;
             }
             float range = Managers.Player.Teleport.baseRange;
             if (Input.GetButton("Short"))
             {
                 range /= 2;
             }
             profile.processHoldGesture(
                 (Vector2)Managers.Player.transform.position + (dir * range),
                 Time.time - gestureStartTime,
                 !isInputNow
                 );
             return(true);
         }
         else if (Input.GetButtonDown("Rotate"))
         {
             profile.processTapGesture(Managers.Player.transform.position);
             return(true);
         }
         prevDir = dir;
     }
     return(false);
 }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        //
        //Threshold updating
        //
        float newDT = Mathf.Min(Screen.width, Screen.height) / 20;

        if (dragThreshold != newDT)
        {
            dragThreshold = newDT;
        }
        //
        //Input scouting
        //
        if (Input.touchCount > 2)
        {
            touchCount = 0;
        }
        else if (Input.touchCount == 2)
        {
            touchCount = 2;
            if (Input.GetTouch(1).phase == TouchPhase.Began)
            {
                clickState     = ClickState.Began;
                origMP2        = Input.GetTouch(1).position;
                origScalePoint = cmaController.getScalePointIndex();
            }
            else if (Input.GetTouch(1).phase == TouchPhase.Ended)
            {
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP2     = Input.GetTouch(1).position;
            }
        }
        else if (Input.touchCount == 1)
        {
            touchCount = 1;
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                clickState = ClickState.Began;
                origMP     = Input.GetTouch(0).position;
            }
            else if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
                clickState = ClickState.Ended;
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP      = Input.GetTouch(0).position;
            }
        }
        else if (Input.GetMouseButton(0))
        {
            touchCount = 1;
            if (Input.GetMouseButtonDown(0))
            {
                clickState = ClickState.Began;
                origMP     = Input.mousePosition;
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP      = Input.mousePosition;
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            clickState = ClickState.Ended;
        }
        else if (Input.GetAxis("Mouse ScrollWheel") != 0)
        {
            clickState = ClickState.InProgress;
        }
        else if (Input.touchCount == 0 && !Input.GetMouseButton(0))
        {
            touchCount = 0;
            clickState = ClickState.None;
        }

        //
        //Preliminary Processing
        //Stats are processed here
        //
        switch (clickState)
        {
        case ClickState.Began:
            if (touchCount < 2)
            {
                curMP            = origMP;
                maxMouseMovement = 0;
                origCP           = cam.transform.position - player.transform.position;
                origTime         = Time.time;
                curTime          = origTime;
            }
            else if (touchCount == 2)
            {
                curMP2 = origMP2;
            }
            break;

        case ClickState.Ended:     //do the same thing you would for "in progress"
        case ClickState.InProgress:
            float mm = Vector3.Distance(curMP, origMP);
            if (mm > maxMouseMovement)
            {
                maxMouseMovement = mm;
            }
            curTime  = Time.time;
            holdTime = curTime - origTime;
            break;

        case ClickState.None: break;

        default:
            throw new System.Exception("Click State of wrong type, or type not processed! (Stat Processing) clickState: " + clickState);
        }
        curMPWorld = (Vector2)cam.ScreenToWorldPoint(curMP);//cast to Vector2 to force z to 0


        //
        //Input Processing
        //
        if (touchCount == 1)
        {
            if (clickState == ClickState.Began)
            {
                if (touchCount < 2)
                {
                    //Set all flags = true
                    cameraDragInProgress = false;
                    isDrag        = false;
                    isTapGesture  = true;
                    isHoldGesture = false;
                    if (CHEATS_ALLOWED && curMP.x < 20 && curMP.y < 20)
                    {
                        cheatTaps++;
                        cheatTapsTime = Time.time + 1;//give one more second to enter taps
                        if (cheatTaps >= cheatTapsThreshold)
                        {
                            cheatsEnabled = !cheatsEnabled;
                            cheatTaps     = 0;
                            cheatTapsTime = 0;
                        }
                    }
                }
            }
            else if (clickState == ClickState.InProgress)
            {
                if (maxMouseMovement > dragThreshold)
                {
                    if (!isHoldGesture)
                    {
                        isTapGesture         = false;
                        isDrag               = true;
                        cameraDragInProgress = true;
                    }
                }
                if (holdTime > holdThreshold * holdThresholdScale)
                {
                    if (!isDrag)
                    {
                        isTapGesture   = false;
                        isHoldGesture  = true;
                        Time.timeScale = holdTimeScale;
                    }
                }
                if (isDrag)
                {
                    //Check to make sure Merky doesn't get dragged off camera
                    Vector3 delta       = cam.ScreenToWorldPoint(origMP) - cam.ScreenToWorldPoint(curMP);
                    Vector3 newPos      = player.transform.position + origCP + delta;
                    Vector3 playerUIpos = cam.WorldToViewportPoint(player.transform.position + (new Vector3(cam.transform.position.x, cam.transform.position.y) - newPos));
                    if (playerUIpos.x >= 0 && playerUIpos.x <= 1 && playerUIpos.y >= 0 && playerUIpos.y <= 1)
                    {
                        //Move the camera
                        cam.transform.position = newPos;
                    }
                }
                else if (isHoldGesture)
                {
                    currentGP.processHoldGesture(curMPWorld, holdTime, false);
                }
            }
            else if (clickState == ClickState.Ended)
            {
                if (isDrag)
                {
                    cmaController.pinPoint();
                }
                else if (isHoldGesture)
                {
                    currentGP.processHoldGesture(curMPWorld, holdTime, true);
                }
                else if (isTapGesture)
                {
                    tapCount++;
                    adjustHoldThreshold(holdTime, false);
                    bool checkPointPort = false;//Merky is in a checkpoint teleporting to another checkpoint
                    if (plrController.getIsInCheckPoint())
                    {
                        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Checkpoint_Root"))
                        {
                            if (go.GetComponent <CheckPointChecker>().checkGhostActivation(curMPWorld))
                            {
                                checkPointPort = true;
                                currentGP.processTapGesture(go);
                                break;
                            }
                        }
                    }
                    if (!checkPointPort)
                    {
                        currentGP.processTapGesture(curMPWorld);
                    }
                }

                //Set all flags = false
                cameraDragInProgress = false;
                isDrag         = false;
                isTapGesture   = false;
                isHoldGesture  = false;
                Time.timeScale = 1;
            }
            else
            {
                throw new System.Exception("Click State of wrong type, or type not processed! (Input Processing) clickState: " + clickState);
            }
        }
        else  //touchCount == 0 || touchCount >= 2
        {
            if (clickState == ClickState.Began)
            {
            }
            else if (clickState == ClickState.InProgress)
            {
                //
                //Zoom Processing
                //
                //
                //Mouse Scrolling Zoom
                //
                if (Input.GetAxis("Mouse ScrollWheel") < 0)
                {
                    currentGP.processPinchGesture(1);
                }
                else if (Input.GetAxis("Mouse ScrollWheel") > 0)
                {
                    currentGP.processPinchGesture(-1);
                }
                //
                //Pinch Touch Zoom
                //2015-12-31 (1:23am): copied from https://unity3d.com/learn/tutorials/modules/beginner/platform-specific/pinch-zoom
                //

                // If there are two touches on the device...
                if (touchCount == 2)
                {
                    // Store both touches.
                    Touch touchZero = Input.GetTouch(0);
                    Touch touchOne  = Input.GetTouch(1);

                    // Find the position in the previous frame of each touch.
                    Vector2 touchZeroPrevPos = origMP;
                    Vector2 touchOnePrevPos  = origMP2;

                    // Find the magnitude of the vector (the distance) between the touches in each frame.
                    float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
                    float touchDeltaMag     = (touchZero.position - touchOne.position).magnitude;

                    // Find the difference in the distances between each frame.
                    int deltaMagnitudeQuo = (int)System.Math.Truncate(Mathf.Max(prevTouchDeltaMag, touchDeltaMag) / Mathf.Min(prevTouchDeltaMag, touchDeltaMag));
                    deltaMagnitudeQuo *= (int)Mathf.Sign(prevTouchDeltaMag - touchDeltaMag);

                    //Update the camera's scale point index
                    currentGP.processPinchGesture(origScalePoint + deltaMagnitudeQuo - cmaController.getScalePointIndex());
                }
            }
            else if (clickState == ClickState.Ended)
            {
                origScalePoint = cmaController.getScalePointIndex();
            }
        }

        //
        //Application closing
        //
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (cheatTapsTime <= Time.time)
        {
            //Reset cheat taps
            cheatTaps = 0;
        }
    }
Beispiel #4
0
    public override bool processInput(GestureProfile profile)
    {
        if (InputOngoing)
        {
            //
            //Check for click start
            //
            if (mouseEvent == MouseEvent.UNKNOWN)
            {
                //Click beginning
                if (Input.GetMouseButtonDown(mouseButton))
                {
                    origPosScreen = Input.mousePosition;
                    origTime      = Time.time;
                    dragType      = DragType.DRAG_PLAYER;
                }
                else if (Input.GetMouseButtonDown(mouseButton2))
                {
                    origPosScreen = Input.mousePosition;
                    origTime      = Time.time;
                    dragType      = DragType.DRAG_CAMERA;
                }
                else if (Input.GetAxis("Mouse ScrollWheel") != 0)
                {
                    mouseEvent = MouseEvent.SCROLL;
                }
                //Click middle
                else
                {
                    //Check Drag
                    float dragDistance = Vector2.Distance(origPosScreen, Input.mousePosition);
                    if (dragDistance >= dragThreshold)
                    {
                        mouseEvent = MouseEvent.DRAG;
                    }
                    //Check Hold
                    else if (Time.time - origTime >= holdThreshold)
                    {
                        mouseEvent = MouseEvent.HOLD;
                    }
                }
            }

            //
            //Main Processing
            //

            switch (mouseEvent)
            {
            case MouseEvent.DRAG:
                profile.processDragGesture(
                    OrigPosWorld,
                    Utility.ScreenToWorldPoint(Input.mousePosition),
                    dragType,
                    Input.GetMouseButtonUp(mouseButton) || Input.GetMouseButtonUp(mouseButton2)
                    );
                break;

            case MouseEvent.HOLD:
                profile.processHoldGesture(
                    Utility.ScreenToWorldPoint(Input.mousePosition),
                    Time.time - origTime,
                    Input.GetMouseButtonUp(mouseButton) || Input.GetMouseButtonUp(mouseButton2)
                    );
                break;

            case MouseEvent.SCROLL:
                if (Input.GetAxis("Mouse ScrollWheel") < 0)
                {
                    Managers.Camera.ZoomLevel *= 1.2f;
                }
                else if (Input.GetAxis("Mouse ScrollWheel") > 0)
                {
                    Managers.Camera.ZoomLevel /= 1.2f;
                }
                break;
            }

            //
            //Check for click end
            //
            if (Input.GetMouseButtonUp(mouseButton))
            {
                //If it's unknown,
                if (mouseEvent == MouseEvent.UNKNOWN)
                {
                    //Then it's a click.
                    mouseEvent = MouseEvent.CLICK;
                    profile.processTapGesture(Utility.ScreenToWorldPoint(Input.mousePosition));
                }
            }
            if (Input.GetMouseButtonUp(mouseButton2))
            {
                //If it's unknown,
                if (mouseEvent == MouseEvent.UNKNOWN)
                {
                    //Then it's a camera drag
                    mouseEvent = MouseEvent.DRAG;
                    profile.processDragGesture(
                        OrigPosWorld,
                        Utility.ScreenToWorldPoint(Input.mousePosition),
                        dragType,
                        true
                        );
                }
            }
            return(true);
        }
        //If there's no input,
        else
        {
            //Reset gesture variables
            mouseEvent = MouseEvent.UNKNOWN;
            dragType   = DragType.UNKNOWN;
            //Hover gesture
            profile.processHoverGesture(
                Utility.ScreenToWorldPoint(Input.mousePosition)
                );
            return(false);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //
        //Threshold updating
        //
        float newDT = Mathf.Min(Screen.width, Screen.height) / 20;

        if (dragThreshold != newDT)
        {
            dragThreshold = newDT;
        }
        //
        //Input scouting
        //
        if (Input.touchCount > 2)
        {
            touchCount = 0;
        }
        else if (Input.touchCount == 2)
        {
            touchCount = 2;
            if (Input.GetTouch(1).phase == TouchPhase.Began)
            {
                clickState     = ClickState.Began;
                origMP2        = Input.GetTouch(1).position;
                origScalePoint = Managers.Camera.getScalePointIndex();
            }
            else if (Input.GetTouch(1).phase == TouchPhase.Ended)
            {
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP2     = Input.GetTouch(1).position;
            }
        }
        else if (Input.touchCount == 1)
        {
            touchCount = 1;
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                clickState = ClickState.Began;
                origMP     = Input.GetTouch(0).position;
            }
            else if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
                clickState = ClickState.Ended;
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP      = Input.GetTouch(0).position;
            }
        }
        else if (Input.GetMouseButton(0))
        {
            touchCount = 1;
            if (Input.GetMouseButtonDown(0))
            {
                clickState   = ClickState.Began;
                origMP       = Input.mousePosition;
                isRightClick = false;
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP      = Input.mousePosition;
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            clickState = ClickState.Ended;
        }
        else if (Input.GetMouseButton(1))
        {
            touchCount = 1;
            if (Input.GetMouseButtonDown(1))
            {
                clickState   = ClickState.Began;
                origMP       = Input.mousePosition;
                isRightClick = true;
            }
            else
            {
                clickState = ClickState.InProgress;
                curMP      = Input.mousePosition;
            }
        }
        else if (Input.GetMouseButtonUp(1))
        {
            clickState = ClickState.Ended;
        }
        else if (Input.GetAxis("Mouse ScrollWheel") != 0)
        {
            clickState = ClickState.InProgress;
        }
        else if (Input.touchCount == 0 &&
                 !Input.GetMouseButton(0) &&
                 !Input.GetMouseButton(1))
        {
            touchCount = 0;
            clickState = ClickState.None;
        }

        //
        //Preliminary Processing
        //Stats are processed here
        //
        switch (clickState)
        {
        case ClickState.Began:
            if (touchCount < 2)
            {
                curMP            = origMP;
                maxMouseMovement = 0;
                origCP           = Camera.main.transform.position;
                origTime         = Time.time;
                curTime          = origTime;
            }
            else if (touchCount == 2)
            {
                curMP2 = origMP2;
            }
            break;

        case ClickState.Ended:     //do the same thing you would for "in progress"
        case ClickState.InProgress:
            float mm = Vector3.Distance(curMP, origMP);
            if (mm > maxMouseMovement)
            {
                maxMouseMovement = mm;
            }
            curTime  = Time.time;
            holdTime = curTime - origTime;
            break;

        case ClickState.None: break;

        default:
            throw new System.Exception("Click State of wrong type, or type not processed! (Stat Processing) clickState: " + clickState);
        }
        curMPWorld = (Vector2)Camera.main.ScreenToWorldPoint(curMP);//cast to Vector2 to force z to 0

        if (Input.touchCount == 0 && Input.mousePresent)
        {
            currentGP.processCursorMoveGesture((Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition), true);
        }
        else
        {
            currentGP.processCursorMoveGesture(Vector3.zero, false);
        }

        //
        //Input Processing
        //
        if (touchCount == 1)
        {
            if (clickState == ClickState.Began)
            {
                if (touchCount < 2)
                {
                    //Set all flags = true
                    cameraDragInProgress = false;
                    isDrag        = false;
                    isTapGesture  = true;
                    isHoldGesture = false;
                }
            }
            else if (clickState == ClickState.InProgress)
            {
                if (maxMouseMovement > dragThreshold)
                {
                    if (!isHoldGesture)
                    {
                        isTapGesture         = false;
                        isDrag               = true;
                        cameraDragInProgress = true;
                    }
                }
                if (holdTime > holdThreshold ||
                    isRightClick)
                {
                    if (!isDrag)
                    {
                        isTapGesture   = false;
                        isHoldGesture  = true;
                        Time.timeScale = holdTimeScale;
                    }
                }
                if (isDrag)
                {
                    //Check to make sure Merky doesn't get dragged off camera
                    Vector3 delta  = Camera.main.ScreenToWorldPoint(origMP) - Camera.main.ScreenToWorldPoint(curMP);
                    Vector3 newPos = origCP + delta;
                    //Move the camera
                    Camera.main.transform.position = newPos;
                    Managers.Camera.pinpoint();
                }
                else if (isHoldGesture)
                {
                    currentGP.processHoldGesture(curMPWorld, holdTime, false);
                }
            }
            else if (clickState == ClickState.Ended)
            {
                if (isDrag)
                {
                    Managers.Camera.pinpoint();
                }
                else if (isHoldGesture)
                {
                    currentGP.processHoldGesture(curMPWorld, holdTime, true);
                }
                else if (isTapGesture)
                {
                    tapCount++;
                    currentGP.processTapGesture(curMPWorld);
                    tapGesture?.Invoke();
                }

                //Set all flags = false
                cameraDragInProgress = false;
                isDrag         = false;
                isTapGesture   = false;
                isHoldGesture  = false;
                Time.timeScale = 1;
            }
            else
            {
                throw new System.Exception("Click State of wrong type, or type not processed! (Input Processing) clickState: " + clickState);
            }
        }
        else
        {//touchCount == 0 || touchCount >= 2
            if (clickState == ClickState.Began)
            {
            }
            else if (clickState == ClickState.InProgress)
            {
                //
                //Zoom Processing
                //
                //
                //Mouse Scrolling Zoom
                //
                if (Input.GetAxis("Mouse ScrollWheel") < 0)
                {
                    currentGP.processPinchGesture(1);
                }
                else if (Input.GetAxis("Mouse ScrollWheel") > 0)
                {
                    currentGP.processPinchGesture(-1);
                }
                //
                //Pinch Touch Zoom
                //2015-12-31 (1:23am): copied from https://unity3d.com/learn/tutorials/modules/beginner/platform-specific/pinch-zoom
                //

                // If there are two touches on the device...
                if (touchCount == 2)
                {
                    // Store both touches.
                    Touch touchZero = Input.GetTouch(0);
                    Touch touchOne  = Input.GetTouch(1);

                    // Find the position in the previous frame of each touch.
                    Vector2 touchZeroPrevPos = origMP;
                    Vector2 touchOnePrevPos  = origMP2;

                    // Find the magnitude of the vector (the distance) between the touches in each frame.
                    float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
                    float touchDeltaMag     = (touchZero.position - touchOne.position).magnitude;

                    // Find the difference in the distances between each frame.
                    int deltaMagnitudeQuo = (int)System.Math.Truncate(Mathf.Max(prevTouchDeltaMag, touchDeltaMag) / Mathf.Min(prevTouchDeltaMag, touchDeltaMag));
                    deltaMagnitudeQuo *= (int)Mathf.Sign(prevTouchDeltaMag - touchDeltaMag);

                    //Update the camera's scale point index
                    currentGP.processPinchGesture(origScalePoint + deltaMagnitudeQuo - Managers.Camera.getScalePointIndex());
                }
            }
            else if (clickState == ClickState.Ended)
            {
                origScalePoint = Managers.Camera.getScalePointIndex();
            }
        }

        //
        //Application closing
        //
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
    }