/// <summary> /// 响应并发序列动画单个动画播放完成 /// </summary> /// <param name="tanim"></param> private void OnParalAnimationPlayCompleted(TBaseAnimation tanim) { mParalWailtedCompletedAnimationList.Remove(tanim); Debug.Log($"并发序列-动画:{tanim.GetType().Name}播放完成,剩余等待完成动画数量:{mParalWailtedCompletedAnimationList.Count}!"); if (mParalWailtedCompletedAnimationList.Count == 0) { OnPlaySequenceAnimationEnd(); } }
/// <summary> /// 强制打断当前序列动画 /// </summary> public void ForceStopAnims() { // 强制线性播放到最后一个,强制结束 mLinearPlayAnimationNextIndex = AnimationInfoList.Count; if (mCurrentLinearPlayAnimation != null) { mCurrentLinearPlayAnimation.ForceStopAnim(); } mCurrentLinearPlayAnimation = null; foreach (var waitedcompletedanimation in mParalWailtedCompletedAnimationList.ToArray()) { waitedcompletedanimation.ForceStopAnim(); } mParalWailtedCompletedAnimationList.Clear(); mOnSequenceAnimBeginEvent = null; }
/// <summary> /// 播放下一个线性动画 /// </summary> private void PlayNextLinearAnimation() { if (mLinearPlayAnimationNextIndex < AnimationInfoList.Count) { for (int i = mLinearPlayAnimationNextIndex, length = AnimationInfoList.Count; i < length; i++) { if (AnimationInfoList[mLinearPlayAnimationNextIndex].ControlAnimation != null) { if (AnimationInfoList[mLinearPlayAnimationNextIndex].ControlAnimation.IsAvalibleToPlay()) { mLinearPlayAnimationNextIndex = i + 1; mCurrentLinearPlayAnimation = AnimationInfoList[i].ControlAnimation; break; } else { Debug.LogWarning($"动画:{AnimationInfoList[i].ControlAnimation.GetType().Name}不符合播放条件,无法通过序列组动画对象:{gameObject.name}线性播放!"); } } else { Debug.LogWarning($"序列动画索引:{i}的动画组件为空,无法线性播放!"); } } if (mCurrentLinearPlayAnimation != null) { mCurrentLinearPlayAnimation.StartAnim(OnLinearAnimationPlayCompleted); } else { OnPlaySequenceAnimationEnd(); } } else { OnPlaySequenceAnimationEnd(); } }
TAnimationInfo(GameObject targetgo, TBaseAnimation controlanimation = null) { TargetGo = targetgo; ControlAnimation = controlanimation; ControlAnimationIndex = -1; }
TAnimationInfo() { TargetGo = null; ControlAnimation = null; ControlAnimationIndex = -1; }
/// <summary> /// 响应线性序列动画单个动画播放完成 /// </summary> /// <param name="tanim"></param> private void OnLinearAnimationPlayCompleted(TBaseAnimation tanim) { Debug.Log($"线性序列-动画:{tanim.GetType().Name}播放完成,下一个等待播放动画索引:{mLinearPlayAnimationNextIndex}!"); mCurrentLinearPlayAnimation = null; PlayNextLinearAnimation(); }