From e103c87d10df4b2bad7c9f93217a80abb791618c Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 12 Jul 2023 13:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84`Animation`=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=EF=BC=8C=E5=A2=9E=E5=8A=A0`Addition`?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A8=E7=94=BB=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Component/Animation/AnimationInfo.cs | 20 +++++++------- .../Animation/AnimationInfoContext.cs | 4 +-- Runtime/Component/Animation/AnimationStyle.cs | 27 ++++++++++++------- .../Animation/AnimationStyleHelper.cs | 2 +- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Runtime/Component/Animation/AnimationInfo.cs b/Runtime/Component/Animation/AnimationInfo.cs index 62a2e6b7..6901bc10 100644 --- a/Runtime/Component/Animation/AnimationInfo.cs +++ b/Runtime/Component/Animation/AnimationInfo.cs @@ -73,7 +73,7 @@ namespace XCharts.Runtime context.pause = false; context.end = false; context.startTime = 0; - context.itemCurrProgress.Clear(); + context.dataCurrProgress.Clear(); } /// @@ -101,8 +101,8 @@ namespace XCharts.Runtime context.destProgress = 1; context.totalProgress = 0; context.sizeProgress = 0; - context.itemCurrProgress.Clear(); - context.itemDestProgress.Clear(); + context.dataCurrProgress.Clear(); + context.dataDestProgress.Clear(); } if (OnAnimationStart != null) { @@ -242,7 +242,7 @@ namespace XCharts.Runtime internal void SetDataCurrProgress(int index, float state) { - context.itemCurrProgress[index] = state; + context.dataCurrProgress[index] = state; } @@ -253,23 +253,23 @@ namespace XCharts.Runtime isBarEnd = false; return initValue; } - var c1 = !context.itemCurrProgress.ContainsKey(index); - var c2 = !context.itemDestProgress.ContainsKey(index); + var c1 = !context.dataCurrProgress.ContainsKey(index); + var c2 = !context.dataDestProgress.ContainsKey(index); if (c1 || c2) { if (c1) - context.itemCurrProgress.Add(index, initValue); + context.dataCurrProgress.Add(index, initValue); if (c2) - context.itemDestProgress.Add(index, destValue); + context.dataDestProgress.Add(index, destValue); isBarEnd = false; } else { - isBarEnd = context.itemCurrProgress[index] == context.itemDestProgress[index]; + isBarEnd = context.dataCurrProgress[index] == context.dataDestProgress[index]; } - return context.itemCurrProgress[index]; + return context.dataCurrProgress[index]; } internal void CheckProgress(double total, bool m_UnscaledTime) diff --git a/Runtime/Component/Animation/AnimationInfoContext.cs b/Runtime/Component/Animation/AnimationInfoContext.cs index 5991c337..34032d5c 100644 --- a/Runtime/Component/Animation/AnimationInfoContext.cs +++ b/Runtime/Component/Animation/AnimationInfoContext.cs @@ -17,7 +17,7 @@ namespace XCharts.Runtime public float sizeProgress; public int currPointIndex; public int destPointIndex; - public Dictionary itemCurrProgress = new Dictionary(); - public Dictionary itemDestProgress = new Dictionary(); + public Dictionary dataCurrProgress = new Dictionary(); + public Dictionary dataDestProgress = new Dictionary(); } } \ No newline at end of file diff --git a/Runtime/Component/Animation/AnimationStyle.cs b/Runtime/Component/Animation/AnimationStyle.cs index 6704cf19..b5351dc9 100644 --- a/Runtime/Component/Animation/AnimationStyle.cs +++ b/Runtime/Component/Animation/AnimationStyle.cs @@ -45,7 +45,8 @@ namespace XCharts.Runtime /// /// the animation of serie. support animation type: fadeIn, fadeOut, change, addition. - /// |动画系统。支持配置四种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画)。 + /// |动画组件,用于控制图表的动画播放。支持配置四种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画)。 + /// 按作用的对象可以分为两类:SerieAnimation(系列动画)和DataAnimation(数据动画)。 /// [System.Serializable] public class AnimationStyle : ChildComponent @@ -241,7 +242,7 @@ namespace XCharts.Runtime var anim = activedAnimation; if (anim == null) return; var isAddedAnim = anim is AnimationAddition; - if (IsIndexAnimation()) + if (IsSerieAnimation()) { if (isAddedAnim) { @@ -331,13 +332,13 @@ namespace XCharts.Runtime return true; } } - if (IsIndexAnimation()) + if (IsSerieAnimation()) { if (m_FadeOut.context.start) return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress; else if (m_Addition.context.start) return m_Addition.context.currProgress >= m_Addition.context.destProgress; else return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress; } - else if (IsItemAnimation()) + else if (IsDataAnimation()) { return false; } @@ -352,12 +353,20 @@ namespace XCharts.Runtime return false; } - public bool IsItemAnimation() + /// + /// whther animaiton is data animation. BottomToTop and InsideOut are data animation. + /// |是否为数据动画。BottomToTop和InsideOut类型的为数据动画。 + /// + public bool IsDataAnimation() { return context.type == AnimationType.BottomToTop || context.type == AnimationType.InsideOut; } - public bool IsIndexAnimation() + /// + /// whther animaiton is serie animation. LeftToRight, AlongPath and Clockwise are serie animation. + /// |是否为系列动画。LeftToRight、AlongPath和Clockwise类型的为系列动画。 + /// + public bool IsSerieAnimation() { return context.type == AnimationType.LeftToRight || context.type == AnimationType.AlongPath || context.type == AnimationType.Clockwise; @@ -365,7 +374,7 @@ namespace XCharts.Runtime public bool CheckDetailBreak(float detail) { - if (!IsIndexAnimation()) + if (!IsSerieAnimation()) return false; foreach (var animation in animations) { @@ -377,7 +386,7 @@ namespace XCharts.Runtime public bool CheckDetailBreak(Vector3 pos, bool isYAxis) { - if (!IsIndexAnimation()) + if (!IsSerieAnimation()) return false; if (IsFinish()) @@ -400,7 +409,7 @@ namespace XCharts.Runtime public void CheckProgress() { - if (IsItemAnimation() && context.isAllItemAnimationEnd) + if (IsDataAnimation() && context.isAllItemAnimationEnd) { foreach (var animation in animations) { diff --git a/Runtime/Component/Animation/AnimationStyleHelper.cs b/Runtime/Component/Animation/AnimationStyleHelper.cs index e58930c5..bc8a5bf5 100644 --- a/Runtime/Component/Animation/AnimationStyleHelper.cs +++ b/Runtime/Component/Animation/AnimationStyleHelper.cs @@ -7,7 +7,7 @@ namespace XCharts.Runtime { public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0) { - if (!serie.animation.IsItemAnimation()) + if (!serie.animation.IsDataAnimation()) { serie.animation.context.isAllItemAnimationEnd = false; return destProgress;