Exemplo n.º 1
0
    //
    // NOTES: Based on Robert Penner's open source easing equations (http://www.robertpenner.com/easing_terms_of_use.html).
    //
    // EASING EQUATIONS TERMS OF USE
    //
    // Open source under the BSD License.
    //
    // Copyright © 2001 Robert Penner
    // All rights reserved.
    //
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    //
    // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    // Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    /// <summary>
    /// Returns an <see cref="EasignFunction"/> delegate that implements the 
    /// easing equation defined by the <paramref name="easeType"/> argument.
    /// </summary>
    /// <param name="easeType">The easing equation to be used</param>
    public static EasingFunction GetFunction( dfEasingType easeType )
    {
        switch( easeType )
        {
            case dfEasingType.BackEaseIn: return easeInBack;
            case dfEasingType.BackEaseInOut: return easeInOutBack;
            case dfEasingType.BackEaseOut: return easeOutBack;
            case dfEasingType.Bounce: return bounce;
            case dfEasingType.CircEaseIn: return easeInCirc;
            case dfEasingType.CircEaseInOut: return easeInOutCirc;
            case dfEasingType.CircEaseOut: return easeOutCirc;
            case dfEasingType.CubicEaseIn: return easeInCubic;
            case dfEasingType.CubicEaseInOut: return easeInOutCubic;
            case dfEasingType.CubicEaseOut: return easeOutCubic;
            case dfEasingType.ExpoEaseIn: return easeInExpo;
            case dfEasingType.ExpoEaseInOut: return easeInOutExpo;
            case dfEasingType.ExpoEaseOut: return easeOutExpo;
            case dfEasingType.Linear: return linear;
            case dfEasingType.QuadEaseIn: return easeInQuad;
            case dfEasingType.QuadEaseInOut: return easeInOutQuad;
            case dfEasingType.QuadEaseOut: return easeOutQuad;
            case dfEasingType.QuartEaseIn: return easeInQuart;
            case dfEasingType.QuartEaseInOut: return easeInOutQuart;
            case dfEasingType.QuartEaseOut: return easeOutQuart;
            case dfEasingType.QuintEaseIn: return easeInQuint;
            case dfEasingType.QuintEaseInOut: return easeInOutQuint;
            case dfEasingType.QuintEaseOut: return easeOutQuint;
            case dfEasingType.SineEaseIn: return easeInSine;
            case dfEasingType.SineEaseInOut: return easeInOutSine;
            case dfEasingType.SineEaseOut: return easeOutSine;
            case dfEasingType.Spring: return spring;
        }

        throw new NotImplementedException();
    }
Exemplo n.º 2
0
    public static dfEasingFunctions.EasingFunction GetFunction(dfEasingType easeType)
    {
        switch (easeType)
        {
        case dfEasingType.Linear:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.linear));
        }

        case dfEasingType.Bounce:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.bounce));
        }

        case dfEasingType.BackEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInBack));
        }

        case dfEasingType.BackEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutBack));
        }

        case dfEasingType.BackEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutBack));
        }

        case dfEasingType.CircEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInCirc));
        }

        case dfEasingType.CircEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutCirc));
        }

        case dfEasingType.CircEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutCirc));
        }

        case dfEasingType.CubicEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInCubic));
        }

        case dfEasingType.CubicEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutCubic));
        }

        case dfEasingType.CubicEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutCubic));
        }

        case dfEasingType.ExpoEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInExpo));
        }

        case dfEasingType.ExpoEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutExpo));
        }

        case dfEasingType.ExpoEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutExpo));
        }

        case dfEasingType.QuadEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInQuad));
        }

        case dfEasingType.QuadEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutQuad));
        }

        case dfEasingType.QuadEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutQuad));
        }

        case dfEasingType.QuartEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInQuart));
        }

        case dfEasingType.QuartEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutQuart));
        }

        case dfEasingType.QuartEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutQuart));
        }

        case dfEasingType.QuintEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInQuint));
        }

        case dfEasingType.QuintEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutQuint));
        }

        case dfEasingType.QuintEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutQuint));
        }

        case dfEasingType.SineEaseIn:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInSine));
        }

        case dfEasingType.SineEaseOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutSine));
        }

        case dfEasingType.SineEaseInOut:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutSine));
        }

        case dfEasingType.Spring:
        {
            return(new dfEasingFunctions.EasingFunction(dfEasingFunctions.spring));
        }
        }
        throw new NotImplementedException();
    }
    //
    // NOTES: Based on Robert Penner's open source easing equations (http://www.robertpenner.com/easing_terms_of_use.html).
    //
    // EASING EQUATIONS TERMS OF USE
    //
    // Open source under the BSD License.
    //
    // Copyright © 2001 Robert Penner
    // All rights reserved.
    //
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    //
    // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    // Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //

    /// <summary>
    /// Returns an <see cref="EasignFunction"/> delegate that implements the
    /// easing equation defined by the <paramref name="easeType"/> argument.
    /// </summary>
    /// <param name="easeType">The easing equation to be used</param>
    public static EasingFunction GetFunction(dfEasingType easeType)
    {
        switch (easeType)
        {
        case dfEasingType.BackEaseIn: return(easeInBack);

        case dfEasingType.BackEaseInOut: return(easeInOutBack);

        case dfEasingType.BackEaseOut: return(easeOutBack);

        case dfEasingType.Bounce: return(bounce);

        case dfEasingType.CircEaseIn: return(easeInCirc);

        case dfEasingType.CircEaseInOut: return(easeInOutCirc);

        case dfEasingType.CircEaseOut: return(easeOutCirc);

        case dfEasingType.CubicEaseIn: return(easeInCubic);

        case dfEasingType.CubicEaseInOut: return(easeInOutCubic);

        case dfEasingType.CubicEaseOut: return(easeOutCubic);

        case dfEasingType.ExpoEaseIn: return(easeInExpo);

        case dfEasingType.ExpoEaseInOut: return(easeInOutExpo);

        case dfEasingType.ExpoEaseOut: return(easeOutExpo);

        case dfEasingType.Linear: return(linear);

        case dfEasingType.QuadEaseIn: return(easeInQuad);

        case dfEasingType.QuadEaseInOut: return(easeInOutQuad);

        case dfEasingType.QuadEaseOut: return(easeOutQuad);

        case dfEasingType.QuartEaseIn: return(easeInQuart);

        case dfEasingType.QuartEaseInOut: return(easeInOutQuart);

        case dfEasingType.QuartEaseOut: return(easeOutQuart);

        case dfEasingType.QuintEaseIn: return(easeInQuint);

        case dfEasingType.QuintEaseInOut: return(easeInOutQuint);

        case dfEasingType.QuintEaseOut: return(easeOutQuint);

        case dfEasingType.SineEaseIn: return(easeInSine);

        case dfEasingType.SineEaseInOut: return(easeInOutSine);

        case dfEasingType.SineEaseOut: return(easeOutSine);

        case dfEasingType.Spring: return(spring);
        }

        throw new NotImplementedException();
    }
Exemplo n.º 4
0
    /// <summary>
    /// Creates a new Tween and returns a reference to the Tween component. The Tween will not auto-play, and
    /// must be started manually (this allows additional configuration before starting the Tween).
    /// </summary>
    /// <param name="target">The component whose property will be animated</param>
    /// <param name="propertyName">The name of the property to be animated</param>
    /// <param name="startValue">The start value</param>
    /// <param name="endValue">The end value</param>
    /// <param name="length">The length of the animation</param>
    /// <param name="func">The easing function that will be used to modify the animation</param>
    public static dfTweenComponent <T> Create(Component target, string propertyName, T startValue, T endValue, float length, dfEasingType func)
    {
        if (target == null || target.gameObject == null)
        {
            throw new ArgumentNullException("target");
        }

        if (string.IsNullOrEmpty(propertyName))
        {
            throw new ArgumentNullException("propertyName");
        }

        var tween = (dfTweenComponent <T>)target.gameObject.AddComponent(typeof(T));

        tween.autoRun = false;
        tween.target  = new dfComponentMemberInfo()
        {
            Component = target, MemberName = propertyName
        };
        tween.startValue = startValue;
        tween.endValue   = endValue;
        tween.length     = length;
        tween.easingType = func;

        return(tween);
    }
Exemplo n.º 5
0
 public static dfEasingFunctions.EasingFunction GetFunction(dfEasingType easeType)
 {
     switch (easeType)
     {
         case dfEasingType.Linear:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.linear);
         }
         case dfEasingType.Bounce:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.bounce);
         }
         case dfEasingType.BackEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInBack);
         }
         case dfEasingType.BackEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutBack);
         }
         case dfEasingType.BackEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutBack);
         }
         case dfEasingType.CircEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInCirc);
         }
         case dfEasingType.CircEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutCirc);
         }
         case dfEasingType.CircEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutCirc);
         }
         case dfEasingType.CubicEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInCubic);
         }
         case dfEasingType.CubicEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutCubic);
         }
         case dfEasingType.CubicEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutCubic);
         }
         case dfEasingType.ExpoEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInExpo);
         }
         case dfEasingType.ExpoEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutExpo);
         }
         case dfEasingType.ExpoEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutExpo);
         }
         case dfEasingType.QuadEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInQuad);
         }
         case dfEasingType.QuadEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutQuad);
         }
         case dfEasingType.QuadEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutQuad);
         }
         case dfEasingType.QuartEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInQuart);
         }
         case dfEasingType.QuartEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutQuart);
         }
         case dfEasingType.QuartEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutQuart);
         }
         case dfEasingType.QuintEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInQuint);
         }
         case dfEasingType.QuintEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutQuint);
         }
         case dfEasingType.QuintEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutQuint);
         }
         case dfEasingType.SineEaseIn:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInSine);
         }
         case dfEasingType.SineEaseOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeOutSine);
         }
         case dfEasingType.SineEaseInOut:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.easeInOutSine);
         }
         case dfEasingType.Spring:
         {
             return new dfEasingFunctions.EasingFunction(dfEasingFunctions.spring);
         }
     }
     throw new NotImplementedException();
 }