Пример #1
0
    /// <summary>
    /// 加载本地最近聊天的人
    /// </summary>
    void LoadChatLogs()
    {
        UIUtils.DestroyChildren(parent);
        if (!File.Exists(ConstantUtils.chatConfigPath))
        {
            return;
        }
        string   text = File.ReadAllText(ConstantUtils.chatConfigPath);
        JsonData json = JsonMapper.ToObject(text);

        foreach (var item in json.Keys)
        {
            MessagePanelInfo info = new MessagePanelInfo();
            info.messageType = 0;
            info.name        = json[item]["name"].ToString();
            info.headIcon    = json[item]["headIcon"].ToString();

            info.id  = int.Parse(item);
            info.six = int.Parse(json[item]["six"].ToString());
            long Timer = long.Parse(json[item]["history"][json[item]["history"].Count - 1]["timer"].ToString());
            info.timer = Timer;
            info.text  = json[item]["history"][json[item]["history"].Count - 1]["text"].ToString();
            info.type  = int.Parse(json[item]["history"][json[item]["history"].Count - 1]["type"].ToString());
            LoadItem(info);
        }
    }
Пример #2
0
    void LoadItem(MessagePanelInfo info)
    {
        MessagePanelItem item = null;

        if (info.messageType == 0)
        {
            item = Instantiate(playerPrefab, parent).GetComponent <MessagePanelItem>();
        }
        else
        {
            item = Instantiate(systemPrefab, parent).GetComponent <MessagePanelItem>();
        }
        item.Inits(info, OnClickCall);
        item.transform.SetAsFirstSibling();
    }
Пример #3
0
 /// <summary>
 /// 服务器推送所有加好友列表
 /// </summary>
 public void G2C_AddFriends(List <FriendInfo> infos)
 {
     for (int i = 0; i < parent.childCount; i++)
     {
         MessagePanelItem item = parent.GetChild(i).GetComponent <MessagePanelItem>();
         if (item.info.messageType == 1)
         {
             Destroy(item.gameObject);
         }
     }
     for (int i = 0; i < infos.Count; i++)
     {
         MessagePanelInfo info = new MessagePanelInfo();
         info.messageType = 1;
         info.name        = infos[i].nickname;
         info.id          = infos[i].userId;
         info.six         = infos[i].gender;
         //DateTime time=MiscUtils.GetDateTimeByTimeStamp(infos[i].)
         info.timer = MiscUtils.GetTimeStamp(DateTime.Now) * 1000;
         LoadItem(info);
     }
 }
Пример #4
0
    void G2C_Chat(ChatInfo info)
    {
        MessagePanelItem item = getMessageItem(info);

        if (item)
        {
            item.RefreshNowMessage(info.type, info.text, info.chatTime);
        }
        else
        {
            //如果之前没有
            MessagePanelInfo infos = new MessagePanelInfo();
            infos.name = info.chatWithName;
            infos.id   = info.chatWithId;
            infos.six  = info.playerBaseInfo.six == Six.boy ? 0 : 1;

            infos.timer       = info.chatTime;
            infos.text        = info.text;
            infos.headIcon    = info.playerBaseInfo.icon;
            infos.type        = info.type;
            infos.messageType = 0;
            LoadItem(infos);
        }
    }