Exemplo n.º 1
0
        private void InitLangHunLingYuConfig()
        {
            string fileName = "";

            lock (this.Mutex)
            {
                try
                {
                    Dictionary <int, CityLevelInfo> cityLevelInfoDict = new Dictionary <int, CityLevelInfo>();
                    fileName = "Config/MU_City.xml";
                    string   fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
                    XElement xml = ConfigHelper.Load(fullPathFileName);
                    IEnumerable <XElement> nodes = xml.Elements();
                    foreach (XElement t in nodes)
                    {
                        string type = ConfigHelper.GetElementAttributeValue(t, "TypeID", "");
                        if (string.Compare(type, KuaFuServerManager.platformType.ToString(), true) == 0)
                        {
                            foreach (XElement node in t.Elements())
                            {
                                CityLevelInfo item = new CityLevelInfo();
                                item.ID        = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID", 0L);
                                item.CityLevel = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityLevel", 0L);
                                item.CityNum   = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityNum", 0L);
                                item.MaxNum    = (int)ConfigHelper.GetElementAttributeValueLong(node, "MaxNum", 0L);
                                string strAttackWeekDay = ConfigHelper.GetElementAttributeValue(node, "AttackWeekDay", "");
                                item.AttackWeekDay = ConfigHelper.String2IntArray(strAttackWeekDay, ',');
                                if (!ConfigHelper.ParserTimeRangeListWithDay(item.BaoMingTime, ConfigHelper.GetElementAttributeValue(node, "BaoMingTime", "").Replace(';', '|'), true, '|', '-', ','))
                                {
                                    LogManager.WriteLog(LogTypes.Fatal, string.Format("解析文件{0}的BaoMingTime出错", fileName), null, true);
                                    KuaFuServerManager.LoadConfigSuccess = false;
                                }
                                if (!ConfigHelper.ParserTimeRangeList(item.AttackTime, ConfigHelper.GetElementAttributeValue(node, "AttackTime", ""), true, '|', '-'))
                                {
                                    LogManager.WriteLog(LogTypes.Fatal, string.Format("解析文件{0}的BaoMingTime出错", fileName), null, true);
                                    KuaFuServerManager.LoadConfigSuccess = false;
                                }
                                cityLevelInfoDict[item.CityLevel] = item;
                            }
                            break;
                        }
                    }
                    this.CityLevelInfoDict = cityLevelInfoDict;
                    if (this.CityLevelInfoDict.Count == 0)
                    {
                        LogManager.WriteLog(LogTypes.Fatal, string.Format("读取配置{0}失败,读取到的城池配置数为0", new object[0]), null, true);
                        KuaFuServerManager.LoadConfigSuccess = false;
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。{1}", fileName, ex.ToString()), null, true);
                    KuaFuServerManager.LoadConfigSuccess = false;
                }
            }
        }
Exemplo n.º 2
0
        private void InitLangHunLingYuConfig()
        {
            string fileName         = "";
            string fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (Mutex)
            {
                try
                {
                    Dictionary <int, CityLevelInfo> cityLevelInfoDict = new Dictionary <int, CityLevelInfo>();

                    fileName         = "Config/MU_City.xml";
                    fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
                    XElement xml = ConfigHelper.Load(fullPathFileName);

                    nodes = xml.Elements();
                    int cityId = 0;
                    foreach (var t in nodes)
                    {
                        string type = ConfigHelper.GetElementAttributeValue(t, "TypeID");
                        if (string.Compare(type, KuaFuServerManager.platformType.ToString(), true) == 0)
                        {
                            foreach (var node in t.Elements())
                            {
                                CityLevelInfo item = new CityLevelInfo();
                                item.ID        = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID");
                                item.CityLevel = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityLevel");
                                item.CityNum   = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityNum");
                                item.MaxNum    = (int)ConfigHelper.GetElementAttributeValueLong(node, "MaxNum");

                                string strAttackWeekDay = ConfigHelper.GetElementAttributeValue(node, "AttackWeekDay");
                                item.AttackWeekDay = ConfigHelper.String2IntArray(strAttackWeekDay);

                                cityLevelInfoDict[item.CityLevel] = item;
                            }

                            break;
                        }
                    }

                    CityLevelInfoDict = cityLevelInfoDict;
                    if (CityLevelInfoDict.Count == 0)
                    {
                        LogManager.WriteLog(LogTypes.Fatal, string.Format("读取配置{0}失败,读取到的城池配置数为0"));
                        KuaFuServerManager.LoadConfigSuccess = false;
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。{1}", fileName, ex.ToString()));
                    KuaFuServerManager.LoadConfigSuccess = false;
                }
            }
        }