Пример #1
0
    /*
     * Reset the zoom to the starting field of view.
     */
    public void ResetZoom(float duration)
    {
        StopCoroutine("SetFieldOfView");
        ZoomProperty zoomProperty = new ZoomProperty(defaultFieldOfView, duration);

        StartCoroutine("SetFieldOfView", zoomProperty);
    }
Пример #2
0
 /*
  * Zoom by a given ratio over a given duration in seconds. Increases/decreases zoom
  * level linearly over time. Example: 1.05 would evenly zoom in 5% over 5 seconds.
  */
 public void Zoom(float targetZoomRatio, float duration)
 {
     // Convert our "zoom ratio" to a "field of view" ratio which is the inverse
     // i.e. 1.05 zoom-in means 0.95 field of view.
     float fieldOfViewRatio = 1.0f - (targetZoomRatio - 1.0f);
     float newFieldOfView = fieldOfViewRatio * defaultFieldOfView;
     ZoomProperty zoomProperty = new ZoomProperty (newFieldOfView, duration);
     StopCoroutine ("SetFieldOfView");
     StartCoroutine ("SetFieldOfView", zoomProperty);
 }
Пример #3
0
    /*
     * Zoom by a given ratio over a given duration in seconds. Increases/decreases zoom
     * level linearly over time. Example: 1.05 would evenly zoom in 5% over 5 seconds.
     */
    public void Zoom(float targetZoomRatio, float duration)
    {
        // Convert our "zoom ratio" to a "field of view" ratio which is the inverse
        // i.e. 1.05 zoom-in means 0.95 field of view.
        float        fieldOfViewRatio = 1.0f - (targetZoomRatio - 1.0f);
        float        newFieldOfView   = fieldOfViewRatio * defaultFieldOfView;
        ZoomProperty zoomProperty     = new ZoomProperty(newFieldOfView, duration);

        StopCoroutine("SetFieldOfView");
        StartCoroutine("SetFieldOfView", zoomProperty);
    }
Пример #4
0
    /*
     * Sets the camera field of view to a certain value over a provided amount of seconds.
     */
    IEnumerator SetFieldOfView(ZoomProperty zoomProperty)
    {
        float startingFieldOfView = camera.fieldOfView;
        float elapsed             = 0;

        while (elapsed < zoomProperty.duration)
        {
            elapsed += Time.deltaTime;
            float percentageComplete = elapsed / zoomProperty.duration;
            float newFieldOfView     = Mathf.Lerp(startingFieldOfView, zoomProperty.fieldOfView, percentageComplete);
            camera.fieldOfView = newFieldOfView;
            yield return(null);
        }
    }
        private float GetFactor(ZoomProperty property, float factor)
        {
            switch (property)
            {
            case ZoomProperty.In:
                return(factor);

            case ZoomProperty.Out:
                return(1 / factor);

            case ZoomProperty.Stay:
                return(1);
            }

            return(1);
        }
        /// <summary>
        /// Converts given values to expected property
        /// </summary>
        /// <param name="values">
        ///     It should be following values:
        ///     <list type="number">
        ///         <item>property from <c>Zoom</c> model</item>
        ///         <item>Image control</item>
        ///         <item>ZoomProperty describing which property we want to get.</item>
        ///     </list>
        /// </param>
        /// <param name="targetType">Not used</param>
        /// <param name="parameter">Not used</param>
        /// <param name="culture">Not used</param>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length < 3 || !(values[0] is double && values[1] is Image && values[2] is ZoomProperty))
            {
                return(null);
            }
            double       prop         = (double)values[0];
            Image        image        = values[1] as Image;
            ZoomProperty zoomProperty = (ZoomProperty)values[2];

            switch (zoomProperty)
            {
            case ZoomProperty.OffsetX:
                return(GetOffsetX(prop, image));

            case ZoomProperty.OffsetY:
                return(GetOffsetY(prop, image));
            }
            return(null);
        }
Пример #7
0
 set => SetValue(ZoomProperty, value);
Пример #8
0
 static FriendInfoDescriptionViewer()
 {
     ZoomProperty.OverrideMetadata(typeof(FriendInfoDescriptionViewer), new FrameworkPropertyMetadata(_OnZoomChanged));
 }
 private void Zoom(ZoomProperty widthProperty, ZoomProperty heightProperty)
 {
     Zoomed?.Invoke(this, new ZoomButtonsEventArgs(GetFactor(widthProperty, zoomFactorWidth),
                                                   GetFactor(heightProperty, zoomFactorHeight)));
 }
Пример #10
0
 /*
  * Reset the zoom to the starting field of view.
  */
 public void ResetZoom(float duration)
 {
     StopCoroutine ("SetFieldOfView");
     ZoomProperty zoomProperty = new ZoomProperty (defaultFieldOfView, duration);
     StartCoroutine ("SetFieldOfView", zoomProperty);
 }
Пример #11
0
    /*
     * Sets the camera field of view to a certain value over a provided amount of seconds.
     */
    IEnumerator SetFieldOfView(ZoomProperty zoomProperty)
    {
        float startingFieldOfView = camera.fieldOfView;
        float elapsed = 0;

        while (elapsed < zoomProperty.duration) {
            elapsed += Time.deltaTime;
            float percentageComplete = elapsed / zoomProperty.duration;
            float newFieldOfView = Mathf.Lerp (startingFieldOfView, zoomProperty.fieldOfView, percentageComplete);
            camera.fieldOfView = newFieldOfView;
            yield return null;
        }
    }