Exemplo n.º 1
0
        public void UpdateTeam(ushort protocol, byte[] data)
        {
            if (IsEnable == false)
            {
                return;
            }
            if (protocol == NetMsg.MSG_TEAM_MEMBER_POS)
            {
                m_bNetAnswer = true;

                var msg = S2CPackBase.DeserializePack <S2CTeamMemberPos>(data);
                if (mTeamListPointObjs.Count != msg.list.Count)
                {
                    for (int i = 0; i < mTeamListPointObjs.Count; i++)
                    {
                        UIResourceManager.Instance.ReturnObjectToPool(mTeamListPointObjs[i]);
                    }
                    mTeamListPointObjs.Clear();
                    for (int i = 0; i < msg.list.Count; i++)
                    {
                        uint          uuid   = msg.list[i].uuid;
                        PkgTeamMember member = TeamManager.Instance.GetMember(uuid);
                        if (member.dungeon_id.Equals(m_CurSceneId))
                        {
                            var rect = GetItem(m_TeamPoint);
                            mTeamListPointObjs.Add(rect.gameObject);
                        }
                    }
                }
                for (int i = 0; i < mTeamListPointObjs.Count; i++)
                {
                    if (msg.list.Count > i)
                    {
                        var pos = msg.list[i];
                        mTeamListPointObjs[i].transform.localPosition = new Vector3((pos.pos.px * GlobalConst.UnitScale - minX) / uiScalex, (pos.pos.py * GlobalConst.UnitScale - minY) / uiScalex);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            case NetMsg.MSG_TEAM_INFO:
            {
                S2CTeamInfo pack = S2CPackBase.DeserializePack <S2CTeamInfo>(data);

                // 如果是新创建的队伍
                if (TeamId == 0 && pack.team_info.team_id > 0)
                {
                    RemoveAllBeInvitedInfos();
                }

                TeamId         = pack.team_info.team_id;
                LeaderId       = pack.team_info.leader_id;
                TargetId       = pack.team_info.target_id;
                TargetMinLevel = pack.team_info.min_lv;
                TargetMaxLevel = pack.team_info.max_lv;
                TeamMembers    = pack.team_info.members;
                if (pack.team_info.auto_match == 0)
                {
                    mIsAutoMatchingPlayer = false;
                }
                else
                {
                    mIsAutoMatchingPlayer = true;
                }
                mIsAutoMatchingTeam = false;

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, new CEventBaseArgs(pack.auto_build));
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_AUTO_MATCHING_STATE_CHANGED, null);

                UpdateMembersTeamIcon(null);

                break;
            }

            case NetMsg.MSG_TEAM_LIST:
            {
                S2CTeamList pack = S2CPackBase.DeserializePack <S2CTeamList>(data);

                break;
            }

            case NetMsg.MSG_TEAM_APPLY:
            {
                S2CTeamApply pack = S2CPackBase.DeserializePack <S2CTeamApply>(data);

                if (pack.result == 1)
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("TEAM_APPLY_SUCCESS"));
                }
                else
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("TEAM_APPLY_FAIL"));
                }

                break;
            }

            case NetMsg.MSG_TEAM_APPLY_INFO:
            {
                S2CTeamApplyInfo pack = S2CPackBase.DeserializePack <S2CTeamApplyInfo>(data);

                foreach (PkgTeamUserIntro applyInfo in pack.apply_list)
                {
                    if (IsInApllyList(applyInfo.brief.uuid) == false)
                    {
                        ApplyList.Add(applyInfo);
                    }
                }

                if (IsAutoAgree == true && SceneHelp.Instance.IsInWildInstance() == true)
                {
                    List <uint> uuids = new List <uint>();
                    uuids.Clear();
                    foreach (PkgTeamUserIntro apply in ApplyList)
                    {
                        uuids.Add(apply.brief.uuid);
                    }
                    HandleApply(1, uuids);
                }
                else
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_APPLY_INFO_CHANGED, null);
                }

                break;
            }

            case NetMsg.MSG_TEAM_ADD_MEMBER:
            {
                S2CTeamAddMember pack = S2CPackBase.DeserializePack <S2CTeamAddMember>(data);

                if (HaveMember(pack.member.brief.uuid) == false)
                {
                    TeamMembers.Add(pack.member);

                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, null);

                    // 在申请列表里面删除该玩家
                    RemoveApplyInfo(pack.member.brief.uuid);
                }

                break;
            }

            case NetMsg.MSG_TEAM_LEAVE:
            {
                S2CTeamLeave pack = S2CPackBase.DeserializePack <S2CTeamLeave>(data);

                if (pack.uuid == Game.Instance.LocalPlayerID.obj_idx)
                {
                    if (pack.reason == 1)
                    {
                        ApplyList.Clear();
                        ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_APPLY_INFO_CHANGED, null);

                        if (TeamMembers.Count == 1)
                        {
                            if (HaveTeam == true)
                            {
                                UINotice.Instance.ShowMessage(DBConstText.GetText("TEAM_DISMISS_TIPS"));
                            }
                        }
                        else
                        {
                            if (HaveTeam == true)
                            {
                                string msg = DBConstText.GetText("TEAM_ME_LEAVE_TIPS");
                                //ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_SYSTEM_MESSAGE_SHOW, new CEventBaseArgs(msg));
                                UINotice.Instance.ShowMessage(msg);
                            }
                        }
                    }
                    else
                    {
                        if (HaveTeam == true)
                        {
                            string msg = DBConstText.GetText("TEAM_ME_EXPEL_TIPS");
                            //ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_SYSTEM_MESSAGE_SHOW, new CEventBaseArgs(msg));
                            UINotice.Instance.ShowMessage(msg);
                        }
                    }

                    List <PkgTeamMember> tempMembers = new List <PkgTeamMember>(TeamMembers);

                    TeamId         = 0;
                    LeaderId       = 0;
                    TargetType     = 1;
                    TargetId       = 0;
                    TargetMinLevel = 0;
                    TargetMaxLevel = 0;
                    TeamMembers.Clear();

                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, null);

                    UpdateMembersTeamIcon(tempMembers);
                }
                else
                {
                    PkgTeamMember leaveMember = GetMember(pack.uuid);
                    if (leaveMember != null)
                    {
                        TeamMembers.Remove(leaveMember);

                        ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, null);

                        string msg = "";
                        if (pack.reason == 1)
                        {
                            msg = string.Format(DBConstText.GetText("TEAM_LEAVE_TIPS"), System.Text.Encoding.UTF8.GetString(leaveMember.brief.name));
                            UINotice.Instance.ShowMessage(msg);
                        }
                        else
                        {
                            msg = string.Format(DBConstText.GetText("TEAM_EXPEL_TIPS"), System.Text.Encoding.UTF8.GetString(leaveMember.brief.name));
                            UINotice.Instance.ShowMessage(msg);
                        }
                        ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_SYSTEM_MESSAGE_SHOW, new CEventBaseArgs(msg));
                    }
                }

                if (IsAutoAgree == true && SceneHelp.Instance.IsInWildInstance() == true)
                {
                    List <uint> uuids = new List <uint>();
                    uuids.Clear();
                    foreach (PkgTeamUserIntro apply in ApplyList)
                    {
                        uuids.Add(apply.brief.uuid);
                    }
                    HandleApply(1, uuids);
                }

                break;
            }

            case NetMsg.MSG_TEAM_BE_REJECTED:
            {
                S2CTeamBeRejected pack = S2CPackBase.DeserializePack <S2CTeamBeRejected>(data);

                UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("TEAM_REJECT_TIPS"), System.Text.Encoding.UTF8.GetString(pack.leader_name)));

                break;
            }

            case NetMsg.MSG_TEAM_PROMOTE:
            {
                S2CTeamPromote pack = S2CPackBase.DeserializePack <S2CTeamPromote>(data);

                // 没有队伍的话,LeaderId要赋值为0
                if (HaveTeam == true)
                {
                    LeaderId = pack.uuid;
                }
                else
                {
                    LeaderId = 0;
                }

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, null);

                UpdateMembersTeamIcon(null);

                // 如果不是转让给自己,则清空申请列表
                if (pack.uuid != Game.GetInstance().LocalPlayerID.obj_idx)
                {
                    ApplyList.Clear();
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_APPLY_INFO_CHANGED, null);

                    PkgTeamMember member = GetMember(pack.uuid);
                    if (member != null)
                    {
                        string msg = string.Format(DBConstText.GetText("TEAM_PROMOTE_TIPS"), System.Text.Encoding.UTF8.GetString(member.brief.name));
                        UINotice.Instance.ShowMessage(msg);
                        ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_SYSTEM_MESSAGE_SHOW, new CEventBaseArgs(msg));
                    }
                }
                else
                {
                    string msg = DBConstText.GetText("TEAM_ME_PROMOTE_TIPS");
                    UINotice.Instance.ShowMessage(msg);
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_SYSTEM_MESSAGE_SHOW, new CEventBaseArgs(msg));

                    mIsAutoMatchingPlayer = false;

                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_AUTO_MATCHING_STATE_CHANGED, null);
                }

                break;
            }

            case NetMsg.MSG_TEAM_INVITE:
            {
                S2CTeamInvite pack = S2CPackBase.DeserializePack <S2CTeamInvite>(data);

                if (pack.type > 0)
                {
                    UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("TEAM_HAVE_INVITED"), System.Text.Encoding.UTF8.GetString(pack.name)));
                }

                AddInviteCD(pack.uuid);

                break;
            }

            case NetMsg.MSG_TEAM_BE_INVITE:
            {
                S2CTeamBeInvite pack = S2CPackBase.DeserializePack <S2CTeamBeInvite>(data);

                if (IsAutoRejectInvite == true)
                {
                    HandleInvite(2, pack.team_id, 1);
                    break;
                }

                bool existing = false;
                foreach (S2CTeamBeInvite teamBeInvite in BeInvitedInfos)
                {
                    if (teamBeInvite.team_id == pack.team_id)
                    {
                        existing = true;
                    }
                }
                if (existing == false)
                {
                    BeInvitedInfos.Add(pack);
                }

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_BE_INVITED, null);

                break;
            }

            case NetMsg.MSG_TEAM_HANDLE_INVITE:
            {
                S2CTeamHandleInvite pack = S2CPackBase.DeserializePack <S2CTeamHandleInvite>(data);

                if (pack.choice == 2)
                {
                    // 对方已设置本次登录不再接收邀请
                    if (pack.type == 1)
                    {
                        UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("TEAM_AUTO_REJECT_TIPS"), System.Text.Encoding.UTF8.GetString(pack.name)));
                    }
                    else
                    {
                        UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("TEAM_REJECT_INVITE"), System.Text.Encoding.UTF8.GetString(pack.name)));
                    }
                }

                break;
            }

            case NetMsg.MSG_TEAM_INTRO:
            {
                S2CTeamIntro pack = S2CPackBase.DeserializePack <S2CTeamIntro>(data);

                break;
            }

            case NetMsg.MSG_TEAM_TARGET:
            {
                S2CTeamTarget pack = S2CPackBase.DeserializePack <S2CTeamTarget>(data);

                TargetId       = pack.target_id;
                TargetMinLevel = pack.min_lv;
                TargetMaxLevel = pack.max_lv;

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_TARGET_CHANGED, null);

                break;
            }

            case NetMsg.MSG_TEAM_MEMBER_INFO:
            {
                S2CTeamMemberInfo pack = S2CPackBase.DeserializePack <S2CTeamMemberInfo>(data);

                PkgTeamMember member = GetMember(pack.uuid);
                if (member != null)
                {
                    member.dungeon_id = pack.dungeon_id;
                    member.brief      = pack.info;
                }

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_TEAM_INFO_CHANGED, null);

                break;
            }

            case NetMsg.MSG_TEAM_SET_MATCH:
            {
                S2CTeamSetMatch pack = S2CPackBase.DeserializePack <S2CTeamSetMatch>(data);

                if (pack.auto_match == 0)
                {
                    IsAutoMatchingPlayer = false;
                }
                else
                {
                    IsAutoMatchingPlayer = true;
                }

                break;
            }

            case NetMsg.MSG_TEAM_NEARBY_USER:
            {
                S2CTeamNearbyUser pack = S2CPackBase.DeserializePack <S2CTeamNearbyUser>(data);

                break;
            }

            case NetMsg.MSG_TEAM_ERROR:
            {
                S2CTeamError pack = S2CPackBase.DeserializePack <S2CTeamError>(data);

                PkgTeamMember member = GetMember(pack.uuid);
                if (member != null)
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("INSTANCE_CAN_NOT_START_INSTANCE") + xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_83") + GameConst.COLOR_DARK_RED + System.Text.Encoding.UTF8.GetString(member.brief.name) + xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_42") + DBErrorCode.GetErrorString(pack.err_code));
                }

                ui.ugui.UIManager.Instance.ShowWaitScreen(false);

                break;
            }

            default: break;
            }
        }