Exemplo n.º 1
0
 public void SendSpouseDataToClient(GameClient client)
 {
     try
     {
         if (-1 != client.ClientData.MyMarriageData.nSpouseID)
         {
             MarriageData_EX myMarriageData_EX = new MarriageData_EX();
             GameClient      Spouseclient      = GameManager.ClientMgr.FindClient(client.ClientData.MyMarriageData.nSpouseID);
             if (null != Spouseclient)
             {
                 myMarriageData_EX.myMarriageData = Spouseclient.ClientData.MyMarriageData;
                 myMarriageData_EX.roleName       = Spouseclient.ClientData.RoleName;
                 myMarriageData_EX.Occupation     = Spouseclient.ClientData.OccupationList[0];
                 client.sendCmd <MarriageData_EX>(896, myMarriageData_EX, false);
             }
             else
             {
                 RoleDataEx roleDataEx = MarryLogic.GetOfflineRoleData(client.ClientData.MyMarriageData.nSpouseID);
                 if (roleDataEx != null)
                 {
                     myMarriageData_EX.roleName       = roleDataEx.RoleName;
                     myMarriageData_EX.Occupation     = roleDataEx.OccupationList[0];
                     myMarriageData_EX.myMarriageData = roleDataEx.MyMarriageData;
                     client.sendCmd <MarriageData_EX>(896, myMarriageData_EX, false);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "SendSpouseDataToClient", false, false);
     }
 }
Exemplo n.º 2
0
        public static string GetRoleName(int roleID)
        {
            // 角色不在线读数据库
            RoleDataEx roleDataEx = GetOfflineRoleData(roleID);

            return((roleDataEx != null)? roleDataEx.RoleName : "");
        }
Exemplo n.º 3
0
        public static bool IsMarried(int roleID)
        {
            RoleDataEx roleDataEx = MarryLogic.GetOfflineRoleData(roleID);

            if (roleDataEx != null && roleDataEx.MyMarriageData != null)
            {
                if (roleDataEx.MyMarriageData.byMarrytype != -1)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 刷新雕像
        /// </summary>
        /// <param name="manStatue"></param>
        /// <param name="wifeStatue"></param>
        private void ReshowCoupleStatue(RoleDataEx manStatue, RoleDataEx wifeStatue)
        {
            NPC manNpc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.CoupleWishMan);

            if (null != manNpc)
            {
                if (manStatue == null)
                {
                    manNpc.ShowNpc = true;
                    GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, manNpc);
                    FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishMan, true);
                }
                else
                {
                    manNpc.ShowNpc = false;
                    GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, manNpc);
                    FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishMan, true);
                    SafeClientData clientData = new SafeClientData();
                    clientData.RoleData = manStatue;
                    FakeRoleManager.ProcessNewFakeRole(clientData, manNpc.MapCode, FakeRoleTypes.CoupleWishMan, (int)manNpc.CurrentDir, (int)manNpc.CurrentPos.X, (int)manNpc.CurrentPos.Y, FakeRoleNpcId.CoupleWishMan);
                }
            }

            NPC wifeNpc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.CoupleWishWife);

            if (null != wifeNpc)
            {
                if (wifeStatue == null)
                {
                    // wifeNpc.ShowNpc = true;
                    // GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, wifeNpc);

                    wifeNpc.ShowNpc = true;
                    GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, wifeNpc);
                    FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishWife, true);
                }
                else
                {
                    wifeNpc.ShowNpc = false;
                    GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, wifeNpc);
                    FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishWife, true);
                    SafeClientData clientData = new SafeClientData();
                    clientData.RoleData = wifeStatue;
                    FakeRoleManager.ProcessNewFakeRole(clientData, wifeNpc.MapCode, FakeRoleTypes.CoupleWishWife, (int)wifeNpc.CurrentDir, (int)wifeNpc.CurrentPos.X, (int)wifeNpc.CurrentPos.Y, FakeRoleNpcId.CoupleWishWife);
                }
            }
        }
Exemplo n.º 5
0
        public void ReplacePKKingNpc(int roleId)
        {
            RoleDataEx rd = this.KingRoleData;

            this.KingRoleData = null;
            if (rd == null || rd.RoleID != roleId)
            {
                rd = Global.sendToDB <RoleDataEx, KingRoleGetData>(13230, new KingRoleGetData
                {
                    KingType = 1
                }, 0);
                if (rd == null || rd.RoleID != roleId)
                {
                    RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, roleId), 0);
                    if (dbRd == null || dbRd.RoleID <= 0)
                    {
                        return;
                    }
                    rd = dbRd;
                    if (!Global.sendToDB <bool, KingRolePutData>(13231, new KingRolePutData
                    {
                        KingType = 1,
                        RoleDataEx = rd
                    }, 0))
                    {
                    }
                }
            }
            if (rd != null && rd.RoleID > 0)
            {
                this.KingRoleData = rd;
                NPC npc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.PkKing);
                if (null != npc)
                {
                    npc.ShowNpc = false;
                    GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, npc);
                    FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.DiaoXiang, false);
                    FakeRoleManager.ProcessNewFakeRole(new SafeClientData
                    {
                        RoleData = rd
                    }, npc.MapCode, FakeRoleTypes.DiaoXiang, 4, (int)npc.CurrentPos.X, (int)npc.CurrentPos.Y, FakeRoleNpcId.PkKing);
                }
            }
        }
Exemplo n.º 6
0
        private void HandleGet(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            KingRoleGetData data = DataHelper.BytesToObject <KingRoleGetData>(cmdParams, 0, count);
            string          sql  = string.Format("SELECT roledata_ex FROM t_king_role_data WHERE king_type={0}", data.KingType);

            using (MyDbConnection3 conn = new MyDbConnection3(false))
            {
                MySQLDataReader reader = conn.ExecuteReader(sql, new MySQLParameter[0]);
                RoleDataEx      rd     = new RoleDataEx
                {
                    RoleID = -1
                };
                if (reader.Read())
                {
                    string s = new ASCIIEncoding().GetString((byte[])reader["roledata_ex"]);
                    byte[] d = Convert.FromBase64String(s);
                    rd = DataHelper.BytesToObject <RoleDataEx>(d, 0, d.Length);
                }
                client.sendCmd <RoleDataEx>(nID, rd);
            }
        }
Exemplo n.º 7
0
        private void _HandleChangeNameEv()
        {
            List <Tuple <int, string, string> > changeNameLst = null;

            lock (this._ChangeNameEvQ)
            {
                changeNameLst = this._ChangeNameEvQ.ToList <Tuple <int, string, string> >();
                this._ChangeNameEvQ.Clear();
            }
            if (changeNameLst != null && changeNameLst.Count != 0)
            {
                foreach (Tuple <int, string, string> ev in changeNameLst)
                {
                    int        roleId  = ev.Item1;
                    string     oldName = ev.Item2;
                    string     newName = ev.Item3;
                    RoleDataEx rd      = this.KingRoleData;
                    if (rd != null && rd.RoleID == roleId)
                    {
                        rd.RoleName = newName;
                        if (!Global.sendToDB <bool, KingRolePutData>(13231, new KingRolePutData
                        {
                            KingType = 1,
                            RoleDataEx = rd
                        }, 0))
                        {
                        }
                        this.KingRoleData = null;
                        this.ReShowPKKing();
                    }
                    if (!string.IsNullOrEmpty(this.TheKingOfPKTopRoleName) && this.TheKingOfPKTopRoleName == oldName)
                    {
                        this.TheKingOfPKTopRoleName = newName;
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 发送情侣数据给客户端
        /// </summary>
        public void SendSpouseDataToClient(GameClient client)
        {
            try
            {
                if (-1 != client.ClientData.MyMarriageData.nSpouseID)
                {
                    MarriageData_EX myMarriageData_EX = new MarriageData_EX();
                    GameClient      Spouseclient      = GameManager.ClientMgr.FindClient(client.ClientData.MyMarriageData.nSpouseID);

                    //在线情况
                    if (null != Spouseclient)
                    {
                        myMarriageData_EX.myMarriageData = Spouseclient.ClientData.MyMarriageData;
                        myMarriageData_EX.roleName       = Spouseclient.ClientData.RoleName;
                        myMarriageData_EX.Occupation     = Spouseclient.ClientData.Occupation;
                        client.sendCmd <MarriageData_EX>((int)TCPGameServerCmds.CMD_SPR_MARRY_SPOUSE_DATA, myMarriageData_EX);
                    }
                    else //不在线情况
                    {
                        RoleDataEx roleDataEx = MarryLogic.GetOfflineRoleData(client.ClientData.MyMarriageData.nSpouseID);
                        if (roleDataEx != null)
                        {
                            myMarriageData_EX.roleName       = roleDataEx.RoleName;
                            myMarriageData_EX.Occupation     = roleDataEx.Occupation;
                            myMarriageData_EX.myMarriageData = roleDataEx.MyMarriageData;
                            //将结婚信息和配偶名称职业一起发过去
                            client.sendCmd <MarriageData_EX>((int)TCPGameServerCmds.CMD_SPR_MARRY_SPOUSE_DATA, myMarriageData_EX);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "SendSpouseDataToClient", false);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 设置雕像
        /// </summary>
        /// <param name="newStatue"></param>
        public void SetDiaoXiang(CoupleWishSyncStatueData newStatue)
        {
            if (newStatue.DbCoupleId > 0 &&
                (newStatue.ManRoleDataEx == null || newStatue.WifeRoleDataEx == null))
            {
                // 把第一名情侣的雕像形象数据上传到中心
                // 雕像数据非常大,有100K+,所以在祝福的时候不传到中心,然后每个服务器自行检测上周的第一名是否有雕像数据,如果没有,那么则尝试上报雕像数据
                // 第一名所在的服务器上报之后,其余服务器就能同步到雕像数据了
                SafeClientData manClientData  = Global.GetSafeClientDataFromLocalOrDB(newStatue.Man.RoleId);
                SafeClientData wifeClientData = Global.GetSafeClientDataFromLocalOrDB(newStatue.Wife.RoleId);
                RoleDataEx     manRoleDataEx  = manClientData != null?manClientData.GetRoleDataEx() : null;

                RoleDataEx wifeRoleDataEx = wifeClientData != null?wifeClientData.GetRoleDataEx() : null;

                if (manRoleDataEx != null && wifeRoleDataEx != null)
                {
                    CoupleWishReportStatueData statueReq = new CoupleWishReportStatueData();
                    statueReq.DbCoupleId = newStatue.DbCoupleId;
                    statueReq.ManStatue  = DataHelper.ObjectToBytes <RoleDataEx>(manRoleDataEx);
                    statueReq.WifeStatue = DataHelper.ObjectToBytes <RoleDataEx>(wifeRoleDataEx);
                    TianTiClient.getInstance().CoupleWishReportCoupleStatue(statueReq);
                }
            }

            if (newStatue.DbCoupleId > 0 &&
                newStatue.ManRoleDataEx != null && newStatue.WifeRoleDataEx != null)
            {
                if (newStatue.IsDivorced == 1) // 强制不可显示雕像。离婚了呗
                {
                    ReshowCoupleStatue(null, null);
                }
                else
                {
                    if (_Statue == null ||
                        _Statue.ManRoleDataEx == null || _Statue.WifeRoleDataEx == null ||
                        _Statue.DbCoupleId != newStatue.DbCoupleId)
                    {
                        ReshowCoupleStatue(DataHelper.BytesToObject <RoleDataEx>(newStatue.ManRoleDataEx, 0, newStatue.ManRoleDataEx.Length),
                                           DataHelper.BytesToObject <RoleDataEx>(newStatue.WifeRoleDataEx, 0, newStatue.WifeRoleDataEx.Length));
                    }
                }
            }
            else
            {
                ReshowCoupleStatue(null, null);
            }

            NPC npc = NPCGeneralManager.GetNPCFromConfig(YanHuiMapCode, YanHuiNpcId, YanHuiNpcX, YanHuiNpcY, YanHuiNpcDir);

            if (newStatue.DbCoupleId > 0 &&
                null != npc && (_Statue == null || _Statue.DbCoupleId != newStatue.DbCoupleId) &&
                newStatue.YanHuiJoinNum < _Config.YanHuiCfg.TotalMaxJoinNum)
            {
                NPCGeneralManager.AddNpcToMap(npc);
            }

            if (newStatue.DbCoupleId <= 0 || newStatue.YanHuiJoinNum >= _Config.YanHuiCfg.TotalMaxJoinNum)
            {
                NPCGeneralManager.RemoveMapNpc(YanHuiMapCode, YanHuiNpcId);
            }

            _Statue = newStatue;
        }
Exemplo n.º 10
0
        public static string GetRoleName(int roleID)
        {
            RoleDataEx roleDataEx = MarryLogic.GetOfflineRoleData(roleID);

            return((roleDataEx != null) ? roleDataEx.RoleName : "");
        }
Exemplo n.º 11
0
        public static int GetSpouseID(int roleID)
        {
            RoleDataEx roleDataEx = MarryLogic.GetOfflineRoleData(roleID);

            return((roleDataEx != null && roleDataEx.MyMarriageData != null) ? roleDataEx.MyMarriageData.nSpouseID : -1);
        }
Exemplo n.º 12
0
        public void PushGameResultData(KarenBattleScene scene)
        {
            JunTuanRankData rankData = this.GetJunTuanRankDataBySide(scene.SuccessSide);

            if (null != rankData)
            {
                JunTuanBaseData baseData = JunTuanManager.getInstance().GetJunTuanBaseDataByJunTuanID(rankData.JunTuanId);
                if (null == baseData)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取军团基本信息 JunTuanId={0}", rankData.JunTuanId), null, true);
                }
                else if (baseData.BhList == null || baseData.BhList.Count == 0)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("军团基本信息BhList为空 JunTuanId={0}", rankData.JunTuanId), null, true);
                }
                else
                {
                    int               leaderBangHui  = baseData.BhList[0];
                    int               leaderServerID = 0;
                    SceneUIClasses    mapType        = Global.GetMapSceneType(scene.m_nMapCode);
                    int               lingDiType     = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType);
                    LingDiData        oldLingDiData  = null;
                    List <LingDiData> LingDiList     = JunTuanClient.getInstance().GetLingDiData();
                    if (null != LingDiList)
                    {
                        oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType);
                    }
                    RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null;
                    lock (this.Mutex)
                    {
                        if (!this.FactionIDVsServerIDDict.TryGetValue(leaderBangHui, out leaderServerID))
                        {
                            JunTuanData data = JunTuanClient.getInstance().GetJunTuanData(leaderBangHui, rankData.JunTuanId, true);
                            if (null == data)
                            {
                                LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取JunTuanData BangHuiID={0} JunTuanId={1}", leaderBangHui, rankData.JunTuanId), null, true);
                                return;
                            }
                            LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, data.LeaderRoleId, rankData.JunTuanId, rankData.JunTuanName, null);
                            EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, data.LeaderZoneId, rankData.JunTuanId, data.LeaderRoleId);
                            return;
                        }
                    }
                    BangHuiDetailData bhData = Global.GetBangHuiDetailData(-1, leaderBangHui, leaderServerID);
                    if (null == bhData)
                    {
                        LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮会详细信息 BangHuiID={0} ServerID={1}", leaderBangHui, leaderServerID), null, true);
                    }
                    else
                    {
                        RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, bhData.BZRoleID), leaderServerID);
                        if (dbRd == null || dbRd.RoleID <= 0)
                        {
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮主详细信息 BangHuiID={0} BZRoleID={1} ServerID={2}", leaderBangHui, bhData.BZRoleID, leaderServerID), null, true);
                        }
                        else
                        {
                            JunTuanManager.getInstance().OnInitGame(dbRd);
                            RoleData4Selector leaderShowInfo = Global.RoleDataEx2RoleData4Selector(dbRd);
                            LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, dbRd.RoleID, rankData.JunTuanId, rankData.JunTuanName, leaderShowInfo);
                            EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, dbRd.ZoneID, rankData.JunTuanId, dbRd.RoleID);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
 public void ClearDbKingNpc()
 {
     this.KingRoleData = null;
     Global.sendToDB <bool, string>(13232, string.Format("{0}", 1), 0);
 }