wangguan
2020-12-23 1e192494412a34d17548834a6aff639202cdfdda
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
85
86
87
88
89
90
91
92
93
94
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
 
/**
 * 游戏结束面板
 * @Author: chenxin
 * @Date: 2020-12-11 21:27:12
 */
namespace KTGMGemClient
{
    public class GameOverPanel : MonoBehaviour
    {
        [SerializeField]
        private Image bg;
 
        [SerializeField]
        private List<Image> imgList;
 
        private float duration = 0.1f;
 
        // Start is called before the first frame update
        private void Start()
        {
            Sequence sequence = DOTween.Sequence();
            sequence.Append(DOTween.To(
                () => bg.color,
                (Color v) => bg.color = v,
                new Color(0f, 0f, 0f, 170f / 255f),
                0.3f));
 
            sequence.Join(DOTween.To(
                   () => imgList[0].transform.localPosition.y,
                   (float v) =>
                   {
                       Vector3 pos = imgList[0].transform.localPosition;
                       pos.y = v;
                       imgList[0].transform.localPosition = pos;
                   },
                   346f,
                   0.8f)
                   .SetEase(Ease.OutBounce)
               );
 
            sequence.Join(DOTween.To(
                   () => imgList[1].transform.localPosition.y,
                   (float v) =>
                   {
                       Vector3 pos = imgList[1].transform.localPosition;
                       pos.y = v;
                       imgList[1].transform.localPosition = pos;
                   },
                   346f,
                   0.8f)
                   .SetEase(Ease.OutBounce)
                   .SetDelay(1 * duration)
            );
 
            sequence.Join(DOTween.To(
                   () => imgList[2].transform.localPosition.y,
                   (float v) =>
                   {
                       Vector3 pos = imgList[2].transform.localPosition;
                       pos.y = v;
                       imgList[2].transform.localPosition = pos;
                   },
                   346f,
                   0.8f)
                   .SetEase(Ease.OutBounce)
                   .SetDelay(2 * duration)
            );
 
            sequence.Join(DOTween.To(
                   () => imgList[3].transform.localPosition.y,
                   (float v) =>
                   {
                       Vector3 pos = imgList[3].transform.localPosition;
                       pos.y = v;
                       imgList[3].transform.localPosition = pos;
                   },
                   346f,
                   0.8f)
                   .SetEase(Ease.OutBounce)
                   .SetDelay(3 * duration)
                   .OnComplete(() =>
                   {
                       EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.GameOverEnd);
                       Destroy(gameObject);
                   })
            );
        }
    }
}