wangguan
2020-12-04 a156d3fb25a19967851c145f811782258dd663bf
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using UnityEngine;
using UnityEngine.UI;
using EnhancedUI.EnhancedScroller;
using TMPro;
using DG.Tweening;
using KTGMGemClient;
 
public class FinalPanelItem : EnhancedScrollerCellView
{
    public Text playerNameTxt;
    public Text playerWaveTxt;
    public TextMeshProUGUI playerScoreTxt;
 
    public TextMeshProUGUI indexTxt;
 
    //public Image icon;
    public Image backGround;
    public Sprite tmpBackGround;//自己的背景
    public Sprite otherBackGround;//其他人的背景
    public Color tmpColor;//自己的字体颜色
    public Color otherColor;//其他人的字体颜色
    Vector3 offect;
 
    private RectTransform rt;
 
    //public TextMeshProUGUI rankUpbj;
 
    //bool isSelfPlayer;
 
    /// <summary>
    /// Start is called on the frame when a script is enabled just before
    /// any of the Update methods is called the first time.
    /// </summary>
    void Awake()
    {
        offect = Vector3.zero;
        rt = transform.GetComponent<RectTransform>();
    }
 
 
    public void SetData(FinalPanelItemData data)
    {
        playerNameTxt.text = data.httpInfo.nickname;
        playerScoreTxt.text = data.httpInfo.score.ToString();
        playerWaveTxt.text = data.httpInfo.waveInfo;
 
        if (data.index > 3)//前三名的手动隐藏了
        {
            indexTxt.text = data.index.ToString();
        }
 
        if (data.httpInfo.username.Equals(GameConfig.Imei))
        {
            //isSelfPlayer = true;
            //是自己
            if (backGround.sprite != tmpBackGround)
                backGround.sprite = tmpBackGround;
            if (playerNameTxt.color != tmpColor)
            {
                playerNameTxt.color = tmpColor;
                playerScoreTxt.color = tmpColor;
                playerWaveTxt.color = tmpColor;
            }
        }
        else
        {
            //isSelfPlayer = false;
 
            if (backGround.sprite != otherBackGround)
                backGround.sprite = otherBackGround;
            if (playerNameTxt.color != otherColor)
            {
                playerNameTxt.color = otherColor;
                playerScoreTxt.color = otherColor;
                playerWaveTxt.color = otherColor;
            }
        }
        if (rt != null)
        {
            offect.x = rt.anchoredPosition3D.x;
            offect.y = rt.anchoredPosition3D.y;
 
            rt.anchoredPosition3D = offect;
        }
    }
 
    // /// <summary>
    // /// 检查排名上升
    // /// </summary>
    // /// <param name="rankUp"></param>
    // public void CheckRank(int rankUp)
    // {
    //     if (rankUp > 0)
    //     {
    //         Debug.Log($"排名上升:{rankUp}   isSelfPlayer:{isSelfPlayer}  rankUpbj.gameObject.activeSelf:{rankUpbj.gameObject.activeSelf}");
    //         if (isSelfPlayer && !rankUpbj.gameObject.activeSelf)
    //         {
    //             rankUpbj.gameObject.SetActive(true);
    //             rankUpbj.text = rankUp.ToString();
    //         }
    //     }
    //     else if (rankUpbj.gameObject.activeSelf)
    //     {
    //         rankUpbj.gameObject.SetActive(false);
    //     }
    // }
 
    public void SetPos()
    {
        backGround.rectTransform.anchoredPosition = new UnityEngine.Vector2(720, 0);
    }
 
    public void PlayDoTween(float duration)
    {
        //Sequence agentTweenSeq = DOTween.Sequence();
        //agentTweenSeq.Join(backGround.rectTransform.DOAnchorPosX(0, duration));
        backGround.rectTransform.DOAnchorPosX(0, duration);
    }
}