コード例 #1
0
ファイル: FriendsInfo.cs プロジェクト: atom-chen/tianyu
 /// <summary>
 /// 构造
 /// </summary>
 public FriendsInfo(relation_list _data)
 {
     type      = _data.type;
     configId  = _data.uid;
     isOnline  = _data.offline_state == 0;
     prof      = _data.prof;
     name      = _data.name;
     lev       = _data.lev;
     intimacy  = _data.intimacy;
     placeName = _data.scene;
     fight     = _data.fight_score;
 }
コード例 #2
0
ファイル: FriendsInfo.cs プロジェクト: atom-chen/tianyu
 /// <summary>
 /// 好友更新
 /// </summary>
 public void Updata(relation_list _data)
 {
     type      = _data.type;
     configId  = _data.uid;
     isOnline  = _data.offline_state == 0;
     prof      = _data.prof;
     name      = _data.name;
     lev       = _data.lev;
     intimacy  = _data.intimacy;
     placeName = _data.scene;
     fight     = _data.fight_score;
     if (OnFriendsListUpdate != null)
     {
         OnFriendsListUpdate();
     }
 }
コード例 #3
0
    /// <summary>
    /// 接收好友链表
    /// </summary>
    protected void S2C_GetFriendsList(Pt pt)
    {
        pt_friend_relation_list_d705 msg = pt as pt_friend_relation_list_d705;

        if (msg != null)
        {
            //for (int j = 0; j < msg.relation_list.Count; j++)
            //{
            //    Debug.Log("d705    add_or_remove:  " + msg.add_or_remove + "   , type : " + msg.relation_list[j].type + "   ,  uid : " + msg.relation_list[j].uid + "   , name : " + msg.relation_list[j].name + "   ,lev : " + msg.relation_list[j].lev + "  " + ConfigMng.Instance.GetLevelDes(msg.relation_list[j].lev));
            //}
            if (isAddInAdvice && msg.add_or_remove == 1)//将好友推送中的人添加到好友列表,删除好友推送中的人
            {
                for (int i = 0, max = msg.relation_list.Count; i < max; i++)
                {
                    if (friendsDic.ContainsKey(msg.relation_list[i].uid))
                    {
                        friendsDic.Remove(msg.relation_list[i].uid);
                    }
                }
            }
            else if (msg.add_or_remove == 1)//添加
            {
                if (msg.relation_list.Count > 0)
                {
                    int type = msg.relation_list[0].type;

                    if (!allFriendDic.ContainsKey(type))
                    {
                        allFriendDic[type] = new FDictionary();
                    }
                    for (int i = 0, max = msg.relation_list.Count; i < max; i++)
                    {
                        FriendsInfo info = new FriendsInfo(msg.relation_list[i]);
                        if (!allFriendDic[type].ContainsKey(msg.relation_list[i].uid))
                        {
                            allFriendDic[type][msg.relation_list[i].uid] = info;
                        }
                    }
                }
                for (int i = 0, max = msg.relation_list.Count; i < max; i++)
                {
                    if (!friendsDic.ContainsKey(msg.relation_list[i].uid))
                    {
                        friendsDic[msg.relation_list[i].uid] = new FriendsInfo(msg.relation_list[i]);
                    }
                }
            }
            else if (msg.add_or_remove == 2)//移除
            {
                if (msg.relation_list.Count > 0)
                {
                    int type = msg.relation_list[0].type;

                    if (allFriendDic.ContainsKey(type))
                    {
                        for (int i = 0, max = msg.relation_list.Count; i < max; i++)
                        {
                            if (allFriendDic[type].ContainsKey(msg.relation_list[i].uid))
                            {
                                allFriendDic[type].Remove(msg.relation_list[i].uid);
                            }
                        }
                    }
                }

                for (int i = 0, max = msg.relation_list.Count; i < max; i++)
                {
                    if (friendsDic.ContainsKey(msg.relation_list[i].uid))
                    {
                        friendsDic.Remove(msg.relation_list[i].uid);
                    }
                }
            }
            else//链表
            {
                curFriend = null;
                friendsDic.Clear();
                for (int i = 0, max = msg.relation_list.Count; i < max; i++)
                {
                    relation_list data = msg.relation_list[i];
                    if (!friendsDic.ContainsKey(data.uid))
                    {
                        friendsDic[data.uid] = new FriendsInfo(data);
                    }
                    else
                    {
                        FriendsInfo info = friendsDic[data.uid] as FriendsInfo;
                        info.Updata(data);
                    }
                }
                if (msg.relation_list.Count > 0)
                {
                    FDictionary dic = new FDictionary();
                    foreach (FriendsInfo info in friendsDic.Values)
                    {
                        dic[info.configId] = info;
                    }
                    if (!allFriendDic.ContainsKey(msg.relation_list[0].type))
                    {
                        allFriendDic[msg.relation_list[0].type] = dic;
                    }
                }
            }
        }
        if (msg.relation_list.Count > 0 && msg.relation_list[0].type == 4)
        {
            if (OnEnemyDicUpdata != null)
            {
                OnEnemyDicUpdata();
            }
        }
        if (OnFriendsDicUpdata != null)
        {
            OnFriendsDicUpdata();
        }
    }