public static void ProcessDailyActiveKillMonster(GameClient killer, Monster victim)
 {
     if (DailyActiveManager.CheckLevCondition(killer, 1300) || DailyActiveManager.CheckLevCondition(killer, 1301) || DailyActiveManager.CheckLevCondition(killer, 1302))
     {
         killer.ClientData.DailyTotalKillMonsterNum += 1U;
         SafeClientData clientData = killer.ClientData;
         clientData.TimerKilledMonsterNum += 1;
         if (killer.ClientData.TimerKilledMonsterNum > 20)
         {
             killer.ClientData.TimerKilledMonsterNum = 0;
             DailyActiveManager.ModifyDailyActiveInfor(killer, killer.ClientData.DailyTotalKillMonsterNum, DailyActiveDataField1.DailyActiveTotalKilledMonsterNum, false);
         }
         DailyActiveManager.CheckDailyActiveKillMonster(killer);
         if (401 == victim.MonsterType)
         {
             for (int i = 0; i < Data.KillBossCountForChengJiu.Length; i++)
             {
                 if (victim.MonsterInfo.ExtensionID == Data.KillBossCountForChengJiu[i])
                 {
                     DailyActiveManager.CheckDailyActiveKillBoss(killer);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public static void OnChangeName(int roleId, string oldName, string newName)
        {
            if (string.IsNullOrEmpty(oldName) || string.IsNullOrEmpty(newName))
            {
                return;
            }

            SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);

            // 未婚不处理
            if (clientData == null ||
                clientData.MyMarriageData == null ||
                clientData.MyMarriageData.nSpouseID == -1)
            {
                return;
            }

            // 把我的信息重新发给我的配偶
            GameClient spouseClient = GameManager.ClientMgr.FindClient(clientData.MyMarriageData.nSpouseID);

            if (spouseClient != null)
            {
                // 我改名了,要通知我的配偶
                MarriageOtherLogic.getInstance().SendSpouseDataToClient(spouseClient);
            }

            MarryPartyLogic.getInstance().OnChangeName(roleId, oldName, newName);
        }
Esempio n. 3
0
        /// <summary>
        /// 处理添加假人
        /// </summary>
        public static int ProcessNewFakeRole(SafeClientData clientData, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1)
        {
            int mapCode = clientData.MapCode;

            if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID离线挂机时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID));
                return(-1);
            }

            //删除一个假人数据
            RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType);

            //添加一个新的假人数据
            FakeRoleItem fakeRoleItem = AddFakeRole(clientData, fakeRoleType);

            if (null == fakeRoleItem)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID));
                return(-1);
            }

            if (toPosX >= 0 && toPosY >= 0)
            {
                fakeRoleItem.MyRoleDataMini.PosX = toPosX;
                fakeRoleItem.MyRoleDataMini.PosY = toPosY;
            }

            if (direction >= 0)
            {
                fakeRoleItem.MyRoleDataMini.RoleDirection = direction;
            }

            if (ToExtensionID >= 0)
            {
                fakeRoleItem.ToExtensionID = ToExtensionID;
            }

            if (FakeRoleTypes.LiXianGuaJi == fakeRoleType)
            {
                if (clientData.OfflineMarketState <= 0)
                {
                    fakeRoleItem.MyRoleDataMini.StallName = "";
                }
            }

            fakeRoleItem.MyRoleDataMini.LifeV  = Math.Max(1, clientData.LifeV);
            fakeRoleItem.MyRoleDataMini.MagicV = Math.Max(1, clientData.MagicV);

            GameManager.MapGridMgr.DictGrids[clientData.MapCode].MoveObject(-1, -1, (int)fakeRoleItem.MyRoleDataMini.PosX, (int)fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem);

            //List<Object> objList = Global.GetAll9Clients(FakeRoleItem);
            //GameManager.ClientMgr.NotifyOthersNewFakeRole(sl, pool, objList, FakeRoleItem);

            return(fakeRoleItem.FakeRoleID);
        }
Esempio n. 4
0
        public void OnChangeName(int roleId, string oldName, string newName)
        {
            if (string.IsNullOrEmpty(oldName) || string.IsNullOrEmpty(newName))
            {
                return;
            }

            // 未婚,应该没有婚宴数据,如果申请了婚宴,然后离婚,需要确认是否删除婚宴数据
            SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);

            if (clientData == null ||
                clientData.MyMarriageData == null ||
                clientData.MyMarriageData.nSpouseID == -1)
            {
                return;
            }

            // 修改我或者我的配偶举办的婚宴
            lock (MarryPartyList)
            {
                MarryPartyData data = null;

                // 我举办的婚宴
                MarryPartyList.TryGetValue(clientData.RoleID, out data);
                if (data != null)
                {
                    if (!string.IsNullOrEmpty(data.HusbandName) && data.HusbandName == oldName)
                    {
                        data.HusbandName = newName;
                    }
                    else if (!string.IsNullOrEmpty(data.WifeName) && data.WifeName == oldName)
                    {
                        data.WifeName = newName;
                    }
                }

                // 我的配偶举办的婚宴
                data = null;
                MarryPartyList.TryGetValue(clientData.MyMarriageData.nSpouseID, out data);
                if (data != null)
                {
                    if (!string.IsNullOrEmpty(data.HusbandName) && data.HusbandName == oldName)
                    {
                        data.HusbandName = newName;
                    }
                    else if (!string.IsNullOrEmpty(data.WifeName) && data.WifeName == oldName)
                    {
                        data.WifeName = newName;
                    }
                }
            }
        }
Esempio n. 5
0
 public void UnionDataChange(int unionID, int serverID, bool isDel = false, int unionLevel = 0)
 {
     if (!KuaFuManager.KuaFuWorldKuaFuGameServer)
     {
         if (unionID > 0)
         {
             if (isDel)
             {
                 if (this.IsAllyOpen(unionLevel))
                 {
                     EAlly result = AllyClient.getInstance().HUnionDel(unionID);
                     if (result != EAlly.Succ)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:战盟{0}解散失败 id={1}", unionID, result), null, true);
                     }
                 }
             }
             else
             {
                 BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, serverID);
                 if (unionData != null && this.IsAllyOpen(unionData.QiLevel))
                 {
                     AllyData data = new AllyData();
                     data.UnionID     = unionData.BHID;
                     data.UnionZoneID = unionData.ZoneID;
                     data.UnionName   = unionData.BHName;
                     data.UnionLevel  = unionData.QiLevel;
                     data.UnionNum    = unionData.TotalNum;
                     data.LeaderID    = unionData.BZRoleID;
                     data.LeaderName  = unionData.BZRoleName;
                     SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(data.LeaderID);
                     if (null != clientData)
                     {
                         data.LeaderZoneID = clientData.ZoneID;
                     }
                     else
                     {
                         data.LeaderZoneID = unionData.ZoneID;
                     }
                     EAlly result = AllyClient.getInstance().HUnionDataChange(data);
                     if (result != EAlly.Succ)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:战盟数据变更失败 id={0}", result), null, true);
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
 public static void OnChangeName(int roleId, string oldName, string newName)
 {
     if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName))
     {
         SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);
         if (clientData != null && clientData.MyMarriageData != null && clientData.MyMarriageData.nSpouseID != -1)
         {
             GameClient spouseClient = GameManager.ClientMgr.FindClient(clientData.MyMarriageData.nSpouseID);
             if (spouseClient != null)
             {
                 MarriageOtherLogic.getInstance().SendSpouseDataToClient(spouseClient);
             }
             MarryPartyLogic.getInstance().OnChangeName(roleId, oldName, newName);
         }
     }
 }
Esempio n. 7
0
        public static RoleDataEx GetOfflineRoleData(int roleID)
        {
            GameClient client = GameManager.ClientMgr.FindClient(roleID);
            RoleDataEx result;

            if (null != client)
            {
                result = client.ClientData.GetRoleData();
            }
            else
            {
                SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleID);
                result = ((clientData != null) ? clientData.GetRoleData() : null);
            }
            return(result);
        }
Esempio n. 8
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);
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 重新恢复显示PK之王
        /// </summary>
        public void ReShowPKKing()
        {
            int roleID = GetPKKingRoleID();

            if (roleID <= 0)
            {
                return;
            }

            SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleID);

            if (null != clientData)
            {
                //替换PK之王的npc显示
                Global.ReplacePKKingNpc(clientData);
            }
        }
Esempio n. 10
0
 public void UnionLeaderChangName(int roleId, string oldName, string newName)
 {
     if (!KuaFuManager.KuaFuWorldKuaFuGameServer)
     {
         if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName))
         {
             SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);
             if (clientData != null && clientData.Faction > 0)
             {
                 BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, clientData.Faction, GameManager.ServerId);
                 if (roleId == unionData.BZRoleID)
                 {
                     this.UnionDataChange(clientData.Faction, GameManager.ServerId, false, 0);
                 }
             }
         }
     }
 }
Esempio n. 11
0
        private static FakeRoleItem AddFakeRole(SafeClientData clientData, FakeRoleTypes fakeRoleType)
        {
            FakeRoleItem fakeRoleItem = new FakeRoleItem
            {
                FakeRoleID     = (int)GameManager.FakeRoleIDMgr.GetNewID(),
                FakeRoleType   = (int)fakeRoleType,
                MyRoleDataMini = Global.ClientDataToRoleDataMini(clientData)
            };

            lock (FakeRoleManager._ID2FakeRoleDict)
            {
                FakeRoleManager._ID2FakeRoleDict[fakeRoleItem.FakeRoleID] = fakeRoleItem;
            }
            string roleID_Type = string.Format("{0}_{1}", fakeRoleItem.MyRoleDataMini.RoleID, (int)fakeRoleType);

            lock (FakeRoleManager._RoleIDType2FakeRoleDict)
            {
                FakeRoleManager._RoleIDType2FakeRoleDict[roleID_Type] = fakeRoleItem;
            }
            return(fakeRoleItem);
        }
Esempio n. 12
0
 public void OnChangeName(int roleId, string oldName, string newName)
 {
     if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName))
     {
         SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);
         if (clientData != null && clientData.MyMarriageData != null && clientData.MyMarriageData.nSpouseID != -1)
         {
             lock (this.MarryPartyList)
             {
                 MarryPartyData data = null;
                 this.MarryPartyList.TryGetValue(clientData.RoleID, out data);
                 if (data != null)
                 {
                     if (!string.IsNullOrEmpty(data.HusbandName) && data.HusbandName == oldName)
                     {
                         data.HusbandName = newName;
                     }
                     else if (!string.IsNullOrEmpty(data.WifeName) && data.WifeName == oldName)
                     {
                         data.WifeName = newName;
                     }
                 }
                 data = null;
                 this.MarryPartyList.TryGetValue(clientData.MyMarriageData.nSpouseID, out data);
                 if (data != null)
                 {
                     if (!string.IsNullOrEmpty(data.HusbandName) && data.HusbandName == oldName)
                     {
                         data.HusbandName = newName;
                     }
                     else if (!string.IsNullOrEmpty(data.WifeName) && data.WifeName == oldName)
                     {
                         data.WifeName = newName;
                     }
                 }
             }
         }
     }
 }
Esempio n. 13
0
        public void UnionLeaderChangName(int roleId, string oldName, string newName)
        {
            if (string.IsNullOrEmpty(oldName) || string.IsNullOrEmpty(newName))
            {
                return;
            }

            SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);

            if (clientData == null || clientData.Faction <= 0)
            {
                return;
            }

            BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, clientData.Faction, GameManager.ServerId);

            if (roleId != unionData.BZRoleID)
            {
                return;
            }

            UnionDataChange(clientData.Faction, GameManager.ServerId);
        }
Esempio n. 14
0
        /// <summary>
        /// 将ClientData 类型转换为 TeamMemberData类型(组队时使用)
        /// </summary>
        /// <param name="clientData"></param>
        /// <returns></returns>
        public CopyTeamMemberData ClientDataToTeamMemberData(SafeClientData clientData)
        {
            CopyTeamMemberData teamMemberData = new CopyTeamMemberData()
            {
                RoleID        = clientData.RoleID,
                RoleName      = Global.FormatRoleName2(clientData, clientData.RoleName),
                RoleSex       = clientData.RoleSex,
                Level         = clientData.Level,
                Occupation    = clientData.Occupation,
                RolePic       = clientData.RolePic,
                MapCode       = clientData.MapCode,
                OnlineState   = 1,
                MaxLifeV      = clientData.LifeV,
                CurrentLifeV  = clientData.CurrentLifeV,
                MaxMagicV     = clientData.MagicV,
                CurrentMagicV = clientData.CurrentMagicV,
                PosX          = clientData.PosX,
                PosY          = clientData.PosY,
                CombatForce   = clientData.CombatForce,
                ChangeLifeLev = clientData.ChangeLifeCount,
            };

            return(teamMemberData);
        }
Esempio n. 15
0
        private TradeBlackObject LoadTradeBlackObject(int roleid, bool loadDbIfNotExist = true)
        {
            DateTime         now = TimeUtil.NowDateTime();
            TradeBlackObject obj = null;
            int offsetDay        = Global.GetOffsetDay(TimeUtil.NowDateTime());

            lock (TradeBlackObjs)
            {
                if (TradeBlackObjs.TryGetValue(roleid, out obj))
                {
                    obj.LastFlushTime = now;
                }
            }

            if (obj == null && loadDbIfNotExist)
            {
                string reqCmd = string.Format("{0}:{1}:{2}", roleid, now.ToString("yyyy-MM-dd"), now.Hour);
                List <TradeBlackHourItem> items = Global.sendToDB <List <TradeBlackHourItem>, string>(
                    (int)TCPGameServerCmds.CMD_DB_LOAD_TRADE_BLACK_HOUR_ITEM, reqCmd, GameManager.LocalServerId);

                obj               = new TradeBlackObject();
                obj.RoleId        = roleid;
                obj.LastFlushTime = now;
                obj.HourItems     = new TradeBlackHourItem[24];

                GameClient client = GameManager.ClientMgr.FindClient(roleid);
                if (client != null)
                {
                    obj.VipLevel        = client.ClientData.VipLevel;
                    obj.ChangeLife      = client.ClientData.ChangeLifeCount;
                    obj.Level           = client.ClientData.Level;
                    obj.BanTradeToTicks = client.ClientData.BanTradeToTicks;
                    obj.ZoneId          = client.ClientData.ZoneID;
                    obj.RoleName        = client.ClientData.RoleName;
                }
                else
                {
                    SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleid);
                    if (clientData != null)
                    {
                        obj.VipLevel        = Global.CalcVipLevelByZuanShi(Global.GetUserInputAllYuanBao(clientData.RoleID, clientData.RoleName, GameManager.LocalServerId));
                        obj.ChangeLife      = clientData.ChangeLifeCount;
                        obj.Level           = clientData.Level;
                        obj.BanTradeToTicks = clientData.BanTradeToTicks;
                        obj.ZoneId          = clientData.ZoneID;
                        obj.RoleName        = clientData.RoleName;
                    }
                }

                if (items != null)
                {
                    foreach (var item in items)
                    {
                        int idx = item.Hour % 24; // 哈哈,hour,必然在0 --- 24 范围内吧
                        obj.HourItems[idx] = item;
                        item.TradeRoles    = item.TradeRoles ?? new HashSet <int>();
                    }
                }

                // 防止多个线程同时都从数据库加载同一个人的信息
                lock (TradeBlackObjs)
                {
                    if (!TradeBlackObjs.ContainsKey(roleid))
                    {
                        TradeBlackObjs[roleid] = obj;
                    }
                    else
                    {
                        obj = TradeBlackObjs[roleid];
                    }
                }
            }

            return(obj);
        }
Esempio n. 16
0
        /// <summary>
        /// 处理添加假人
        /// </summary>
        public static int ProcessNewFakeRole(SafeClientData clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1)
        {
            if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID离线挂机时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID));
                return(-1);
            }

            //删除一个假人数据
            RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType);

            //添加一个新的假人数据
            FakeRoleItem fakeRoleItem = AddFakeRole(clientData, fakeRoleType);

            if (null == fakeRoleItem)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID));
                return(-1);
            }

            fakeRoleItem.MyRoleDataMini.MapCode = mapCode;

            if (toPosX >= 0 && toPosY >= 0)
            {
                fakeRoleItem.MyRoleDataMini.PosX = toPosX;
                fakeRoleItem.MyRoleDataMini.PosY = toPosY;
            }

            if (direction >= 0)
            {
                fakeRoleItem.MyRoleDataMini.RoleDirection = direction;
            }

            if (ToExtensionID >= 0)
            {
                fakeRoleItem.ToExtensionID = ToExtensionID;
            }

            if (FakeRoleTypes.LiXianGuaJi == fakeRoleType)
            {
                if (clientData.OfflineMarketState <= 0)
                {
                    fakeRoleItem.MyRoleDataMini.StallName = "";
                }
            }

            if (FakeRoleTypes.DiaoXiang2 == fakeRoleType)
            {
                if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams || fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count <= 0)
                {
                    int fashionID = 0;
                    foreach (var item in FashionManager.getInstance().RuntimeData.FashingDict.Values)
                    {
                        if (item.Type == (int)FashionTypes.LuoLanYuYi)
                        {
                            fashionID = item.ID;
                            break;
                        }
                    }
                    if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams)
                    {
                        fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams = new List <int>();
                    }

                    for (int i = fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count; i < (int)RoleCommonUseIntParamsIndexs.MaxCount; ++i)
                    {
                        fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Add(0);
                    }
                    fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[(int)RoleCommonUseIntParamsIndexs.FashionWingsID] = fashionID;
                }
            }

            fakeRoleItem.MyRoleDataMini.LifeV  = Math.Max(1, clientData.LifeV);
            fakeRoleItem.MyRoleDataMini.MagicV = Math.Max(1, clientData.MagicV);

            GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, (int)fakeRoleItem.MyRoleDataMini.PosX, (int)fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem);

            //List<Object> objList = Global.GetAll9Clients(FakeRoleItem);
            //GameManager.ClientMgr.NotifyOthersNewFakeRole(sl, pool, objList, FakeRoleItem);

            return(fakeRoleItem.FakeRoleID);
        }
Esempio n. 17
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;
        }
Esempio n. 18
0
        public static int ProcessNewFakeRole(SafeClientData clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1)
        {
            int result;

            if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID离线挂机时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID), null, true);
                result = -1;
            }
            else
            {
                FakeRoleManager.RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType);
                FakeRoleItem fakeRoleItem = FakeRoleManager.AddFakeRole(clientData, fakeRoleType);
                if (null == fakeRoleItem)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID), null, true);
                    result = -1;
                }
                else
                {
                    fakeRoleItem.MyRoleDataMini.MapCode = mapCode;
                    if (toPosX >= 0 && toPosY >= 0)
                    {
                        fakeRoleItem.MyRoleDataMini.PosX = toPosX;
                        fakeRoleItem.MyRoleDataMini.PosY = toPosY;
                    }
                    if (direction >= 0)
                    {
                        fakeRoleItem.MyRoleDataMini.RoleDirection = direction;
                    }
                    if (ToExtensionID >= 0)
                    {
                        fakeRoleItem.ToExtensionID = ToExtensionID;
                    }
                    if (FakeRoleTypes.LiXianGuaJi == fakeRoleType)
                    {
                        if (clientData.OfflineMarketState <= 0)
                        {
                            fakeRoleItem.MyRoleDataMini.StallName = "";
                        }
                    }
                    if (FakeRoleTypes.DiaoXiang2 == fakeRoleType)
                    {
                        if (fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams == null || fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count <= 0)
                        {
                            int fashionID = 0;
                            foreach (FashionData item in FashionManager.getInstance().RuntimeData.FashingDict.Values)
                            {
                                if (item.Type == 1)
                                {
                                    fashionID = item.ID;
                                    break;
                                }
                            }
                            if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams = new List <int>();
                            }
                            for (int i = fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count; i < 53; i++)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Add(0);
                            }
                            fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[26] = fashionID;
                        }
                    }
                    if (FakeRoleTypes.BangHuiMatchBZ == fakeRoleType || FakeRoleTypes.CompDaLingZhu_1 == fakeRoleType || FakeRoleTypes.CompDaLingZhu_2 == fakeRoleType || FakeRoleTypes.CompDaLingZhu_3 == fakeRoleType)
                    {
                        int fashionID = 0;
                        foreach (FashionData item in FashionManager.getInstance().RuntimeData.FashingDict.Values)
                        {
                            if (item.Type == 4)
                            {
                                fashionID = item.ID;
                                break;
                            }
                        }
                        if (fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams == null || fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count <= 0)
                        {
                            if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams = new List <int>();
                            }
                            for (int i = fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count; i < 53; i++)
                            {
                                fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Add(0);
                            }
                            fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[26] = fashionID;
                        }
                        else if (53 == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count)
                        {
                            fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[26] = fashionID;
                        }
                    }
                    fakeRoleItem.MyRoleDataMini.LifeV  = Math.Max(1, clientData.LifeV);
                    fakeRoleItem.MyRoleDataMini.MagicV = Math.Max(1, clientData.MagicV);
                    GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, fakeRoleItem.MyRoleDataMini.PosX, fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem);
                    result = fakeRoleItem.FakeRoleID;
                }
            }
            return(result);
        }
Esempio n. 19
0
        private TradeBlackObject LoadTradeBlackObject(int roleid, bool loadDbIfNotExist = true)
        {
            DateTime         now = TimeUtil.NowDateTime();
            TradeBlackObject obj = null;
            int offsetDay        = Global.GetOffsetDay(TimeUtil.NowDateTime());

            lock (this.TradeBlackObjs)
            {
                if (this.TradeBlackObjs.TryGetValue(roleid, out obj))
                {
                    obj.LastFlushTime = now;
                }
            }
            if (obj == null && loadDbIfNotExist)
            {
                string reqCmd = string.Format("{0}:{1}:{2}", roleid, now.ToString("yyyy-MM-dd"), now.Hour);
                List <TradeBlackHourItem> items = Global.sendToDB <List <TradeBlackHourItem>, string>(14007, reqCmd, 0);
                obj               = new TradeBlackObject();
                obj.RoleId        = roleid;
                obj.LastFlushTime = now;
                obj.HourItems     = new TradeBlackHourItem[24];
                GameClient client = GameManager.ClientMgr.FindClient(roleid);
                if (client != null)
                {
                    obj.VipLevel        = client.ClientData.VipLevel;
                    obj.ChangeLife      = client.ClientData.ChangeLifeCount;
                    obj.Level           = client.ClientData.Level;
                    obj.BanTradeToTicks = client.ClientData.BanTradeToTicks;
                    obj.ZoneId          = client.ClientData.ZoneID;
                    obj.RoleName        = client.ClientData.RoleName;
                }
                else
                {
                    SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleid);
                    if (clientData != null)
                    {
                        obj.VipLevel        = Global.CalcVipLevelByZuanShi(Global.GetUserInputAllYuanBao(clientData.RoleID, clientData.RoleName, 0));
                        obj.ChangeLife      = clientData.ChangeLifeCount;
                        obj.Level           = clientData.Level;
                        obj.BanTradeToTicks = clientData.BanTradeToTicks;
                        obj.ZoneId          = clientData.ZoneID;
                        obj.RoleName        = clientData.RoleName;
                    }
                }
                if (items != null)
                {
                    foreach (TradeBlackHourItem item in items)
                    {
                        int idx = item.Hour % 24;
                        obj.HourItems[idx] = item;
                        item.TradeRoles    = (item.TradeRoles ?? new HashSet <int>());
                    }
                }
                lock (this.TradeBlackObjs)
                {
                    if (!this.TradeBlackObjs.ContainsKey(roleid))
                    {
                        this.TradeBlackObjs[roleid] = obj;
                    }
                    else
                    {
                        obj = this.TradeBlackObjs[roleid];
                    }
                }
            }
            return(obj);
        }