コード例 #1
0
ファイル: Loop.cs プロジェクト: wcavell/CoreAnimation
        public static void FrontToBack(ITweener tweener, int times)
        {
            TimesLoopingHelper helper = new TimesLoopingHelper(tweener, times);

            tweener.Ended -= helper.FrontToBack;
            tweener.Ended += helper.FrontToBack;
        }
コード例 #2
0
        private void StartTweeners()
        {
            playingTweeners.Clear();
            playingTweeners.AddRange(tweeners);

            for (int i = playingTweeners.Count - 1; i >= 0; --i)
            {
                ITweener tweener = playingTweeners[i];

                tweener.TimeScale = TimeScale;
                tweener.SetEase(EaseFunction);

                tweener.Start();

                if (!tweener.IsPlaying)
                {
                    playingTweeners.RemoveAt(i);
                }
            }

            if (playingTweeners.Count == 0)
            {
                NewMarkCompleted();
            }
        }
コード例 #3
0
ファイル: Loop.cs プロジェクト: wcavell/CoreAnimation
        public static void BackAndForth(ITweener tweener, int times)
        {
            TimesLoopingHelper helper = new TimesLoopingHelper(tweener, times);

            tweener.Ended -= helper.BackAndForth;
            tweener.Ended += helper.BackAndForth;
        }
コード例 #4
0
 public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration,
                                    Easing.Equation easing,
                                    int delay = 0, ITweener tweener = null)
 {
     CoroutineManager.StartCoroutine(
         TweenColorAlphaRoutine(hasColor, from, to, duration, easing, delay, tweener), null);
 }
コード例 #5
0
ファイル: TestTween.cs プロジェクト: Bagoum/suzunoya
        private static Task <Completion> TestSteps <T>(ITweener t, Coroutines?cors, Func <T> value, T[] expected, Action <T, T> assertEq, bool lastIsComplete = true)
        {
            cors ??= new Coroutines();
            var tw = t.Run(cors);

            for (int ii = 0; ii < expected.Length; ++ii)
            {
                cors.Step();
                if (lastIsComplete && ii == expected.Length - 1)
                {
                    Assert.IsTrue(tw.IsCompleted);
                }
                else
                {
                    Assert.IsFalse(tw.IsCompleted);
                }
                try {
                    assertEq(value(), expected[ii]);
                } catch (Exception e) {
                    Console.WriteLine($"Failed steps comparison at index {ii}");
                    throw;
                }
            }
            return(tw);
        }
コード例 #6
0
        protected override void OnTweenReset(bool kill, ResetMode resetMode)
        {
            for (int i = tweeners.Count - 1; i >= 0; --i)
            {
                ITweener tweener = tweeners[i];

                tweener.Reset(resetMode);
            }
        }
コード例 #7
0
 private void OnAnimationCompleted(ITweener tweener)
 {
     if (tweener.IsCompleted)
     {
         CAAnimation am = (CAAnimation)tweener;
         AnimationDidStop?.Invoke(am, true);
         OnCompleted(am, true);
         Animations.Remove(am.ForKey);
     }
 }
コード例 #8
0
        static IEnumerator TweenColorAlphaRoutine(IHasColor hasColor, float from, float to, int duration,
                                                  Easing.Equation easing,
                                                  int delay = 0, ITweener tweener = null)
        {
            if (delay > 0)
            {
                yield return(new WaitForMilliSeconds(delay));
            }

            float durationF = duration * 0.001f;
            float time      = 0;

            hasColor.Alpha = from;
            var childs = hasColor.children;

            for (int i = 0; i < childs.Count; i++)
            {
                if (childs[i] is IHasColor)
                {
                    ((IHasColor)childs[i]).Alpha = from;
                }
            }

            while (time < durationF)
            {
                hasColor.Alpha = Easing.Ease(easing, time, from, to, durationF);

                for (int i = 0; i < childs.Count; i++)
                {
                    if (childs[i] is IHasColor)
                    {
                        ((IHasColor)childs[i]).Alpha = Easing.Ease(easing, time, from, to, durationF);
                    }
                }

                time += Time.deltaTime * 0.001f;

                yield return(null);
            }

            hasColor.Alpha = to;
            for (int i = 0; i < childs.Count; i++)
            {
                if (childs[i] is IHasColor)
                {
                    ((IHasColor)childs[i]).Alpha = to;
                }
            }

            if (tweener != null)
            {
                tweener.OnTweenEnd(hasColor);
            }
        }
コード例 #9
0
ファイル: Tween.cs プロジェクト: jorik041/CoolestTween2
 public void Init(TweenTime timeProvider, TweenBuilder builder)
 {
     this.timeProvider = timeProvider;
     this.tweener      = builder.Tweener;
     this.easeType     = builder.EaseType;
     this.tweenType    = builder.TweenType;
     this.easeFunction = builder.EaseFunction;
     this.duration     = builder.Duration;
     this.delayTime    = builder.Delay;
     this.handler      = builder.Handler;
     this.startTime    = 0;
     this.realTime     = 0;
     this.pauseTime    = 0;
 }
コード例 #10
0
        static IEnumerator TweenSpriteAlphaRoutine(Sprite s, float from, float to, int duration, Easing.Equation easing,
                                                   int delay = 0, ITweener tweener = null)
        {
            if (delay > 0)
            {
                yield return(new WaitForMilliSeconds(delay));
            }

            float durationF = duration * 0.001f;
            float time      = 0;

            s.alpha = from;
            var childs = s.GetChildren();

            for (int i = 0; i < childs.Count; i++)
            {
                if (childs[i] is Sprite)
                {
                    ((Sprite)childs[i]).alpha = from;
                }
            }

            while (time < durationF)
            {
                s.alpha = Easing.Ease(easing, time, from, to, durationF);
                //Console.WriteLine($"{s.name} - alpha: {s.alpha}");

                for (int i = 0; i < childs.Count; i++)
                {
                    if (childs[i] is Sprite)
                    {
                        ((Sprite)childs[i]).alpha = Easing.Ease(easing, time, from, to, durationF);
                    }
                }

                time += Time.deltaTime * 0.001f;

                yield return(null);
            }

            if (tweener != null)
            {
                tweener.OnTweenEnd(s);
            }
        }
コード例 #11
0
        protected override void OnTweenUpdate()
        {
            for (int i = playingTweeners.Count - 1; i >= 0; --i)
            {
                ITweener tweener = playingTweeners[i];

                tweener.Update();

                if (!tweener.IsPlaying)
                {
                    playingTweeners.RemoveAt(i);
                }
            }

            if (playingTweeners.Count == 0)
            {
                NewMarkCompleted();
            }
        }
コード例 #12
0
    void BounceDone(ITweener tw)
    {
        tw.SetOnFinishedDelegate(null);
        if (IsActive)
        {
            IsActive = loopBounce && gameObject.activeSelf && gameObject.activeInHierarchy;
            if (IsActive)
            {
                tw.SetBeginStateImmediately();
                float newMiddleDelay = middleDelay + (randomMiddleDelay ? (middleDelay * Random.Range(-randomMiddleDelayPercent, randomMiddleDelayPercent) / 100f) : 0f);

                if (bounceSessionTime > 0 && sessionTime > bounceSessionTime)
                {
                    sessionTime     = -bounceSessionDelay;
                    newMiddleDelay += bounceSessionDelay;
                }

                tw.SetEndState(newMiddleDelay, BounceDone);
            }
        }
    }
コード例 #13
0
        public void Add(ITweener tweener)
        {
            if (tweener == null)
            {
                throw new ArgumentNullException($"Tried to {nameof(Add)} a null {nameof(ITweener)} on {nameof(InterpolationTween)}");
            }

            if (tweener.IsPlaying)
            {
                throw new ArgumentNullException($"Tried to {nameof(Add)} a {nameof(ITweener)} on {nameof(InterpolationTween)} " +
                                                $"but it was already playing");
            }

            if (tweeners.Contains(tweener))
            {
                throw new ArgumentNullException($"Tried to {nameof(Add)} a {nameof(ITweener)} on {nameof(InterpolationTween)} " +
                                                $"but it was already added");
            }

            tweeners.Add(tweener);

            durationCalculated = false;
        }
コード例 #14
0
ファイル: Loop.cs プロジェクト: szyszart/Junkyard
 public static void BackAndForth(ITweener tweener)
 {
     tweener.Ended += tweener.Reverse;
 }
コード例 #15
0
 public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration, ITweener tweener)
 {
     TweenColorAlpha(hasColor, from, to, duration, Easing.Equation.Linear, 0, tweener);
 }
コード例 #16
0
 public void SetUp()
 {
     tweener = new ColorTweener(Linear.EaseNone);
 }
コード例 #17
0
 internal void RemoveTweener(ITweener tweener)
 {
     RemoveTweener(tweenerUpdate.IndexOf(tweener));
 }
コード例 #18
0
 internal LoopHelper(ITweener tweener)
 {
     this.tweener = tweener;
 }
コード例 #19
0
ファイル: Loop.cs プロジェクト: wcavell/CoreAnimation
 public static void BackAndForth(ITweener tweener)
 {
     tweener.Ended -= tweener.Reverse;
     tweener.Ended += tweener.Reverse;
 }
コード例 #20
0
 /// <summary>
 /// MonoBehaviour Awake callback.
 /// </summary>
 protected virtual void Awake()
 {
     tweener = AnimationManager.Instance.Configuration.Tweener;
 }
コード例 #21
0
 public static void TweenSpriteAlpha(Sprite s, float from, float to, int duration, ITweener tweener)
 {
     TweenSpriteAlpha(s, from, to, duration, Easing.Equation.Linear, 0, tweener);
 }
コード例 #22
0
ファイル: Loop.cs プロジェクト: liquidboy/X
 public static void FrontToBack(ITweener tweener, int times)
 {
     TimesLoopingHelper helper = new TimesLoopingHelper(tweener, times);
     tweener.Ended += helper.FrontToBack;
 }
コード例 #23
0
 public static void TweenSpriteAlpha(Sprite s, float from, float to, int duration, Easing.Equation easing,
                                     int delay = 0, ITweener tweener = null)
 {
     CoroutineManager.StartCoroutine(TweenSpriteAlphaRoutine(s, from, to, duration, easing, delay, tweener), null);
 }
コード例 #24
0
ファイル: Loop.cs プロジェクト: liquidboy/X
 public static void BackAndForth(ITweener tweener, int times)
 {
     TimesLoopingHelper helper = new TimesLoopingHelper(tweener, times);
     tweener.Ended += helper.BackAndForth;
 }
コード例 #25
0
 public StartableTweener(ITweener implementation, MonoBehaviour gameObject)
 {
     Implementation = implementation;
     GameObject     = gameObject;
 }
コード例 #26
0
ファイル: ITweener.cs プロジェクト: mengtest/laughing-memory
    void Update()
    {
        float delta = ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
        float time  = ignoreTimeScale ? Time.unscaledDeltaTime : Time.time;

        if (!mStarted)
        {
            delta      = 0;
            mStarted   = true;
            mStartTime = time + delay;
        }

        if (time < mStartTime)
        {
            return;
        }

        mFactor += (duration == 0f) ? 1f : amountPerDelta * delta;

        if (style == Style.Loop)
        {
            if (mFactor > 1f)
            {
                mFactor -= Mathf.Floor(mFactor);
            }
        }
        else if (style == Style.PingPong)
        {
            if (mFactor > 1f)
            {
                mFactor         = 1f - (mFactor - Mathf.Floor(mFactor));
                mAmountPerDelta = -mAmountPerDelta;
            }
            else if (mFactor < 0f)
            {
                mFactor         = -mFactor;
                mFactor        -= Mathf.Floor(mFactor);
                mAmountPerDelta = -mAmountPerDelta;
            }
        }

        if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
        {
            mFactor = Mathf.Clamp01(mFactor);
            Sample(mFactor, true);
            enabled = false;

            if (current != this)
            {
                ITweener before = current;
                current = this;

                if (onFinished != null)
                {
                    for (int i = 0; i < onFinished.Count; ++i)
                    {
                        FinishedEvent ed = onFinished[i];
                        if (ed != null)
                        {
                            ed();
                        }
                    }
                }
                current = before;
            }
        }
        else
        {
            Sample(mFactor, false);
        }
    }
コード例 #27
0
 public TweenBuilder WithTweener(ITweener accessor)
 {
     this.tweener = accessor;
     return(this);
 }
コード例 #28
0
 internal void AddTweener(ITweener tweener)
 {
     tweenerUpdate.Add(tweener);
 }
コード例 #29
0
ファイル: Loop.cs プロジェクト: liquidboy/X
 public static void FrontToBack(ITweener tweener)
 {
     tweener.Ended += tweener.Restart;
 }
コード例 #30
0
 public static void FrontToBack(ITweener tweener)
 {
     tweener.Ended += tweener.Restart;
 }
コード例 #31
0
ファイル: Loop.cs プロジェクト: liquidboy/X
 public static void BackAndForth(ITweener tweener)
 {
     tweener.Ended += delegate { tweener.Reverse(); };
 }
コード例 #32
0
 public static void BackAndForth(ITweener tweener)
 {
     tweener.Ended += delegate { tweener.Reverse(); };
 }
コード例 #33
0
ファイル: Loop.cs プロジェクト: liquidboy/X
 public TimesLoopingHelper(ITweener tweener, int times)
 {
     this.tweener = tweener;
     this.times = times;
 }
コード例 #34
0
 public TimesLoopingHelper(ITweener tweener, int times)
 {
     this.tweener = tweener;
     this.times   = times;
 }