using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace vnxbqy.UI { public class HazyRegionCyclicScroll : CyclicScroll { [SerializeField] float m_FadeInTime = 0.2f; bool m_IsPlaying = false; public bool IsPlaying { get { return m_IsPlaying; } private set { m_IsPlaying = value; this.enabled = !m_IsPlaying; } } Coroutine m_Coroutine = null; public event Action animationComplete; public override void Init(List _datas, bool _stepByStep = false) { base.Init(_datas, _stepByStep); IsPlaying = false; if (m_Coroutine != null) { StopCoroutine(m_Coroutine); m_Coroutine = null; } } public void DisplayAnimation() { IsPlaying = true; m_Coroutine = StartCoroutine(Co_DisplayAnimation()); } IEnumerator Co_DisplayAnimation() { for (int i = 0; i < infiniteItems.Count; i++) { var behaviour = infiniteItems[i] as HazyRegionIncidentBehaviour; behaviour.alphaTween.SetStartState(); } var width = content.sizeDelta.x; var time = 0f; for (int i = 0; i < infiniteItems.Count; i++) { var behaviour = infiniteItems[i] as HazyRegionIncidentBehaviour; behaviour.linerMove.duration = behaviour.alphaTween.duration; var fromX = content.anchoredPosition.x + width / 2 + m_BoundOffset.left + cellSize.x; behaviour.linerMove.from = content.anchoredPosition.SetX(fromX); var toX = content.anchoredPosition.x - width / 2 + m_BoundOffset.left + cellSize.x / 2 + i * (cellSize.x + spacing.x); behaviour.linerMove.to = content.anchoredPosition.SetX(toX); behaviour.alphaTween.Play(); behaviour.linerMove.Begin(); yield return WaitingForSecondConst.GetWaitForSeconds(m_FadeInTime); time = behaviour.alphaTween.duration - m_FadeInTime; } time = Mathf.Max(0, time); yield return WaitingForSecondConst.GetWaitForSeconds(time); if (animationComplete != null) { animationComplete(); } IsPlaying = false; } } }