Beispiel #1
0
        /// <summary>
        /// 重置世界等级
        /// </summary>
        public void ResetWorldLevel()
        {
            int dayID = TimeUtil.NowDateTime().DayOfYear;

            if (m_nResetWorldLevelDayID == dayID)
            {
                return;
            }

            TCPOutPacket         tcpOutPacket    = null;
            string               strcmd          = string.Format("{0}:{1}", 0, (int)PaiHangTypes.RoleLevel);
            TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, TCPOutPacketPool.getInstance(), (int)TCPGameServerCmds.CMD_SPR_GETPAIHANGLIST, strcmd, out tcpOutPacket, GameManager.LocalServerId);

            if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED)
            {
                LogManager.WriteLog(LogTypes.Error, "世界等级装入异常");
                return;
            }

            int nBakResetWorldLevelDayID = m_nResetWorldLevelDayID;

            m_nResetWorldLevelDayID = dayID;

            // 处理本地精简的好友列表数据
            PaiHangData paiHangData = DataHelper.BytesToObject <PaiHangData>(tcpOutPacket.GetPacketBytes(), 6, tcpOutPacket.PacketDataSize - 6);

            if (null != paiHangData)
            {
                int nLevelCount = 0;
                if (null != paiHangData.PaiHangList)
                {
                    for (int i = 0; i < 10 && i < paiHangData.PaiHangList.Count; i++)
                    {
                        nLevelCount += paiHangData.PaiHangList[i].Val2 * 100 + paiHangData.PaiHangList[i].Val1;
                    }
                }
                m_nWorldLevel = nLevelCount / 10;
            }
            else
            {
                LogManager.WriteLog(LogTypes.Error, "世界等级装入时,获取等级排行榜失败");
                return;
            }


            if (0 != nBakResetWorldLevelDayID)
            {
                int count = GameManager.ClientMgr.GetMaxClientCount();
                for (int i = 0; i < count; i++)
                {
                    GameClient client = GameManager.ClientMgr.FindClientByNid(i);
                    if (null != client)
                    {
                        UpddateWorldLevelBuff(client);
                    }
                }
            }
        }
Beispiel #2
0
        private void GenerateThemeBossScene()
        {
            int curDayID = TimeUtil.GetOffsetDay(TimeUtil.NowDateTime());

            if (curDayID != this.SceneDayID)
            {
                this.SceneDict.Clear();
                string strcmd = StringUtil.substitute("{0}:{1}:{2}", new object[]
                {
                    0,
                    5,
                    100
                });
                PaiHangData paiHangData = Global.sendToDB <PaiHangData, string>(269, strcmd, 0);
                if (null != paiHangData)
                {
                    long NumOne = 0L;
                    long NumTwo = 0L;
                    List <PaiHangItemData> PaiHangList = paiHangData.PaiHangList;
                    if (null != PaiHangList)
                    {
                        int DivCalNum = Math.Min(PaiHangList.Count, 100);
                        for (int i = 0; i < DivCalNum; i++)
                        {
                            PaiHangItemData phData = PaiHangList[i];
                            NumOne += (long)phData.Val1;
                            NumTwo += (long)phData.Val2;
                        }
                        int TransNum = Global.GetUnionLevel2((int)NumTwo, (int)NumOne) / DivCalNum;
                        NumOne = (long)((TransNum - 1) / 100);
                        NumTwo = (long)((TransNum - 1) % 100 + 1);
                    }
                    int curAvgLev = Global.GetUnionLevel2((int)NumTwo, (int)NumOne);
                    foreach (ThemeBossConfig config in this.ThemeBossConfigDict.Values)
                    {
                        if (curAvgLev <= config.MaxUnionLevel)
                        {
                            ThemeBossScene scene = null;
                            if (!this.SceneDict.TryGetValue(config.MapCode, out scene))
                            {
                                scene                          = new ThemeBossScene();
                                scene.MapCode                  = config.MapCode;
                                scene.BossConfigInfo           = config;
                                scene.State                    = BattleStates.NoBattle;
                                this.SceneDict[config.MapCode] = scene;
                            }
                            if (scene.BossConfigInfo.MaxUnionLevel > config.MaxUnionLevel)
                            {
                                scene.BossConfigInfo = config;
                            }
                        }
                    }
                    this.SceneDayID = curDayID;
                }
            }
        }
Beispiel #3
0
        public void ResetWorldLevel()
        {
            int dayID = TimeUtil.NowDateTime().DayOfYear;

            if (this.m_nResetWorldLevelDayID != dayID)
            {
                int           offsetDay     = TimeUtil.GetOffsetDayNow();
                string        cDate         = TimeUtil.GetRealDate(offsetDay).Date.ToString("yyyy-MM-dd");
                ServerDayData serverDayData = Global.sendToDB <ServerDayData, int>(11004, offsetDay, GameManager.ServerId);
                if (serverDayData != null && serverDayData.Dayid == offsetDay)
                {
                    LogManager.WriteLog(LogTypes.Info, string.Format("从数据加载世界等级:day={0},worldlevel={1}", serverDayData.CDate, serverDayData.WorldLevel), null, true);
                    this.m_nWorldLevel           = serverDayData.WorldLevel;
                    this.m_nResetWorldLevelDayID = dayID;
                }
                else
                {
                    TCPOutPacket         tcpOutPacket    = null;
                    string               strcmd          = string.Format("{0}:{1}", 0, 5);
                    TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, TCPOutPacketPool.getInstance(), 269, strcmd, out tcpOutPacket, 0);
                    if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED)
                    {
                        LogManager.WriteLog(LogTypes.Error, "世界等级装入异常", null, true);
                    }
                    else
                    {
                        int nBakResetWorldLevelDayID = this.m_nResetWorldLevelDayID;
                        this.m_nResetWorldLevelDayID = dayID;
                        PaiHangData paiHangData = DataHelper.BytesToObject <PaiHangData>(tcpOutPacket.GetPacketBytes(), 6, tcpOutPacket.PacketDataSize - 6);
                        if (null != paiHangData)
                        {
                            int nLevelCount = 0;
                            int roleCount   = 0;
                            if (null != paiHangData.PaiHangList)
                            {
                                int i = 0;
                                while (i < 100 && i < paiHangData.PaiHangList.Count)
                                {
                                    roleCount++;
                                    nLevelCount += paiHangData.PaiHangList[i].Val2 * 100 + paiHangData.PaiHangList[i].Val1;
                                    i++;
                                }
                            }
                            this.m_nWorldLevel = ((roleCount > 0) ? (nLevelCount / roleCount) : 1);
                            serverDayData      = new ServerDayData
                            {
                                Dayid      = offsetDay,
                                CDate      = cDate,
                                WorldLevel = this.m_nWorldLevel
                            };
                            for (;;)
                            {
                                int dbRet = Global.sendToDB <int, ServerDayData>(11003, serverDayData, GameManager.ServerId);
                                if (dbRet >= 0)
                                {
                                    break;
                                }
                                Thread.Sleep(1000);
                            }
                            if (0 != nBakResetWorldLevelDayID)
                            {
                                int count = GameManager.ClientMgr.GetMaxClientCount();
                                for (int i = 0; i < count; i++)
                                {
                                    GameClient client = GameManager.ClientMgr.FindClientByNid(i);
                                    if (null != client)
                                    {
                                        this.UpddateWorldLevelBuff(client);
                                    }
                                }
                            }
                        }
                        else
                        {
                            LogManager.WriteLog(LogTypes.Error, "世界等级装入时,获取等级排行榜失败", null, true);
                        }
                    }
                }
            }
        }