Exemplo n.º 1
0
        public static AiukFloatTween Tween(object key, float start, float end, float duration,
                                           Action <IAiukTween <float> > progress,
                                           Action <IAiukTween <float> >
                                           completion = null,
                                           AiukEaseType aiukEaseType = AiukEaseType.Linear,
                                           string friendName         = null)
        {
            var t = AiukTweenFactory.GetFloatTween();

            // 给动画对象赋一个友好的命名如果存在
            if (friendName == null)
            {
                var id = TweenIdCounter + 1;
                t.FriendNme = "Tween_" + id;
            }
            else
            {
                t.FriendNme = friendName;
            }
            t.Key = key;
            var scaleFunc = scaleFuncDictionary[aiukEaseType];

            t.Init(start, end, duration, scaleFunc, progress, completion);
            AddTween(t);

            return(t);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 在指定的过渡时间内移动一个游戏对象的Y轴到指定的位置(本地坐标)。
 /// </summary>
 /// <param name="target">目标游戏对象</param>
 /// <param name="end">结束位置</param>
 /// <param name="duration">过渡时间</param>
 /// <param name="friendName">对人友好的动画名</param>
 /// <param name="easeType">动画曲线类型。</param>
 /// <returns></returns>
 public static AiukVector3Tween DoLocalMoveY(this Transform target,
                                             float end,
                                             float duration,
                                             string friendName     = null,
                                             AiukEaseType easeType = AiukEaseType.Linear)
 {
     return(DoLocalMoveY(target.gameObject, end, duration, friendName, easeType));
 }
Exemplo n.º 3
0
        /// <summary>
        /// 在指定的过渡时间内移动一个游戏对象的Y轴到指定的位置(本地坐标)。
        /// </summary>
        /// <param name="target">目标游戏对象</param>
        /// <param name="end">结束位置</param>
        /// <param name="duration">过渡时间</param>
        /// <param name="friendName">对人友好的动画名</param>
        /// <param name="easeType">动画曲线类型。</param>
        public static AiukVector3Tween DoLocalMoveY(this GameObject target,
                                                    float end,
                                                    float duration,
                                                    string friendName     = null,
                                                    AiukEaseType easeType = AiukEaseType.Linear)
        {
            var startV3 = target.transform.localPosition;
            var endV3   = new Vector3(target.transform.localPosition.x, end, target.transform.localPosition.z);

            return(DoLocalMove(target, startV3, endV3, duration, friendName, easeType));
        }
Exemplo n.º 4
0
        ///// <summary>
        ///// 在指定的过渡时间内移动一个游戏对象到指定的Vector3位置
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="start">开始位置</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //private static ColorTween DoColor(this IImage target, Color start, Color end, float duration)
        //{
        //    target.Color = start;
        //    var tween = TweenManager.Tween(null, start, end, duration, t3 =>
        //    {
        //        target.Color = t3.CurrentValue;
        //    }, null);
        //    return tween;
        //}

        ///// <summary>
        ///// 在指定的过渡时间内移动一个文字游戏对象到指定的Vector3位置
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="start">开始位置</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //public static ColorTween DoColorText(this IText target, Color start, Color end, float duration)
        //{
        //    target.Color = start;
        //    var tween = TweenManager.Tween(null, start, end, duration, t3 =>
        //    {
        //        target.Color = t3.CurrentValue;
        //    }, null);
        //    return tween;
        //}

        ///// <summary>
        ///// 在指定的过渡时间内改变一个图片游戏对象的颜色透明只
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //public static ColorTween DoColorA(this IImage target, float end, float duration)
        //{
        //    var startV3 = target.Color;
        //    var endV3 = new Color(target.Color.r, target.Color.b, target.Color.g, end);
        //    return DoColor(target, startV3, endV3, duration);
        //}

        ///// <summary>
        ///// 在指定的过渡时间内改变一个文字游戏对象的颜色透明只
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //public static ColorTween DoColorAText(this IText target, float end, float duration)
        //{
        //    var startV3 = target.Color;
        //    var endV3 = new Color(target.Color.r, target.Color.b, target.Color.g, end);
        //    return DoColorText(target, startV3, endV3, duration);
        //}

        #region 位置动画

        /// <summary>
        /// 在指定的过渡时间内移动一个游戏对象到指定的Vector3位置(本地坐标 )
        /// </summary>
        /// <param name="target">目标游戏对象</param>
        /// <param name="start">开始位置</param>
        /// <param name="end">结束位置</param>
        /// <param name="duration">过渡时间</param>
        /// <param name="friendName">对人友好的动画名</param>
        /// <param name="easeType">动画曲线类型。</param>
        public static AiukVector3Tween DoLocalMove(this GameObject target,
                                                   Vector3 start,
                                                   Vector3 end,
                                                   float duration,
                                                   string friendName     = null,
                                                   AiukEaseType easeType = AiukEaseType.Linear)
        {
            target.transform.localPosition = start;
            var tween = AiukTweenManager.Tween(null, start, end, duration, t3 =>
            {
                target.transform.localPosition = t3.CurrentValue;
            }, null, easeType, friendName);

            return(tween);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 旋转物体的Z轴(左右)。
        /// </summary>
        /// <param name="target"></param>
        /// <param name="offset">旋转偏移值,如果为正则向左旋转,为负则向右旋转。</param>
        /// <param name="duration"></param>
        /// <param name="easeType"></param>
        /// <param name="friendName"></param>
        /// <returns></returns>
        public static AiukFloatTween DoRotateZ(this GameObject target,
                                               float offset,
                                               float duration,
                                               AiukEaseType easeType = AiukEaseType.Linear,
                                               string friendName     = null)
        {
            var startAngle = target.transform.rotation.eulerAngles.z;
            var endAngle   = startAngle + offset;
            var tween      = AiukTweenManager.Tween(null, startAngle, endAngle, duration, t =>
            {
                target.transform.rotation = Quaternion.identity;
                target.transform.Rotate(Camera.main.transform.forward, t.CurrentValue);
            }, null, easeType, friendName);

            return(tween);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 启动一个颜色动画
        /// </summary>
        /// <param name="key"></param>
        /// <param name="start">Created value</param>
        /// <param name="end">End value</param>
        /// <param name="duration">CostTime in seconds</param>
        /// <param name="progress">Progress handler</param>
        /// <param name="completion">Completion handler</param>
        /// <param name="aiukEaseType"></param>
        /// <returns>ColorTween</returns>
        public static AiukColorTween Tween(object key, Color start, Color end, float duration, Action <IAiukTween <Color> > progress, Action <IAiukTween <Color> > completion, AiukEaseType aiukEaseType = AiukEaseType.Linear)
        {
            var t = AiukTweenFactory.GetColorTween();

            t.Key = key;
            var scaleFunc = scaleFuncDictionary[aiukEaseType];

            t.Init(start, end, duration, scaleFunc, progress, completion);
            AddTween(t);

            return(t);
        }
Exemplo n.º 7
0
 public IAiukTween <T> SetEaseType(AiukEaseType esType)
 {
     scaleFunc = AiukTweenManager.scaleFuncDictionary[esType];
     return(this);
 }