| | |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | | public class ChatTip : MonoBehaviour
|
| | |
| | |
|
| | | private List<GameObject> chatItems = new List<GameObject>(ChatCtrl.CHAT_TIP_CNT);
|
| | |
|
| | | static StringBuilder sb = new StringBuilder();
|
| | |
|
| | | void InitCom()
|
| | | {
|
| | | chatBg = this.GetComponent<Image>("Image");
|
| | |
| | | private bool OnGetDynamicSize(ScrollerDataType type, int index, out float height)
|
| | | {
|
| | | destText.SetExtenalData(chatUpDataList[index].infoList);
|
| | | destText.text = SetChatExtraInfo(chatUpDataList[index]) + chatUpDataList[index].content;
|
| | | destText.text = StringUtility.Contact(SetChatExtraInfo(chatUpDataList[index]),
|
| | | chatUpDataList[index].content);
|
| | | height = destText.preferredHeight;
|
| | | return true;
|
| | | }
|
| | |
| | | {
|
| | | text.SetExtenalData(chatUpDataList[index].infoList);
|
| | | }
|
| | | text.text = SetChatExtraInfo(chatUpDataList[index]) + chatUpDataList[index].content;
|
| | | text.text = StringUtility.Contact(SetChatExtraInfo(chatUpDataList[index]),
|
| | | chatUpDataList[index].content);
|
| | | text.OnClick = () =>
|
| | | {
|
| | | OnChatDataClick(data);
|
| | |
| | |
|
| | | string SetChatExtraInfo(ChatData data)
|
| | | {
|
| | | sb.Length = 0;
|
| | | string vipLv = string.Empty;
|
| | | string chatIcon = string.Empty;
|
| | | string chatName = string.Empty;
|
| | | var chatUserData = (data as ChatUeseData);
|
| | | switch (data.type)
|
| | | {
|
| | | case ChatInfoType.World:
|
| | | {
|
| | | return string.Format("<Img chat={0}/> <color=#109d06>{1}</color>: ", "ChatIcon_World", (data as ChatUeseData).name);
|
| | | chatIcon = "ChatIcon_World";
|
| | | chatName = chatUserData.name;
|
| | | if (chatUserData.vipLv > 0)
|
| | | {
|
| | | vipLv = StringUtility.Contact("V", chatUserData.vipLv);
|
| | | }
|
| | | break;
|
| | | }
|
| | | case ChatInfoType.Area:
|
| | | return string.Format("<Img chat={0}/> <color=#109d06>{1}</color>: ", "ChatIcon_Area", (data as ChatUeseData).name);
|
| | | {
|
| | | chatIcon = "ChatIcon_Area";
|
| | | chatName = chatUserData.name;
|
| | | if (chatUserData.vipLv > 0)
|
| | | {
|
| | | vipLv = StringUtility.Contact("V", chatUserData.vipLv);
|
| | | }
|
| | | break;
|
| | | }
|
| | | case ChatInfoType.Team:
|
| | | {
|
| | | string playerName = (data as ChatUeseData).name;
|
| | | return string.Format("<Img chat={0}/> <color=#109d06>{1}</color>", "ChatIcon_Team", playerName + (playerName != string.Empty ? ": " : string.Empty));
|
| | | chatIcon = "ChatIcon_Team";
|
| | | chatName = chatUserData.name;
|
| | | if (chatUserData.vipLv > 0)
|
| | | {
|
| | | vipLv = StringUtility.Contact("V", chatUserData.vipLv);
|
| | | }
|
| | | break;
|
| | | }
|
| | | case ChatInfoType.Friend:
|
| | | break;
|
| | | case ChatInfoType.Fairy:
|
| | | {
|
| | | string playerName = (data as ChatUeseData).name;
|
| | | return string.Format("<Img chat={0}/> <color=#109d06>{1}</color>", "ChatIcon_Fairy", playerName + (playerName != string.Empty ? ": " : string.Empty));
|
| | | chatIcon = "ChatIcon_Fairy";
|
| | | chatName = chatUserData.name;
|
| | | if (chatUserData.vipLv > 0)
|
| | | {
|
| | | vipLv = StringUtility.Contact("V", chatUserData.vipLv);
|
| | | }
|
| | | break;
|
| | | }
|
| | | case ChatInfoType.Trumpet:
|
| | | return string.Format("<Img chat={0}/> <color=#109d06>{1}</color>: ", "ChatIcon_Trumpet", (data as ChatTrumpetData).name);
|
| | | {
|
| | | chatIcon = "ChatIcon_Trumpet";
|
| | | chatName = chatUserData.name;
|
| | | if (chatUserData.vipLv > 0)
|
| | | {
|
| | | vipLv = StringUtility.Contact("V", chatUserData.vipLv);
|
| | | }
|
| | | break;
|
| | | }
|
| | | case ChatInfoType.Invite:
|
| | | return string.Format("<Img chat={0}/> ", "ChatIcon_Invite");
|
| | | {
|
| | | chatIcon = "ChatIcon_Invite";
|
| | | break;
|
| | | }
|
| | | case ChatInfoType.System:
|
| | | return string.Format("<Img chat={0}/> ", "ChatIcon_System");
|
| | | {
|
| | | chatIcon = "ChatIcon_System";
|
| | | break;
|
| | | }
|
| | | }
|
| | | return string.Empty;
|
| | | if (!string.IsNullOrEmpty(chatIcon))
|
| | | {
|
| | | sb.Append(string.Format("<Img chat={0}/> ", chatIcon));
|
| | | }
|
| | | if (!string.IsNullOrEmpty(vipLv))
|
| | | {
|
| | | sb.Append(string.Format("<color=#f8983b>{0}</color> ", vipLv));
|
| | | }
|
| | | if (!string.IsNullOrEmpty(chatName))
|
| | | {
|
| | | sb.Append(string.Format("<color=#109d06>{0}</color>: ", chatName));
|
| | | }
|
| | | return sb.ToString();
|
| | | }
|
| | |
|
| | | private void OnDisable()
|