예제 #1
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);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            bool     notifyEndGame     = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (this.Mutex)
            {
                KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - 120.0 && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1] + 120.0)
                    {
                        double secsPrepare = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        double secsEnd     = sceneItem.SecondsOfDay[i + 1] + 120.0 - now.TimeOfDay.TotalSeconds;
                        if (!this.PrepareGame)
                        {
                            if (secsPrepare > 0.0 && secsPrepare < 120.0)
                            {
                                this.PrepareGame  = true;
                                notifyPrepareGame = true;
                                break;
                            }
                        }
                        else if (secsPrepare < 0.0)
                        {
                            notifyEnterGame  = true;
                            this.PrepareGame = false;
                            break;
                        }
                        if (!this.EndGame)
                        {
                            if (secsEnd > 0.0 && secsEnd < 120.0)
                            {
                                this.EndGame  = true;
                                notifyEndGame = true;
                                break;
                            }
                        }
                        else if (secsEnd < 0.0)
                        {
                            this.EndGame = false;
                            break;
                        }
                    }
                }
            }
            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "阿卡伦战场活动即将开始,准备通知军团角色进入!", null, true);
                lock (this.Mutex)
                {
                    this.FactionIDVsServerIDDict.Clear();
                }
            }
            if (notifyEnterGame)
            {
                int westcount = 0;
                int eastcount = 0;
                lock (this.Mutex)
                {
                    LogManager.WriteLog(LogTypes.Error, "阿卡伦战场开启,可以通知已分配到场次的玩家进入游戏了", null, true);
                    KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
                    foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true))
                    {
                        if (this.CheckCanEnterKarenBattle(client) && this.CheckMap(client) && this.IsGongNengOpened(client, false))
                        {
                            if (null != client)
                            {
                                client.sendCmd(1210, string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    1,
                                    1,
                                    westcount,
                                    eastcount
                                }), false);
                            }
                        }
                    }
                }
            }
            if (notifyEndGame)
            {
                lock (this.Mutex)
                {
                    foreach (KarenBattleSceneInfo item in this.SceneDataDict.Values)
                    {
                        KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.MapCode);
                        if (fubenData != null && fubenData.ServerId == GameManager.ServerId)
                        {
                            SceneUIClasses mapType = Global.GetMapSceneType(item.MapCode);
                            if (mapType != SceneUIClasses.KarenEast || KarenBattleManager_MapEast.getInstance().SceneDict.Count == 0)
                            {
                                if (mapType != SceneUIClasses.KarenWest || KarenBattleManager_MapWest.getInstance().SceneDict.Count == 0)
                                {
                                    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;
                                    LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, 0, 0, "", null);
                                    EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, 0, 0, 0);
                                }
                            }
                        }
                    }
                }
            }
            this.UpdateKuaFuMapClientCount(KarenBattleManager_MapWest.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>());
            this.UpdateKuaFuMapClientCount(KarenBattleManager_MapEast.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>());
        }