少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Snxxz.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<T>(List<T> _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;
        }
    }
}