public static DirectionTask MoveX(this Transform from, float pos, float speed = 5, bool isLocal = true, bool isPlus = true)
        {
            var task = new DirectionTask(from, MoveDirection.x, pos, speed, isPlus, isLocal);

            AnilUpdate.Register(task);
            return(task);
        }
        public static UpdateTaskGeneric <T> UpdateWhile <T>(this T sender, Action <T> action, Func <T, bool> endCondition, Action then = null, UpdateType updateType = UpdateType.normal)
        {
            var task = new UpdateTaskGeneric <T>(action, endCondition, sender, then);

            AnilUpdate.Register(task, updateType);
            return(task);
        }
        public static MoveTask RotateTransform(this Transform from, Vector3 to, float rotationSpeed = MoveTask.DefaultRotationSpeed, bool IsPlus = false)
        {
            var task = new MoveTask(to, from, rotateSpeed: rotationSpeed, isPlus: IsPlus);

            AnilUpdate.Register(task);
            return(task);
        }
        public static UpdateTask UpdateWhile(this UnityEngine.Object sender, Action action, Func <bool> endCondition, Action then = null, UpdateType updateType = UpdateType.normal)
        {
            var task = new UpdateTask(action, endCondition, then, sender ? sender.GetInstanceID() : 0);

            AnilUpdate.Register(task, updateType);
            return(task);
        }
示例#5
0
        // Animator
        public static UpdateTask LerpAnim(this Animator animator, int hashset, float value, float speed, Action then = null, float stopValue = 0.1f)
        {
            var task = new UpdateTask(() => animator.SetFloatLerp(hashset, value, speed), () => animator.Difrance(hashset, value) > stopValue, then, animator.GetInstanceID());

            AnilUpdate.Register(task);
            return(task);
        }
示例#6
0
        public static MoveTask Translate(this Transform from, Vector3 pos, Vector3 rot, float speed = MoveTask.DefaultSpeed, MoveType moveType = MoveType.towards,
                                         float rotationSpeed = MoveTask.DefaultRotationSpeed, bool IsPlus = false, Action endAction = null)
        {
            var task = new MoveTask(from, pos, rot, speed, rotationSpeed, moveType, IsPlus, false, endAction);

            AnilUpdate.Register(task);
            return(task);
        }
示例#7
0
        public static MoveTask MoveLocal(this Transform from, Vector3 to, float speed = MoveTask.DefaultSpeed, Action endAction = null,
                                         bool IsPlus = false, MoveType moveType = MoveType.towards)
        {
            var task = new MoveTask(from, to, speed, moveType, IsPlus, true, endAction);

            AnilUpdate.Register(task);
            return(task);
        }
        /// <summary>
        /// wait while condition false then action
        /// </summary>
        public static WaitUntilTask WaitUntil(Func <bool> endCondition, Action then, UnityEngine.Object calledInstance = null)
        {
#if UNITY_EDITOR
            int id   = calledInstance ? calledInstance.GetInstanceID() : 0;
            var task = new WaitUntilTask(endCondition, then, id);
#else
            var task = new WaitUntilTask(endCondition, then);
#endif
            AnilUpdate.Register(task, UpdateType.normal);
            return(task);
        }
        /// <summary>
        /// this allows you update action, <b>you can recive input</b>
        /// </summary>
        /// <param name="action"><param>will be updated action</param>
        /// <param name="endCnd"><param>do while this condition true</param>
        /// <param name="then">then do</param>
        public static UpdateTask UpdateWhile(Action action, Func <bool> endCnd, Action then = null, UnityEngine.Object calledInstance = null, UpdateType updateType = UpdateType.normal)
        {
#if UNITY_EDITOR
            int id   = calledInstance ? calledInstance.GetInstanceID() : 0;
            var task = new UpdateTask(action, endCnd, then, id);
#else
            var task = new UpdateTask(action, endCondition, then);
#endif
            AnilUpdate.Register(task, updateType);
            return(task);
        }
        public static MoveTask RotateTransform(this Transform from, Vector3[] to, float rotationSpeed = MoveTask.DefaultRotationSpeed, bool IsPlus = false)
        {
            var task = new MoveTask(to[0], from, rotateSpeed: rotationSpeed, isPlus: IsPlus);

            for (int i = 1; i < to.Length; i++)
            {
                task.JoinRotation(to[i]);
            }

            AnilUpdate.Register(task);
            return(task);
        }
示例#11
0
        public static MoveTask MoveArray(this Transform from, Transform[] to, float speed = MoveTask.DefaultSpeed, Action endAction = null, float rotationSpeed = MoveTask.DefaultRotationSpeed,
                                         MoveType moveType = MoveType.towards, bool reverse = false, bool IsPlus = false, bool isloacal = false)
        {
            var transforms = to.ToList();

            if (reverse)
            {
                transforms.Reverse();
            }

            var task = new MoveTask(from, transforms[0], speed, rotationSpeed, moveType, IsPlus, isloacal, endAction);

            for (int i = 1; i < to.Length; i++)
            {
                task.Join(transforms[i]);
            }

            AnilUpdate.Register(task);
            return(task);
        }