Beispiel #1
0
    void Update()
    {
        // Update our camera target based on whether we have a client connection or not *and* based on the platform
        if ((myNetworkManager.IsClientConnected()) && (m_globalSettings.ShowPalette) && (!isTakingScreenShot))
        {
            setTarget(connectedTarget);
        }
        else
        {
            setTarget(disconnectedTarget);
            SpriteBehavior.HandleCameraZoom(1.0f, GetComponent <Camera>(), 0.1f, minOrthographicSize, maxOrthographicSize);
        }

        if (GetComponent <Camera>().orthographicSize >= 12f)
        {
            connectedTarget.transform.position = myStartingConnectedPosition;
        }

        if (activeTarget != null)
        {
            Vector3 pos = this.transform.position;
            pos.x = Mathf.SmoothDamp(pos.x, activeTarget.position.x, ref (velocity.x), smoothTime);
            pos.y = Mathf.SmoothDamp(pos.y, activeTarget.position.y, ref (velocity.y), smoothTime);
            this.transform.position = pos;
            ClampPosition();
        }
    }
    private void HandleTouchZooming(ref Touch touchZero, ref Touch touchOne)
    {
        // Find the position in the previous frame of each touch.
        Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
        Vector2 touchOnePrevPos  = touchOne.position - touchOne.deltaPosition;

        // 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.
        float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;

        if (deltaMagnitudeDiff != 0f)
        {
            myDebounceTimer = 0.5f;
            SpriteBehavior.HandleCameraZoom(deltaMagnitudeDiff, inputCamera, m_cameraZoomSpeed, m_minCameraSize, m_maxCameraSize);
        }
    }