예제 #1
0
        public bool ProcessGetYongZheZhanChangAwardInfoCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                // 如果1.7的功能没开放
                if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
                {
                    return(false);
                }

                string awardsInfo = Global.GetRoleParamByName(client, RoleParamName.YongZheZhanChangAwards);
                if (!string.IsNullOrEmpty(awardsInfo))
                {
                    int lastGroupId = 0;
                    int score       = 0;
                    int success     = 0;
                    int sideScore1  = 0;
                    int sideScore2  = 0;
                    ConfigParser.ParseStrInt3(awardsInfo, ref lastGroupId, ref success, ref score);
                    List <int> awardsParamList = Global.StringToIntList(awardsInfo, ',');
                    lastGroupId = awardsParamList[0];
                    bool clear = true;
                    if (awardsParamList.Count >= 5 && lastGroupId > 0)
                    {
                        success    = awardsParamList[1];
                        score      = awardsParamList[2];
                        sideScore1 = awardsParamList[3];
                        sideScore2 = awardsParamList[4];

                        YongZheZhanChangSceneInfo lastSceneItem = null;
                        if (RuntimeData.SceneDataDict.TryGetValue(lastGroupId, out lastSceneItem))
                        {
                            //只给一次,马上清掉记录
                            if (score >= RuntimeData.WarriorBattleLowestJiFen)
                            {
                                clear = false;
                            }

                            NtfCanGetAward(client, success, score, lastSceneItem, sideScore1, sideScore2);
                        }
                    }

                    if (clear)
                    {
                        Global.SaveRoleParamsStringToDB(client, RoleParamName.YongZheZhanChangAwards, RuntimeData.RoleParamsAwardsDefaultString, true);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            client.sendCmd(nID, StdErrorCode.Error_Success_No_Info);

            return(false);
        }
예제 #2
0
        /// <summary>
        /// 罗兰城战攻防竞价申请指令处理
        /// </summary>
        /// <param name="client"></param>
        /// <param name="nID"></param>
        /// <param name="bytes"></param>
        /// <param name="cmdParams"></param>
        /// <returns></returns>
        public bool ProcessYongZheZhanChangJoinCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result = StdErrorCode.Error_Success_No_Info;

                do
                {
                    // 如果1.7的功能没开放
                    if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
                    {
                        break;
                    }

                    YongZheZhanChangSceneInfo  sceneItem = null;
                    YongZheZhanChangGameStates state     = YongZheZhanChangGameStates.None;
                    if (!CheckMap(client))
                    {
                        result = StdErrorCode.Error_Denied_In_Current_Map;
                    }
                    else
                    {
                        result = CheckCondition(client, ref sceneItem, ref state);
                    }

                    if (state != YongZheZhanChangGameStates.SignUp)
                    {
                        result = StdErrorCode.Error_Not_In_valid_Time; //非报名时间
                    }
                    else if (RuntimeData.RoleId2JoinGroup.ContainsKey(client.ClientData.RoleID))
                    {
                        result = StdErrorCode.Error_Operation_Denied; // 已经报名了
                    }

                    if (result >= 0)
                    {
                        int gropuId = sceneItem.Id;
                        result = YongZheZhanChangClient.getInstance().YongZheZhanChangSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID,
                                                                                             (int)GameTypes.YongZheZhanChang, gropuId, client.ClientData.CombatForce);
                        if (result > 0)
                        {
                            RuntimeData.RoleId2JoinGroup[client.ClientData.RoleID] = gropuId;
                            client.ClientData.SignUpGameType = (int)GameTypes.YongZheZhanChang;
                        }
                    }
                } while (false);

                //发送结果给客户端
                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
예제 #3
0
        private int GiveRoleAwards(GameClient client, int success, int score, YongZheZhanChangSceneInfo sceneInfo)
        {
            long addExp       = 0;
            int  addBindJinBi = 0;
            List <AwardsItemData> awardsItemDataList = null;

            if (score >= RuntimeData.WarriorBattleLowestJiFen)
            {
                //最终经验(取整万舍去尾数) = 经验系数 * (0.2 + Min(0.8, (积分 ^ 0.5) / 100)
                //最终金币(取整万舍去尾数) = 金币系数 * Min(100, (积分 ^ 0.5))
                addExp       = (long)(sceneInfo.Exp * (0.2 + Math.Min(0.8, Math.Pow(score, 0.5) / 100)));
                addBindJinBi = (int)(sceneInfo.BandJinBi * Math.Min(100, Math.Pow(score, 0.5)));
                if (success > 0)
                {
                    awardsItemDataList = sceneInfo.WinAwardsItemList.Items;
                }
                else
                {
                    addExp             = (long)(addExp * 0.8);
                    addBindJinBi       = (int)(addBindJinBi * 0.8);
                    awardsItemDataList = sceneInfo.LoseAwardsItemList.Items;
                }

                addExp       = addExp - (addExp % 10000);
                addBindJinBi = addBindJinBi - (addBindJinBi % 10000);
            }

            if (awardsItemDataList != null && !Global.CanAddGoodsNum(client, awardsItemDataList.Count))
            {
                // 背包不足
                return(StdErrorCode.Error_BagNum_Not_Enough);
            }

            if (addExp > 0)
            {
                GameManager.ClientMgr.ProcessRoleExperience(client, addExp);
            }

            if (addBindJinBi > 0)
            {
                GameManager.ClientMgr.AddMoney1(client, addBindJinBi, "勇者战场奖励");
            }

            if (awardsItemDataList != null)
            {
                foreach (var item in awardsItemDataList)
                {
                    Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, item.GoodsNum, 0, "", item.Level, item.Binding, 0, "", true, 1, "勇者战场奖励", Global.ConstGoodsEndTime, 0, 0, item.IsHaveLuckyProp, 0, item.ExcellencePorpValue, item.AppendLev);
                }
            }

            return(StdErrorCode.Error_Success);
        }
예제 #4
0
        private TimeSpan GetStartTime(int sceneId)
        {
            int result = 0;
            YongZheZhanChangSceneInfo sceneItem = null;
            TimeSpan startTime = TimeSpan.MinValue;
            DateTime now       = TimeUtil.NowDateTime();

            do
            {
                lock (RuntimeData.Mutex)
                {
                    if (!RuntimeData.SceneDataDict.TryGetValue(sceneId, out sceneItem))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }
                }

                result = StdErrorCode.Error_Not_In_valid_Time;
                lock (RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                            now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                            now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            startTime = TimeSpan.FromSeconds(sceneItem.SecondsOfDay[i]);
                            break;
                        }
                    }
                }
            } while (false);

            if (startTime < TimeSpan.Zero)
            {
                startTime = now.TimeOfDay;
            }

            return(startTime);
        }
예제 #5
0
        // 通知客户端有奖励可以领取
        private void NtfCanGetAward(GameClient client, int success, int score, YongZheZhanChangSceneInfo sceneInfo, int sideScore1, int sideScore2)
        {
            long addExp       = 0;
            int  addBindJinBi = 0;
            List <AwardsItemData> awardsItemDataList = null;

            if (score >= RuntimeData.WarriorBattleLowestJiFen)
            {
                //最终经验(取整万舍去尾数) = 经验系数 * (0.2 + Min(0.8, (积分 ^ 0.5) / 100)
                //最终金币(取整万舍去尾数) = 金币系数 * Min(100, (积分 ^ 0.5))
                addExp       = (long)(sceneInfo.Exp * (0.2 + Math.Min(0.8, Math.Pow(score, 0.5) / 100)));
                addBindJinBi = (int)(sceneInfo.BandJinBi * Math.Min(100, Math.Pow(score, 0.5)));
                if (success > 0)
                {
                    awardsItemDataList = sceneInfo.WinAwardsItemList.Items;
                }
                else
                {
                    addExp             = (long)(addExp * 0.8);
                    addBindJinBi       = (int)(addBindJinBi * 0.8);
                    awardsItemDataList = sceneInfo.LoseAwardsItemList.Items;
                }

                addExp       = addExp - (addExp % 10000);
                addBindJinBi = addBindJinBi - (addBindJinBi % 10000);
            }

            YongZheZhanChangAwardsData awardsData = new YongZheZhanChangAwardsData();

            awardsData.Exp                = addExp;
            awardsData.BindJinBi          = addBindJinBi;
            awardsData.Success            = success;
            awardsData.AwardsItemDataList = awardsItemDataList;
            awardsData.SideScore1         = sideScore1;
            awardsData.SideScore2         = sideScore2;
            awardsData.SelfScore          = score;

            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_AWARD, awardsData);
        }
예제 #6
0
        /// <summary>
        /// 添加一个场景
        /// </summary>
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (sceneType == SceneUIClasses.YongZheZhanChang)
            {
                GameMap gameMap = null;
                if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap))
                {
                    return(false);
                }

                int      fuBenSeqId = copyMap.FuBenSeqID;
                int      mapCode    = copyMap.MapCode;
                int      roleId     = client.ClientData.RoleID;
                int      gameId     = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                DateTime now        = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    YongZheZhanChangScene scene = null;
                    if (!SceneDict.TryGetValue(fuBenSeqId, out scene))
                    {
                        YongZheZhanChangSceneInfo sceneInfo = null;
                        YongZheZhanChangFuBenData fuBenData;
                        if (!RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData))
                        {
                            LogManager.WriteLog(LogTypes.Error, "勇者战场没有为副本找到对应的跨服副本数据,GameID:" + gameId);
                        }

                        if (!RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo))
                        {
                            LogManager.WriteLog(LogTypes.Error, "勇者战场没有为副本找到对应的档位数据,ID:" + fuBenData.GroupIndex);
                        }

                        scene         = new YongZheZhanChangScene();
                        scene.CopyMap = copyMap;
                        scene.CleanAllInfo();
                        scene.GameId         = gameId;
                        scene.m_nMapCode     = mapCode;
                        scene.CopyMapId      = copyMap.CopyMapID;
                        scene.FuBenSeqId     = fuBenSeqId;
                        scene.m_nPlarerCount = 1;
                        scene.SceneInfo      = sceneInfo;
                        scene.MapGridWidth   = gameMap.MapGridWidth;
                        scene.MapGridHeight  = gameMap.MapGridHeight;
                        DateTime startTime = now.Date.Add(GetStartTime(sceneInfo.Id));
                        scene.StartTimeTicks = startTime.Ticks / 10000;

                        scene.GameStatisticalData.GameId = gameId;

                        SceneDict[fuBenSeqId] = scene;
                    }
                    else
                    {
                        scene.m_nPlarerCount++;
                    }

                    YongZheZhanChangClientContextData clientContextData;
                    if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData))
                    {
                        clientContextData = new YongZheZhanChangClientContextData()
                        {
                            RoleId = roleId, ServerId = client.ServerId, BattleWhichSide = client.ClientData.BattleWhichSide
                        };
                        scene.ClientContextDataDict[roleId] = clientContextData;
                    }
                    else
                    {
                        clientContextData.KillNum = 0;
                    }

                    client.SceneContextData2 = clientContextData;

                    copyMap.IsKuaFuCopy = true;
                    copyMap.SetRemoveTicks(TimeUtil.NOW() + scene.SceneInfo.TotalSecs * TimeUtil.SECOND);

                    // 非首次进来的人会有旧的积分信息需要通知
                    // 改为进入的时候,让客户端来主动查询
                    //NotifyTimeStateInfoAndScoreInfo(client, false, true, true);
                }

                //更新状态
                YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, (int)KuaFuRoleStates.StartGame);
                return(true);
            }

            return(false);
        }
예제 #7
0
        public bool ProcessYongZheZhanChangEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result = StdErrorCode.Error_Success_No_Info;

                // 如果1.7的功能没开放
                if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
                {
                    client.sendCmd(nID, result);
                    return(true);
                }

                YongZheZhanChangSceneInfo  sceneItem = null;
                YongZheZhanChangGameStates state     = YongZheZhanChangGameStates.None;

                if (!CheckMap(client))
                {
                    result = StdErrorCode.Error_Denied_In_Current_Map;
                }
                else
                {
                    result = CheckCondition(client, ref sceneItem, ref state);
                }

                if (state == YongZheZhanChangGameStates.Start)
                {
                    KuaFuServerLoginData kuaFuServerLoginData = null;
                    lock (RuntimeData.Mutex)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.TryGetValue(client.ClientData.RoleID, out kuaFuServerLoginData))
                        {
                            KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                            if (null != clientKuaFuServerLoginData)
                            {
                                clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                                clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                                clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                                clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                                clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                                clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                                clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                                clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                            }
                        }
                        else
                        {
                            result = StdErrorCode.Error_Server_Busy;
                        }
                    }

                    if (result >= 0)
                    {
                        result = YongZheZhanChangClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame);
                        if (result >= 0)
                        {
                            GlobalNew.RecordSwitchKuaFuServerLog(client);
                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KF_SWITCH_SERVER, Global.GetClientKuaFuServerLoginData(client));
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                        }
                    }
                }
                else
                {
                    result = StdErrorCode.Error_Not_In_valid_Time;
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
예제 #8
0
        public bool ProcessGetYongZheZhanChangStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                // 根据策划需求,任何时候来查询状态,领奖状态具有最高优先级
                string awardsInfo = Global.GetRoleParamByName(client, RoleParamName.YongZheZhanChangAwards);
                if (!string.IsNullOrEmpty(awardsInfo))
                {
                    int lastGroupId = 0;
                    int score       = 0;
                    int success     = 0;
                    ConfigParser.ParseStrInt3(awardsInfo, ref lastGroupId, ref success, ref score);
                    if (lastGroupId > 0)
                    {
                        YongZheZhanChangSceneInfo lastSceneItem = null;
                        if (RuntimeData.SceneDataDict.TryGetValue(lastGroupId, out lastSceneItem))
                        {
                            // 通知有奖励可以领取
                            client.sendCmd(nID, (int)YongZheZhanChangGameStates.Awards);
                            return(true);
                        }
                    }
                }

                YongZheZhanChangSceneInfo  sceneItem = null;
                YongZheZhanChangGameStates timeState = YongZheZhanChangGameStates.None;
                int result  = (int)YongZheZhanChangGameStates.None;
                int groupId = 0;
                RuntimeData.RoleId2JoinGroup.TryGetValue(client.ClientData.RoleID, out groupId);

                CheckCondition(client, ref sceneItem, ref timeState);
                if (groupId > 0)
                {
                    if (timeState >= YongZheZhanChangGameStates.SignUp && timeState <= YongZheZhanChangGameStates.Wait)
                    {
                        int state = YongZheZhanChangClient.getInstance().GetKuaFuRoleState(client.ClientData.RoleID);
                        if (state >= (int)KuaFuRoleStates.SignUp)
                        {
                            result = (int)YongZheZhanChangGameStates.Wait;
                        }
                        else
                        {
                            result = (int)KuaFuBossGameStates.NotJoin;
                        }
                    }
                    else if (timeState == YongZheZhanChangGameStates.Start)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.ContainsKey(client.ClientData.RoleID))
                        {
                            result = (int)YongZheZhanChangGameStates.Start;
                        }
                    }
                }
                else
                {
                    if (timeState == YongZheZhanChangGameStates.SignUp)
                    {
                        result = (int)YongZheZhanChangGameStates.SignUp;
                    }
                    else if (timeState == YongZheZhanChangGameStates.Wait || timeState == YongZheZhanChangGameStates.Start)
                    {
                        // 未参加本次活动
                        result = (int)YongZheZhanChangGameStates.NotJoin;
                    }
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
예제 #9
0
        // 检查勇者战场当前处于什么时间状态
        private int CheckCondition(GameClient client, ref YongZheZhanChangSceneInfo sceneItem, ref YongZheZhanChangGameStates state)
        {
            int result = 0;

            sceneItem = null;

            do
            {
                if (!IsGongNengOpened(client, true))
                {
                    result = StdErrorCode.Error_Type_Not_Match;
                    break;
                }

                lock (RuntimeData.Mutex)
                {
                    if (!RuntimeData.LevelRangeSceneIdDict.TryGetValue(new RangeKey(Global.GetUnionLevel(client)), out sceneItem))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }
                }

                result = StdErrorCode.Error_Not_In_valid_Time;
                DateTime now = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                            now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                            now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs)
                            {
                                state  = YongZheZhanChangGameStates.None;
                                result = StdErrorCode.Error_Not_In_valid_Time;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - sceneItem.SignUpEndSecs)
                            {
                                state  = YongZheZhanChangGameStates.SignUp;
                                result = StdErrorCode.Error_Success;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i])
                            {
                                state  = YongZheZhanChangGameStates.Wait;
                                result = StdErrorCode.Error_Success;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i + 1])
                            {
                                state  = YongZheZhanChangGameStates.Start;
                                result = StdErrorCode.Error_Success;
                            }
                            else
                            {
                                state  = YongZheZhanChangGameStates.None;
                                result = StdErrorCode.Error_Not_In_valid_Time;
                            }
                            break;
                        }
                    }
                }
            } while (false);

            return(result);
        }
예제 #10
0
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (RuntimeData.Mutex)
            {
                bool bInActiveTime = false;

                YongZheZhanChangSceneInfo sceneItem = RuntimeData.SceneDataDict.Values.FirstOrDefault();
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                        now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                        now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                    {
                        double secs = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        bInActiveTime = true;

                        if (!RuntimeData.PrepareGame)
                        {
                            if (secs > 0 && secs < sceneItem.SignUpEndSecs / 2)
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止5分钟时间过半,通知跨服中心开始分配所有报名玩家的活动场次");

                                // 通知跨服中心开始准备副本
                                RuntimeData.PrepareGame = true;
                                notifyPrepareGame       = true;
                                break;
                            }
                        }
                        else
                        {
                            if (secs < 0)
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止状态结束,可以通知已分配到场次的玩家进入游戏了");

                                // 首次到达进入时间,通知进入,并重置PrepareGame状态,然后以后的循环走上面的if
                                // 但是上面的if在本次活动期间就相当于空转
                                notifyEnterGame         = true;
                                RuntimeData.PrepareGame = false;
                                break;
                            }
                        }
                    }
                }

                if (!bInActiveTime)
                {
                    if (RuntimeData.RoleIdKuaFuLoginDataDict.Count > 0)
                    {
                        RuntimeData.RoleIdKuaFuLoginDataDict.Clear();
                    }

                    if (RuntimeData.RoleId2JoinGroup.Count > 0)
                    {
                        RuntimeData.RoleId2JoinGroup.Clear();
                    }
                }
            }

            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "通知跨服中心开始分配所有报名玩家的活动场次");

                // GameServer和KF-GameServer都会通知准备游戏,所以中心要防止状态回滚
                string cmd = string.Format("{0} {1} {2}", GameStates.CommandName, GameStates.PrepareGame, (int)GameTypes.YongZheZhanChang);
                YongZheZhanChangClient.getInstance().ExecuteCommand(cmd);
            }

            if (notifyEnterGame)
            {
                lock (RuntimeData.Mutex)
                {
                    foreach (var kuaFuServerLoginData in RuntimeData.RoleIdKuaFuLoginDataDict.Values)
                    {
                        RuntimeData.NotifyRoleEnterDict.Add(kuaFuServerLoginData.RoleId, kuaFuServerLoginData);
                    }
                }
            }

            //通知报名的玩家进入活动,每次只通知一部分(按RoleID除以15的余数),防止所有玩家一起进入给服务器造成压力.
            List <KuaFuServerLoginData> list = null;

            lock (RuntimeData.Mutex)
            {
                int count = RuntimeData.NotifyRoleEnterDict.Count;
                if (count > 0)
                {
                    list = new List <KuaFuServerLoginData>();
                    KuaFuServerLoginData kuaFuServerLoginData = RuntimeData.NotifyRoleEnterDict.First().Value;
                    foreach (var kv in RuntimeData.NotifyRoleEnterDict)
                    {
                        if ((kv.Key % 15) == (kuaFuServerLoginData.RoleId % 15))
                        {
                            list.Add(kv.Value);
                        }
                    }

                    foreach (var data in list)
                    {
                        RuntimeData.NotifyRoleEnterDict.Remove(data.RoleId);
                    }
                }
            }

            if (null != list)
            {
                foreach (var kuaFuServerLoginData in list)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(kuaFuServerLoginData.RoleId);
                    if (null != client)
                    {
                        client.sendCmd((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_ENTER, 1);
                    }
                }
            }
        }
예제 #11
0
        /// <summary>
        /// 初始化配置
        /// </summary>
        public bool InitConfig()
        {
            bool     success          = true;
            XElement xml              = null;
            string   fileName         = "";
            string   fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (RuntimeData.Mutex)
            {
                try
                {
                    //采集怪配置
                    RuntimeData.BattleCrystalMonsterDict.Clear();

                    fileName         = "Config/BattleCrystalMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        BattleCrystalMonsterItem item = new BattleCrystalMonsterItem();
                        item.Id          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.MonsterID   = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item.GatherTime  = (int)Global.GetSafeAttributeLong(node, "GatherTime");
                        item.BattleJiFen = (int)Global.GetSafeAttributeLong(node, "BattleJiFen");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "X");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "Y");
                        item.FuHuoTime   = (int)Global.GetSafeAttributeLong(node, "FuHuoTime") * 1000;
                        //RuntimeData.BattleCrystalMonsterDict[item.MonsterID] = item;
                        RuntimeData.BattleCrystalMonsterDict[item.Id] = item;
                    }

                    //出生点配置
                    RuntimeData.MapBirthPointDict.Clear();

                    fileName         = "Config/ThroughServiceRebirth.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        YongZheZhanChangBirthPoint item = new YongZheZhanChangBirthPoint();
                        item.ID          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "PosY");
                        item.BirthRadius = (int)Global.GetSafeAttributeLong(node, "BirthRadius");

                        RuntimeData.MapBirthPointDict[item.ID] = item;
                    }

                    //活动配置
                    RuntimeData.SceneDataDict.Clear();
                    RuntimeData.LevelRangeSceneIdDict.Clear();

                    fileName         = "Config/ThroughServiceBattle.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        YongZheZhanChangSceneInfo sceneItem = new YongZheZhanChangSceneInfo();
                        int id      = (int)Global.GetSafeAttributeLong(node, "Group");
                        int mapCode = (int)Global.GetSafeAttributeLong(node, "MapCode");

                        sceneItem.Id               = id;
                        sceneItem.MapCode          = mapCode;
                        sceneItem.MinLevel         = (int)Global.GetSafeAttributeLong(node, "MinLevel");
                        sceneItem.MaxLevel         = (int)Global.GetSafeAttributeLong(node, "MaxLevel");
                        sceneItem.MinZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MinZhuanSheng");
                        sceneItem.MaxZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MaxZhuanSheng");
                        sceneItem.PrepareSecs      = (int)Global.GetSafeAttributeLong(node, "PrepareSecs");
                        sceneItem.WaitingEnterSecs = (int)Global.GetSafeAttributeLong(node, "WaitingEnterSecs");
                        sceneItem.FightingSecs     = (int)Global.GetSafeAttributeLong(node, "FightingSecs");
                        sceneItem.ClearRolesSecs   = (int)Global.GetSafeAttributeLong(node, "ClearRolesSecs");

                        ConfigParser.ParseStrInt2(Global.GetSafeAttributeStr(node, "ApplyTime"), ref sceneItem.SignUpStartSecs, ref sceneItem.SignUpEndSecs);
                        sceneItem.SignUpStartSecs += sceneItem.SignUpEndSecs;

                        if (!ConfigParser.ParserTimeRangeListWithDay(sceneItem.TimePoints, Global.GetSafeAttributeStr(node, "TimePoints")))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("读取{0}时间配置(TimePoints)出错", fileName));
                        }

                        for (int i = 0; i < sceneItem.TimePoints.Count; ++i)
                        {
                            TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds);
                            sceneItem.SecondsOfDay.Add(ts.TotalSeconds);
                        }

                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("55地图配置中缺少{0}所需的地图:{1}", fileName, mapCode));
                        }

                        RangeKey range = new RangeKey(Global.GetUnionLevel(sceneItem.MinZhuanSheng, sceneItem.MinLevel), Global.GetUnionLevel(sceneItem.MaxZhuanSheng, sceneItem.MaxLevel));
                        RuntimeData.LevelRangeSceneIdDict[range] = sceneItem;
                        RuntimeData.SceneDataDict[id]            = sceneItem;
                    }

                    //活动奖励配置
                    fileName         = "Config/ThroughServiceBattleAward.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        int id = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        YongZheZhanChangSceneInfo sceneItem;
                        if (RuntimeData.SceneDataDict.TryGetValue(id, out sceneItem))
                        {
                            sceneItem.Exp       = (int)Global.GetSafeAttributeLong(node, "Exp");
                            sceneItem.BandJinBi = (int)Global.GetSafeAttributeLong(node, "BandJinBi");
                            ConfigParser.ParseAwardsItemList(Global.GetSafeAttributeStr(node, "WinGoods"), ref sceneItem.WinAwardsItemList);
                            ConfigParser.ParseAwardsItemList(Global.GetSafeAttributeStr(node, "LoseGoods"), ref sceneItem.LoseAwardsItemList);
                        }
                    }

                    fileName         = "Config/BattleMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        BattleDynamicMonsterItem item = new BattleDynamicMonsterItem();
                        item.Id           = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.MapCode      = (int)Global.GetSafeAttributeLong(node, "CodeID");
                        item.MonsterID    = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item.PosX         = (int)Global.GetSafeAttributeLong(node, "X");
                        item.PosY         = (int)Global.GetSafeAttributeLong(node, "Y");
                        item.DelayBirthMs = (int)Global.GetSafeAttributeLong(node, "Time");

                        List <BattleDynamicMonsterItem> itemList = null;
                        if (!RuntimeData.SceneDynMonsterDict.TryGetValue(item.MapCode, out itemList))
                        {
                            itemList = new List <BattleDynamicMonsterItem>();
                            RuntimeData.SceneDynMonsterDict[item.MapCode] = itemList;
                        }

                        itemList.Add(item);
                    }

                    //奖励配置
                    RuntimeData.WarriorBattleBOssLastAttack = (int)GameManager.systemParamsList.GetParamValueIntByName("WarriorBattleBOssLastAttack");
                    //RuntimeData.WarriorBattlePk = (int)GameManager.systemParamsList.GetParamValueIntByName("WarriorBattlePk");
                    RuntimeData.WarriorBattleLowestJiFen = (int)GameManager.systemParamsList.GetParamValueIntByName("WarriorBattleLowestJiFen");
                    double[] doubalArray = GameManager.systemParamsList.GetParamValueDoubleArrayByName("WarriorBattleBossAttack");
                    if (doubalArray.Length == 2)
                    {
                        RuntimeData.WarriorBattleBossAttackPercent = doubalArray[0];
                        RuntimeData.WarriorBattleBossAttackScore   = (int)doubalArray[1];
                    }
                    int[] intArray = GameManager.systemParamsList.GetParamValueIntArrayByName("WarriorBattleUltraKill");
                    if (doubalArray.Length == 2)
                    {
                        RuntimeData.WarriorBattleUltraKillParam1 = intArray[0];
                        RuntimeData.WarriorBattleUltraKillParam2 = intArray[1];
                        RuntimeData.WarriorBattleUltraKillParam3 = intArray[2];
                        RuntimeData.WarriorBattleUltraKillParam4 = intArray[3];
                    }
                    intArray = GameManager.systemParamsList.GetParamValueIntArrayByName("WarriorBattleShutDown");
                    if (doubalArray.Length == 2)
                    {
                        RuntimeData.WarriorBattleShutDownParam1 = intArray[0];
                        RuntimeData.WarriorBattleShutDownParam2 = intArray[1];
                        RuntimeData.WarriorBattleShutDownParam3 = intArray[2];
                        RuntimeData.WarriorBattleShutDownParam4 = intArray[3];
                    }
                }
                catch (System.Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex);
                }
            }

            return(success);
        }