少年修仙传客户端代码仓库
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
using Snxxz.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace EnhancedUI.EnhancedScroller
{
    public class ChatPlayerMineCell : ScrollerUI
    {
        [SerializeField] Image m_ChatIcon;
        [SerializeField] Text m_VipLv;
        [SerializeField] Text m_PlayerName;
        [SerializeField] Text m_ChatTime;
        [SerializeField] ChatBubbleBehaviour m_ChatBubble;
        [SerializeField] Button m_Func;
        [SerializeField] float spacing = 5.0f;
 
        ChatCenter m_ChatCenter;
        ChatCenter chatCenter
        {
            get
            {
                return m_ChatCenter ?? (m_ChatCenter = ModelCenter.Instance.GetModel<ChatCenter>());
            }
        }
        public override void Refresh(CellView cell)
        {
            ChatData data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
            if (data == null)
            {
                return;
            }
            var chatUserData = data as ChatUeseData;
 
            m_ChatBubble.DisplayContent(data.content);
            m_ChatBubble.DisplayBubble((int)PlayerDatas.Instance.baseData.bubbleId);
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(chatUserData.job, 0));
 
            m_Func.onClick.RemoveAllListeners();
            m_Func.onClick.AddListener(() =>
            {
                OnFunc(cell);
            });
            m_PlayerName.text = chatUserData.name;
            m_ChatTime.text = data.createTime.ToString("yyyy-MM-dd HH:mm");
            if (chatUserData.vipLv > 0)
            {
                m_VipLv.text = "VIP";//string.Format("V{0}", chatUserData.vipLv);
            }
            else
            {
                m_VipLv.text = string.Empty;
            }
        }
 
        private void OnFunc(CellView cell)
        {
            int index = cell.index;
            ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, index);
            if (_data == null)
            {
                return;
            }
            ChatUeseData user = _data as ChatUeseData;
            if (user.player == PlayerDatas.Instance.baseData.PlayerID)
            {
                return;
            }
            HrefAnalysis.Inst.ExcuteHrefEvent(string.Format("<a>showplayer={0}</a>", user.player));
        }
 
        public float GetHeight(string content, ArrayList list)
        {
            var minHeight = m_ChatIcon.rectTransform.sizeDelta.y;
            var chatHeight = m_ChatBubble.GetBubbleHeight(content, list) + Mathf.Abs(m_ChatBubble.transform.localPosition.y);
            return (chatHeight > minHeight ? chatHeight : minHeight) + spacing;
        }
    }
}