Example #1
0
        public bool InitConfig()
        {
            bool   success  = true;
            string fileName = "";

            lock (this.RuntimeData.Mutex)
            {
                try
                {
                    this.RuntimeData.MapBirthPointDict.Clear();
                    fileName = "Config/ThroughServiceBossRebirth.xml";
                    string   fullPathFileName = Global.GameResPath(fileName);
                    XElement xml = XElement.Load(fullPathFileName);
                    IEnumerable <XElement> nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KuaFuBossBirthPoint item = new KuaFuBossBirthPoint();
                        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");
                        this.RuntimeData.MapBirthPointDict[item.ID] = item;
                    }
                    this.RuntimeData.SceneDataDict.Clear();
                    this.RuntimeData.LevelRangeSceneIdDict.Clear();
                    this.RuntimeData.SceneDynMonsterDict.Clear();
                    fileName         = "Config/ThroughServiceBoss.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KuaFuBossSceneInfo sceneItem = new KuaFuBossSceneInfo();
                        int id      = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        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"), true, '|', '-', ','))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("读取{0}时间配置(TimePoints)出错", fileName), null, true);
                        }
                        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("地图配置中缺少{0}所需的地图:{1}", fileName, mapCode), null, true);
                        }
                        RangeKey range = new RangeKey(Global.GetUnionLevel(sceneItem.MinZhuanSheng, sceneItem.MinLevel, false), Global.GetUnionLevel(sceneItem.MaxZhuanSheng, sceneItem.MaxLevel, false), null);
                        this.RuntimeData.LevelRangeSceneIdDict[range] = sceneItem;
                        this.RuntimeData.SceneDataDict[id]            = sceneItem;
                    }
                    fileName         = "Config/ThroughServiceBossMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        BattleDynamicMonsterItem item2 = new BattleDynamicMonsterItem();
                        item2.Id            = (int)Global.GetSafeAttributeLong(node, "ID");
                        item2.MapCode       = (int)Global.GetSafeAttributeLong(node, "CodeID");
                        item2.MonsterID     = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item2.PosX          = (int)Global.GetSafeAttributeLong(node, "X");
                        item2.PosY          = (int)Global.GetSafeAttributeLong(node, "Y");
                        item2.DelayBirthMs  = (int)Global.GetSafeAttributeLong(node, "Time");
                        item2.PursuitRadius = (int)Global.GetSafeAttributeLong(node, "PursuitRadius");
                        item2.Num           = (int)Global.GetSafeAttributeLong(node, "Num");
                        item2.Radius        = (int)Global.GetSafeAttributeLong(node, "Radius");
                        List <BattleDynamicMonsterItem> itemList = null;
                        if (!this.RuntimeData.SceneDynMonsterDict.TryGetValue(item2.MapCode, out itemList))
                        {
                            itemList = new List <BattleDynamicMonsterItem>();
                            this.RuntimeData.SceneDynMonsterDict[item2.MapCode] = itemList;
                        }
                        itemList.Add(item2);
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                }
            }
            return(success);
        }
        /// <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);
        }