private void StopAll(AyAnimateTreeBase animate) { if (animate.NextAnimateTreeItem != null) { if (animate.NextAnimateTreeItem is IAyAnimateLifecycle ani) { ani.Stop(); } StopAll(animate.NextAnimateTreeItem); } }
private void DestroyAll(AyAnimateTreeBase animate) { if (animate.NextAnimateTreeItem != null) { if (animate.NextAnimateTreeItem is IAyAnimateLifecycle ani) { ani.Destroy(); } DestroyAll(animate.NextAnimateTreeItem); } }
private void InitializeAll(AyAnimateTreeBase animate) { if (animate.NextAnimateTreeItem != null) { if (animate.NextAnimateTreeItem is IAyAnimateLifecycle ani) { ani.Initialize(); } InitializeAll(animate.NextAnimateTreeItem); } }
private void SkipToFillAll(AyAnimateTreeBase animate) { if (animate.NextAnimateTreeItem != null) { if (animate.NextAnimateTreeItem is IAyAnimateLifecycle ani) { ani.SkipToFill(); } SkipToFillAll(animate.NextAnimateTreeItem); } }
/// <summary> /// 延迟多少毫秒后执行一组同时执行的Ay动画 /// </summary> /// <param name="millSeconds">毫秒</param> /// <param name="ayAnimate">一组Ay动画</param> /// <returns></returns> public IAyAnimateTreePad DelayAddSameBegin(int millSeconds, params AyAnimateBase[] ayAnimate) { ///寻找时长最长的动画 double time1 = 0; AyAnimateBase maxTimeAyAnimate = null; foreach (var item in ayAnimate) { if (item.AnimateSpeed > time1) { maxTimeAyAnimate = item; time1 = item.AnimateSpeed; } } if (RootAnimateTree == null) { RootAnimateTree = new AyAnimateDelayTreeItem { DelayMillseconds = millSeconds, AyAnimateBases = ayAnimate, LastAyAnimateBase = maxTimeAyAnimate, IsFirst = true, IsEnd = true, Time = time1 }; AllPlayTime += RootAnimateTree.Time; } else { var _AnimateTree = new AyAnimateDelayTreeItem { DelayMillseconds = millSeconds, AyAnimateBases = ayAnimate, LastAyAnimateBase = maxTimeAyAnimate, Time = time1 }; AllPlayTime += _AnimateTree.Time; AllPlayTime += _AnimateTree.DelayMillseconds; if (RootAnimateTree.NextAnimateTreeItem == null) { RootAnimateTree.NextAnimateTreeItem = _AnimateTree; _AnimateTree.LastAnimateTreeItem = RootAnimateTree; RootAnimateTree.LastAyAnimateBase.NextAyAnimateTreeItem = () => { _AnimateTree.Begin(); CurrentAyAnimate = _AnimateTree; }; CurrentLinkAnimateTreeItem = _AnimateTree; } else { CurrentLinkAnimateTreeItem.NextAnimateTreeItem = _AnimateTree; _AnimateTree.LastAnimateTreeItem = CurrentLinkAnimateTreeItem; CurrentLinkAnimateTreeItem.LastAyAnimateBase.NextAyAnimateTreeItem = () => { _AnimateTree.Begin(); CurrentAyAnimate = _AnimateTree; }; CurrentLinkAnimateTreeItem = _AnimateTree; } } return(this); }
/// <summary> /// 开始动画 /// </summary> public void Begin() { if (RootAnimateTree == null) { return; } if (RootAnimateTree != null) { if (RootAnimateTree is IAyAnimateLifecycle animate) { animate.Begin(); CurrentAyAnimate = RootAnimateTree; } } }
/// <summary> /// 延迟多少毫秒后执行 一个动画 /// </summary> /// <param name="millSeconds">毫秒</param> /// <param name="ayAnimate">Ay动画</param> /// <returns></returns> public IAyAnimateTreePad DelayAdd(int millSeconds, AyAnimateBase ayAnimate) { if (RootAnimateTree == null) { RootAnimateTree = new AyAnimateDelayTreeItem { DelayMillseconds = millSeconds, AyAnimateBases = new AyAnimateBase[] { ayAnimate }, LastAyAnimateBase = ayAnimate, IsFirst = true, IsEnd = true, Time = ayAnimate.AnimateSpeed }; AllPlayTime += RootAnimateTree.Time; } else { var _AnimateTree = new AyAnimateDelayTreeItem { DelayMillseconds = millSeconds, AyAnimateBases = new AyAnimateBase[] { ayAnimate }, LastAyAnimateBase = ayAnimate, Time = ayAnimate.AnimateSpeed }; AllPlayTime += _AnimateTree.Time; AllPlayTime += _AnimateTree.DelayMillseconds; if (RootAnimateTree.NextAnimateTreeItem == null) { RootAnimateTree.NextAnimateTreeItem = _AnimateTree; _AnimateTree.LastAnimateTreeItem = RootAnimateTree; RootAnimateTree.LastAyAnimateBase.NextAyAnimateTreeItem = () => { _AnimateTree.Begin(); CurrentAyAnimate = _AnimateTree; }; CurrentLinkAnimateTreeItem = _AnimateTree; } else { CurrentLinkAnimateTreeItem.NextAnimateTreeItem = _AnimateTree; _AnimateTree.LastAnimateTreeItem = CurrentLinkAnimateTreeItem; CurrentLinkAnimateTreeItem.LastAyAnimateBase.NextAyAnimateTreeItem = () => { _AnimateTree.Begin(); CurrentAyAnimate = _AnimateTree; }; CurrentLinkAnimateTreeItem = _AnimateTree; } } return(this); }