Esempio n. 1
0
        private ChatMsgDataItem GetShowChatMsgDataItem(int index, int msgHistoryIndex)
        {
            List <ChatMsgDataItem> showMsgDataList = this.GetShowMsgDataList();
            int             count = showMsgDataList.Count;
            ChatMsgDataItem item  = null;

            if (count > 0)
            {
                if (msgHistoryIndex == 0)
                {
                    return(this.GetShowMsgDataList()[index]);
                }
                if (index < msgHistoryIndex)
                {
                    return(showMsgDataList[index]);
                }
                if ((index >= msgHistoryIndex) && (index < (msgHistoryIndex + 4)))
                {
                    return((index != msgHistoryIndex) ? ChatMsgDataItem.EMPTY_MSG : ChatMsgDataItem.HISTORY_LINE_MSG);
                }
                if (index >= (msgHistoryIndex + 4))
                {
                    int num2 = index - 4;
                    if (num2 < count)
                    {
                        item = showMsgDataList[num2];
                    }
                }
            }
            return(item);
        }
Esempio n. 2
0
 private void SetFriendMsgNew(ChatMsgDataItem msgData)
 {
     if (!this._friendNewMsgWeightDic.ContainsKey(msgData.uid))
     {
         this._friendNewMsgWeightDic.Add(msgData.uid, Tuple.Create <bool, int>(true, this._weight++));
     }
     this._friendNewMsgWeightDic[msgData.uid] = Tuple.Create <bool, int>(true, this._weight++);
 }
Esempio n. 3
0
 private void AddFriendChatMsg(ChatMsgDataItem msgData)
 {
     if (!this._friendChatMsgMap.ContainsKey(msgData.uid))
     {
         this._friendChatMsgMap.Add(msgData.uid, new List <ChatMsgDataItem>());
     }
     this._friendChatMsgMap[msgData.uid].Add(msgData);
     this.SaveLocalFriendChatMsg();
     this.SetFriendMsgNew(msgData);
 }
Esempio n. 4
0
 private string WrapGuildTalkMsgRichText(ChatMsgDataItem msgData)
 {
     if (Singleton <PlayerModule> .Instance.playerData.userId == msgData.uid)
     {
         object[] objArray1 = new object[] { "<color=#ff9900>", msgData.nickname, "</color>", "<color=#00c1ff>", msgData.guildTitle, "</color>" };
         return(string.Format("{0}[{1}]{2}{3}[{4}]:{5}", objArray1));
     }
     object[] args = new object[] { "<color=#00c1ff>", msgData.nickname, "</color>", "<color=#00c1ff>", msgData.guildTitle, "</color>" };
     return(string.Format("{0}[{1}]{2}{3}[{4}]:{5}", args));
 }
Esempio n. 5
0
        private string WrapFriendTalkMsgRichText(ChatMsgDataItem msgData)
        {
            string text = LocalizationGeneralLogic.GetText("Chat_Content_I", new object[0]);
            string str2 = LocalizationGeneralLogic.GetText("Chat_Content_To", new object[0]);
            string str3 = LocalizationGeneralLogic.GetText("Chat_Content_Speak", new object[0]);

            if (Singleton <PlayerModule> .Instance.playerData.userId == msgData.uid)
            {
                object[] objArray1 = new object[] { text, str2, Singleton <FriendModule> .Instance.TryGetPlayerNickName(this._talkingFriendUid), str3 };
                return(string.Format("<color=#ff9900>{0}{1}</color><color=#00c1ff>[{2}]</color><color=#ff9900>{3}</color>:", objArray1));
            }
            object[] args = new object[] { "<color=#00c1ff>", Singleton <FriendModule> .Instance.TryGetPlayerNickName(this._talkingFriendUid), "</color>", "<color=white>", str2, text, str3, "</color>" };
            return(string.Format("{0}[{1}]{2}{3}{4}{5}{6}:{7}", args));
        }
Esempio n. 6
0
        private void OnSendMsgBtnClick()
        {
            string str    = base.view.transform.Find("Dialog/Content/InputField").GetComponent <InputField>().text.Trim();
            int    length = Mathf.Min(40, str.Length);

            str = str.Substring(0, length);
            if (!string.IsNullOrEmpty(str) && ((this._mode != Mode.Friend) || (this._talkingFriendUid > 0)))
            {
                ChatMsgDataItem msgItem = this.GenerateMsgSendByMe(str);
                if (this._mode == Mode.World)
                {
                    if (Singleton <ChatModule> .Instance.IsWorldChatAllowed(msgItem))
                    {
                        Singleton <ChatModule> .Instance.worldChatMsgList.Add(msgItem);

                        Singleton <ChatModule> .Instance.lastWorldChatTime = msgItem.time;
                        Singleton <NetworkManager> .Instance.NotifySendWorldChatMsg(msgItem.msg);
                    }
                    else
                    {
                        Singleton <ChatModule> .Instance.worldChatMsgList.Add(ChatMsgDataItem.TALK_TOO_FAST_MSG);
                    }
                }
                else if (this._mode == Mode.Friend)
                {
                    if (Singleton <FriendModule> .Instance.IsMyFriend(this._talkingFriendUid))
                    {
                        Singleton <ChatModule> .Instance.AddFriendChatMsgByMySelf(msgItem, this._talkingFriendUid, true);

                        Singleton <NetworkManager> .Instance.NotifySendFriendChatMsg(this._talkingFriendUid, msgItem.msg);

                        this.SetupFriendList();
                    }
                    else
                    {
                        msgItem.msg = LocalizationGeneralLogic.GetText("Chat_Content_NotFriend", new object[0]);
                        Singleton <ChatModule> .Instance.AddFriendChatMsgByMySelf(msgItem, this._talkingFriendUid, false);
                    }
                }
                else if (this._mode == Mode.Guild)
                {
                    Singleton <ChatModule> .Instance.guildChatMsgList.Add(msgItem);

                    Singleton <NetworkManager> .Instance.NotifySendGuildChatMsg(msgItem.msg);
                }
                this.UpdateChatList(1);
                this.ClearInputFieldText();
            }
        }
Esempio n. 7
0
 public void AddFriendChatMsgByMySelf(ChatMsgDataItem msgData, int friendId, bool needSave = true)
 {
     if (!this._friendChatMsgMap.ContainsKey(friendId))
     {
         this._friendChatMsgMap.Add(friendId, new List <ChatMsgDataItem>());
     }
     this._friendChatMsgMap[friendId].Add(msgData);
     if (!this._friendNewMsgWeightDic.ContainsKey(friendId))
     {
         this._friendNewMsgWeightDic.Add(friendId, Tuple.Create <bool, int>(false, 0));
     }
     else
     {
         this._friendNewMsgWeightDic[friendId] = Tuple.Create <bool, int>(false, this._friendNewMsgWeightDic[friendId].Item2);
     }
     if (needSave)
     {
         this.SaveLocalFriendChatMsg();
     }
 }
Esempio n. 8
0
 public bool IsWorldChatAllowed(ChatMsgDataItem msgItem)
 {
     return(this.IsInWorldChatCD(msgItem.time) && this.IsInWorldChatLevel());
 }
Esempio n. 9
0
        private void OnScrollChange(Transform trans, int index)
        {
            Text            component           = trans.Find("Nickname").GetComponent <Text>();
            Text            text2               = trans.Find("Msg").GetComponent <Text>();
            int             msgHistoryIndex     = this.GetMsgHistoryIndex();
            ChatMsgDataItem showChatMsgDataItem = this.GetShowChatMsgDataItem(index, msgHistoryIndex);

            if (showChatMsgDataItem == null)
            {
                component.gameObject.SetActive(false);
                text2.gameObject.SetActive(false);
            }
            else
            {
                bool flag  = Singleton <PlayerModule> .Instance.playerData.userId == showChatMsgDataItem.uid;
                bool flag2 = showChatMsgDataItem.isMsgDataItemBelongToType(ChatMsgDataItem.Type.HISTORY_LINE);
                component.gameObject.SetActive(!flag2);
                text2.gameObject.SetActive(!flag2);
                trans.Find("HistoryLine").gameObject.SetActive(flag2);
                if (showChatMsgDataItem.isMsgDataItemBelongToType(ChatMsgDataItem.Type.EMPTY))
                {
                    component.text = string.Empty;
                    text2.text     = string.Empty;
                }
                else
                {
                    Color color  = new Color(1f, 0.6f, 0f);
                    Color color2 = new Color(0f, 0.76f, 1f);
                    Color color3 = new Color(0.99f, 0.87f, 0.3f);
                    Color white  = Color.white;
                    Color grey   = Color.grey;
                    Color color6 = new Color(1f, 0.36f, 0.25f);
                    if (this._mode == Mode.World)
                    {
                        component.color = !flag ? color2 : color;
                        component.text  = string.Format("[{0}]", showChatMsgDataItem.nickname);
                        text2.color     = !flag ? white : color3;
                        text2.text      = showChatMsgDataItem.msg;
                        if (!flag)
                        {
                        }
                    }
                    else if (this._mode == Mode.Guild)
                    {
                        component.text = this.WrapGuildTalkMsgRichText(showChatMsgDataItem);
                        text2.color    = !flag ? white : color3;
                        text2.text     = showChatMsgDataItem.msg;
                    }
                    else if (this._mode == Mode.Friend)
                    {
                        component.text = this.WrapFriendTalkMsgRichText(showChatMsgDataItem);
                        text2.text     = showChatMsgDataItem.msg;
                        if (Singleton <FriendModule> .Instance.IsMyFriend(this._talkingFriendUid))
                        {
                            text2.color = !flag ? white : color3;
                        }
                        else
                        {
                            text2.color = grey;
                        }
                    }
                    if (showChatMsgDataItem.isMsgDataItemBelongToType(ChatMsgDataItem.Type.SYSTEM))
                    {
                        component.color = color6;
                        text2.color     = color6;
                        component.text  = string.Format("[{0}]", LocalizationGeneralLogic.GetText("Chat_Content_System", new object[0]));
                    }
                    bool flag4 = showChatMsgDataItem.isMsgDataItemBelongToType(ChatMsgDataItem.Type.LUCK_GECHA);
                    text2.supportRichText = flag4;
                    if (index < msgHistoryIndex)
                    {
                        text2.color = grey;
                    }
                }
            }
        }