Ejemplo n.º 1
0
        public static void RecordSwitchKuaFuServerLog(GameClient client)
        {
            ushort LastMapCode = 0;
            ushort LastPosX    = 0;
            ushort LastPosY    = 0;

            if (SceneUIClasses.Normal == Global.GetMapSceneType(client.ClientData.MapCode))
            {
                LastMapCode = (ushort)client.CurrentMapCode;
                LastPosX    = (ushort)client.CurrentGrid.X;
                LastPosY    = (ushort)client.CurrentGrid.Y;
            }
            Global.ModifyMapRecordData(client, LastMapCode, LastPosX, LastPosY, 0);
            KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);

            LogManager.WriteLog(LogTypes.Error, string.Format("GameType={5},RoleId={0},GameId={1},SrcServerId={2},KfIp={3},KfPort={4}", new object[]
            {
                kuaFuServerLoginData.RoleId,
                kuaFuServerLoginData.GameId,
                kuaFuServerLoginData.ServerId,
                kuaFuServerLoginData.ServerIp,
                kuaFuServerLoginData.ServerPort,
                kuaFuServerLoginData.GameType
            }), null, true);
            EventLogManager.AddGameEvent(LogRecordType.KuaFu, new object[]
            {
                kuaFuServerLoginData.GameType,
                kuaFuServerLoginData.RoleId,
                client.ClientData.Faction,
                client.ClientData.JunTuanId,
                kuaFuServerLoginData.GameId
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 返回剩下的唯一帮会,-1表示有没有唯一帮会
        /// </summary>
        /// <returns></returns>
        public void GetTheOnlyOneBangHui(LangHunLingYuScene scene, out int newBHid, out int newBHServerID)
        {
            newBHid       = 0;
            newBHServerID = 0;

            CopyMap copyMap;

            if (!scene.CopyMapDict.TryGetValue(scene.SceneInfo.MapCode_LongTa, out copyMap))
            {
                return;
            }

            //龙塔地图中活着的玩家列表
            List <GameClient> lsClients = copyMap.GetClientsList();

            lsClients = Global.GetMapAliveClientsEx(lsClients, scene.SceneInfo.MapCode_LongTa, true);

            lock (RuntimeData.Mutex)
            {
                Dictionary <int, BangHuiRoleCountData> dict = new Dictionary <int, BangHuiRoleCountData>();

                //根据活着的玩家列表,判断王族是否应该产生 保留 还说流产
                for (int n = 0; n < lsClients.Count; n++)
                {
                    GameClient client = lsClients[n];
                    int        bhid   = client.ClientData.Faction;
                    if (bhid > 0)
                    {
                        BangHuiRoleCountData data;
                        if (!dict.TryGetValue(bhid, out data))
                        {
                            data = new BangHuiRoleCountData()
                            {
                                BHID = bhid, RoleCount = 0, ServerID = client.ServerId
                            };
                            dict.Add(bhid, data);
                        }

                        data.RoleCount++;
                    }
                }

                scene.LongTaBHRoleCountList = dict.Values.ToList();

                if (scene.LongTaBHRoleCountList.Count == 1)
                {
                    newBHid       = scene.LongTaBHRoleCountList[0].BHID;
                    newBHServerID = scene.LongTaBHRoleCountList[0].ServerID;
                    EventLogManager.AddGameEvent(LogRecordType.LangHunLingYuLongTaOnlyBangHuiLog, scene.CityData.CityId, newBHid, -1, "狼魂领域龙塔唯一帮会");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// <summary>
        /// 新的王城帮会
        /// 2.1若在结束前,王城已有归属,且当前皇宫内成为拥有多个行会的成员或者无人在皇宫中,则王城胜利方属于王城原有归属
        /// 2.2若在结束前,王城无归属,且皇宫内所有成员均为一个行会的成员,则该行会将成为本次王城战的胜利方
        /// 2.3王城战结束时间到后,若之前王城为无归属状态,且皇宫内成员非同一个行会或者无人在皇宫中,则本次王城战流产
        /// </summary>
        /// 尝试产生新帮会[拥有王城所有权的帮会]
        /// </summary>
        /// <returns></returns>
        public bool TryGenerateNewHuangChengBangHui(LangHunLingYuScene scene)
        {
            int newBHid       = 0;
            int newBHServerID = 0;

            GetTheOnlyOneBangHui(scene, out newBHid, out newBHServerID);
            lock (RuntimeData.Mutex)
            {
                //剩下的帮会是王城帮会,没有产生新帮会
                if (newBHid <= 0 || newBHid == scene.LongTaOwnerData.OwnerBHid)
                {
                    scene.LastTheOnlyOneBangHui = 0;
                    return(false);
                }

                //这次的新帮会和上次不一样,替换,并记录时间
                if (scene.LastTheOnlyOneBangHui != newBHid)
                {
                    scene.LastTheOnlyOneBangHui     = newBHid;
                    scene.BangHuiTakeHuangGongTicks = TimeUtil.NOW();

                    //还是没产生
                    return(false);
                }

                if (scene.LastTheOnlyOneBangHui > 0)
                {
                    //超过最小时间之后,产生了新帮会,接下来外面的代码需要进行数据库修改
                    long ticks = TimeUtil.NOW();
                    EventLogManager.AddGameEvent(LogRecordType.LangHunLingYuLongTaOnlyBangHuiLog, scene.CityData.CityId, newBHid, ticks - scene.BangHuiTakeHuangGongTicks, "狼魂领域龙塔占领持续时间");
                    if (ticks - scene.BangHuiTakeHuangGongTicks > RuntimeData.MaxTakingHuangGongSecs)
                    {
                        scene.LongTaOwnerData.OwnerBHid       = scene.LastTheOnlyOneBangHui;
                        scene.LongTaOwnerData.OwnerBHName     = GetBangHuiName(newBHid, out scene.LongTaOwnerData.OwnerBHZoneId); //加载帮会名称等细节信息
                        scene.LongTaOwnerData.OwnerBHServerId = newBHServerID;
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc(object sender, EventArgs e)
        {
            lock (RuntimeData.Mutex)
            {
                if (RuntimeData.StatisticalDataQueue.Count > 0)
                {
                    LangHunLingYuStatisticalData data = RuntimeData.StatisticalDataQueue.Peek();
                    int result = YongZheZhanChangClient.getInstance().GameFuBenComplete(data);
                    if (result >= 0)
                    {
                        RuntimeData.StatisticalDataQueue.Dequeue();
                    }
                }
            }

            foreach (var scene in RuntimeData.SceneDict.Values)
            {
                lock (RuntimeData.Mutex)
                {
                    // 当前tick
                    DateTime now   = TimeUtil.NowDateTime();
                    long     ticks = TimeUtil.NOW();

                    if (scene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        if (ticks >= scene.StartTimeTicks)
                        {
                            LangHunLingYuFuBenData fuBenData;
                            if (RuntimeData.FuBenDataDict.TryGetValue(scene.GameId, out fuBenData) && fuBenData.State == GameFuBenState.End)
                            {
                                scene.m_eStatus    = GameSceneStatuses.STATUS_AWARD;
                                scene.m_lLeaveTime = TimeUtil.NOW();
                            }

                            scene.m_lPrepareTime = scene.StartTimeTicks;
                            scene.m_lBeginTime   = scene.m_lPrepareTime + scene.SceneInfo.PrepareSecs * TimeUtil.SECOND;
                            scene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                            scene.StateTimeData.GameType = (int)GameTypes.LangHunLingYu;
                            scene.StateTimeData.State    = (int)scene.m_eStatus;
                            scene.StateTimeData.EndTicks = scene.m_lBeginTime;
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, copy);
                            }
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (ticks >= scene.m_lBeginTime)
                        {
                            scene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                            scene.m_lEndTime = scene.m_lBeginTime + scene.SceneInfo.FightingSecs * TimeUtil.SECOND;

                            scene.StateTimeData.GameType = (int)GameTypes.LangHunLingYu;
                            scene.StateTimeData.State    = (int)scene.m_eStatus;
                            scene.StateTimeData.EndTicks = scene.m_lEndTime;
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, copy);
                            }
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (ticks >= scene.m_lEndTime)
                        {
                            scene.m_eStatus    = GameSceneStatuses.STATUS_END;
                            scene.m_lLeaveTime = scene.m_lEndTime + scene.SceneInfo.ClearRolesSecs * TimeUtil.SECOND;

                            scene.StateTimeData.GameType = (int)GameTypes.LangHunLingYu;
                            scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_CLEAR;
                            scene.StateTimeData.EndTicks = scene.m_lLeaveTime;
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, copy);
                            }

                            ProcessWangChengZhanResult(scene, true);
                        }
                        else
                        {
                            ProcessWangChengZhanResult(scene, false);
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_END)         // 战斗结束
                    {
                        //结算奖励
                        scene.m_eStatus = GameSceneStatuses.STATUS_AWARD;

                        LangHunLingYuStatisticalData statisticalData = new LangHunLingYuStatisticalData();
                        statisticalData.CompliteTime = TimeUtil.NowDateTime();
                        statisticalData.CityId       = scene.CityData.CityId;
                        statisticalData.GameId       = scene.GameId;
                        statisticalData.SiteBhids[0] = scene.LongTaOwnerData.OwnerBHid;
                        LangHunLingYuBuildMaxCityOwnerInfo(statisticalData, scene.LongTaOwnerData.OwnerBHServerId);
                        RuntimeData.StatisticalDataQueue.Enqueue(statisticalData);
                        LangHunLingYuFuBenData fuBenData;
                        if (RuntimeData.FuBenDataDict.TryGetValue(scene.GameId, out fuBenData))
                        {
                            fuBenData.State = GameFuBenState.End;
                        }

                        EventLogManager.AddGameEvent(LogRecordType.LangHunLingYuResult, statisticalData.GameId, statisticalData.CityId, statisticalData.SiteBhids[0]);
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        if (ticks >= scene.m_lLeaveTime)
                        {
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                copy.SetRemoveTicks(scene.m_lLeaveTime);
                                try
                                {
                                    List <GameClient> objsList = copy.GetClientsList();
                                    if (objsList != null && objsList.Count > 0)
                                    {
                                        for (int n = 0; n < objsList.Count; ++n)
                                        {
                                            GameClient c = objsList[n];
                                            if (c != null)
                                            {
                                                KuaFuManager.getInstance().GotoLastMap(c);
                                            }
                                        }
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    DataHelper.WriteExceptionLogEx(ex, "圣域争霸系统清场调度异常");
                                }
                            }

                            scene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;
                        }
                    }
                }
            }

            return;
        }