Пример #1
0
        public static void UpdateLingYuProps(GameClient client)
        {
            if (null == client.ClientData.MyWingData)
            {
                return;
            }
            if (client.ClientData.MyWingData.WingID <= 0)
            {
                return;
            }
            //if (1 != client.ClientData.MyWingData.Using) return;

            double MinAttackV   = 0;
            double MaxAttackV   = 0;
            double MinMAttackV  = 0;
            double MaxMAttackV  = 0;
            double MinDefenseV  = 0;
            double MaxDefenseV  = 0;
            double MinMDefenseV = 0;
            double MaxMDefenseV = 0;
            double HitV         = 0;
            double LifeV        = 0;

            //Key: 阶数  Value: 个数
            //List<int> suitCnt = new List<int>(LingYuManager.LingYuSuitLimit + 1);
            int[] suitCnt = new int[LingYuManager.LingYuSuitLimit + 1];

            if (client.ClientData.MyWingData.Using == 1)
            {
                lock (client.ClientData.LingYuDict)
                {
                    foreach (KeyValuePair <int, LingYuData> kv in client.ClientData.LingYuDict)
                    {
                        int type  = kv.Value.Type;
                        int level = kv.Value.Level;
                        int suit  = kv.Value.Suit;

                        for (int i = 0; i <= suit; ++i)
                        {
                            suitCnt[i]++;
                        }

                        LingYuType lyType = null;
                        if (!LingYuTypeDict.TryGetValue(type, out lyType))
                        {
                            continue;
                        }
                        LingYuLevel lyLevel = null;
                        lyType.LevelDict.TryGetValue(level, out lyLevel);
                        LingYuSuit lySuit = null;
                        lyType.SuitDict.TryGetValue(suit, out lySuit);

                        if (lyLevel != null)
                        {
                            MinAttackV   += lyLevel.MinAttackV;
                            MaxAttackV   += lyLevel.MaxAttackV;
                            MinMAttackV  += lyLevel.MinMAttackV;
                            MaxMAttackV  += lyLevel.MaxMAttackV;
                            MinDefenseV  += lyLevel.MinDefenseV;
                            MaxDefenseV  += lyLevel.MaxDefenseV;
                            MinMDefenseV += lyLevel.MinMDefenseV;
                            MaxMDefenseV += lyLevel.MaxMDefenseV;
                            HitV         += lyLevel.HitV;
                            LifeV        += lyLevel.LifeV;
                        }

                        if (lySuit != null)
                        {
                            MinAttackV   += lySuit.MinAttackV;
                            MaxAttackV   += lySuit.MaxAttackV;
                            MinMAttackV  += lySuit.MinMAttackV;
                            MaxMAttackV  += lySuit.MaxMAttackV;
                            MinDefenseV  += lySuit.MinDefenseV;
                            MaxDefenseV  += lySuit.MaxDefenseV;
                            MinMDefenseV += lySuit.MinMDefenseV;
                            MaxMDefenseV += lySuit.MaxMDefenseV;
                            HitV         += lySuit.HitV;
                            LifeV        += lySuit.LifeV;
                        }
                    }
                }
            }

            // 翎羽属性加成
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MinAttack, MinAttackV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MaxAttack, MaxAttackV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MinMAttack, MinMAttackV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MaxMAttack, MaxMAttackV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MinDefense, MinDefenseV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MaxDefense, MaxDefenseV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MinMDefense, MinMDefenseV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MaxMDefense, MaxMDefenseV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.HitV, HitV);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.MaxLifeV, LifeV);

            double lucky   = 0.0;
            double deLucky = 0.0;

            // 翎羽阶数满足条件的加成
            if (client.ClientData.MyWingData.Using == 1)
            {
                for (int i = LingYuCollectList.Count() - 1; i >= 0; i--)
                {
                    LingYuCollect lyCollect = LingYuCollectList[i];
                    if (suitCnt[lyCollect.NeedSuit] >= lyCollect.Num)
                    {
                        lucky   = lyCollect.Luck;
                        deLucky = lyCollect.DeLuck;
                        break;
                    }
                }
            }
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.Lucky, lucky);
            client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.LingYuProps, (int)ExtPropIndexes.DeLucky, deLucky);
        }
Пример #2
0
        public static void LoadConfig()
        {
            XElement xml = null;

            #region 加载LingYuTypeFile

            GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(LingYuTypeFile));
            xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(LingYuTypeFile));
            if (xml == null)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时出错!!!文件不存在", LingYuTypeFile));
            }
            else
            {
                try
                {
                    LingYuTypeDict.Clear();
                    IEnumerable <XElement> xmlItems = xml.Elements();
                    foreach (var xmlItem in xmlItems)
                    {
                        if (null == xmlItem)
                        {
                            continue;
                        }

                        LingYuType lyType = new LingYuType();
                        lyType.Type                 = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "TypeID", "0"));
                        lyType.Name                 = Global.GetDefAttributeStr(xmlItem, "Name", "no-name");
                        lyType.LifeScale            = Global.GetSafeAttributeDouble(xmlItem, "LifeScale");
                        lyType.AttackScale          = Global.GetSafeAttributeDouble(xmlItem, "AttackScale");
                        lyType.DefenseScale         = Global.GetSafeAttributeDouble(xmlItem, "DefenseScale");
                        lyType.MAttackScale         = Global.GetSafeAttributeDouble(xmlItem, "MAttackScale");
                        lyType.MDefenseScale        = Global.GetSafeAttributeDouble(xmlItem, "MDefenseScale");
                        lyType.HitScale             = Global.GetSafeAttributeDouble(xmlItem, "HitScale");
                        LingYuTypeDict[lyType.Type] = lyType;
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时异常{1}", LingYuTypeFile, ex));
                }
            }

            #endregion

            #region 加载LingYuLevelUpFile

            xml = null;
            GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(LingYuLevelUpFile));
            xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(LingYuLevelUpFile));
            if (xml == null)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时出错!!!文件不存在", LingYuLevelUpFile));
            }
            else
            {
                try
                {
                    IEnumerable <XElement> xmlItems = xml.Elements();
                    foreach (var xmlItem in xmlItems)
                    {
                        if (null == xmlItem)
                        {
                            continue;
                        }

                        // 先读取翎羽类型
                        int        TypeID = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "TypeID", "0"));
                        LingYuType lyType = null;
                        if (!LingYuTypeDict.TryGetValue(TypeID, out lyType))
                        {
                            LogManager.WriteLog(LogTypes.Error, string.Format("加载翎羽升级文件{0}时,未找到类型为{1}的翎羽配置", LingYuLevelUpFile, TypeID));
                            continue;
                        }

                        // 读取翎羽的每个级别的信息
                        IEnumerable <XElement> xmlItemLevels = xmlItem.Elements();
                        foreach (var xmlItemLevel in xmlItemLevels)
                        {
                            LingYuLevel lyLevel = new LingYuLevel();
                            lyLevel.Level        = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "Level", "0"));
                            lyLevel.MinAttackV   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinAttackV", "0"));
                            lyLevel.MaxAttackV   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxAttackV", "0"));
                            lyLevel.MinMAttackV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinMAttackV", "0"));
                            lyLevel.MaxMAttackV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxMAttackV", "0"));
                            lyLevel.MinDefenseV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinDefenseV", "0"));
                            lyLevel.MaxDefenseV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxDefenseV", "0"));
                            lyLevel.MinMDefenseV = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinMDefenseV", "0"));
                            lyLevel.MaxMDefenseV = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxMDefenseV", "0"));
                            lyLevel.HitV         = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "HitV", "0"));
                            lyLevel.LifeV        = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "LifeV", "0"));
                            lyLevel.JinBiCost    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "JinBiCost", "0"));
                            string   costGoods      = Global.GetDefAttributeStr(xmlItemLevel, "GoodsCost", "0");
                            string[] costGoodsField = costGoods.Split(',');
                            if (costGoodsField.Length != 2)
                            {
                                LogManager.WriteLog(LogTypes.Error, string.Format("翎羽Type{0},级别{1}, 消耗物品配置错误", TypeID, lyLevel.Level));
                                continue;
                            }

                            lyLevel.GoodsCost    = Convert.ToInt32(costGoodsField[0]);
                            lyLevel.GoodsCostCnt = Convert.ToInt32(costGoodsField[1]);

                            lyType.LevelDict[lyLevel.Level] = lyLevel;

                            LingYuLevelLimit = Global.GMax(LingYuLevelLimit, lyLevel.Level);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时异常{1}", LingYuLevelUpFile, ex));
                }
            }

            #endregion

            #region 加载LingYuSuitUpFile

            xml = null;
            GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(LingYuSuitUpFile));
            xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(LingYuSuitUpFile));
            if (xml == null)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时出错!!!文件不存在", LingYuSuitUpFile));
            }
            else
            {
                try
                {
                    lock (LingYuTypeDict)
                    {
                        IEnumerable <XElement> xmlItems = xml.Elements();
                        foreach (var xmlItem in xmlItems)
                        {
                            if (null == xmlItem)
                            {
                                continue;
                            }

                            // 先读取翎羽类型
                            int        TypeID = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "TypeID", "0"));
                            LingYuType lyType = null;
                            if (!LingYuTypeDict.TryGetValue(TypeID, out lyType))
                            {
                                LogManager.WriteLog(LogTypes.Error, string.Format("加载翎羽进阶文件{0}时,未找到类型为{1}的翎羽配置", LingYuSuitUpFile, TypeID));
                                continue;
                            }

                            // 读取翎羽的每个级别的信息
                            IEnumerable <XElement> xmlItemLevels = xmlItem.Elements();
                            foreach (var xmlItemLevel in xmlItemLevels)
                            {
                                LingYuSuit lySuit = new LingYuSuit();
                                lySuit.Suit         = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "SuitID", "0"));
                                lySuit.MinAttackV   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinAttackV", "0"));
                                lySuit.MaxAttackV   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxAttackV", "0"));
                                lySuit.MinMAttackV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinMAttackV", "0"));
                                lySuit.MaxMAttackV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxMAttackV", "0"));
                                lySuit.MinDefenseV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinDefenseV", "0"));
                                lySuit.MaxDefenseV  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxDefenseV", "0"));
                                lySuit.MinMDefenseV = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MinMDefenseV", "0"));
                                lySuit.MaxMDefenseV = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "MaxMDefenseV", "0"));
                                lySuit.HitV         = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "HitV", "0"));
                                lySuit.LifeV        = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "LifeV", "0"));
                                lySuit.JinBiCost    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItemLevel, "JinBiCost", "0"));
                                string   costGoods      = Global.GetDefAttributeStr(xmlItemLevel, "GoodsCost", "0");
                                string[] costGoodsField = costGoods.Split(',');
                                if (costGoodsField.Length != 2)
                                {
                                    LogManager.WriteLog(LogTypes.Error, string.Format("翎羽Type{0},级别{1}, 消耗物品配置错误", TypeID, lySuit.Suit));
                                    continue;
                                }

                                lySuit.GoodsCost    = Convert.ToInt32(costGoodsField[0]);
                                lySuit.GoodsCostCnt = Convert.ToInt32(costGoodsField[1]);

                                lyType.SuitDict[lySuit.Suit] = lySuit;

                                LingYuSuitLimit = Global.GMax(LingYuSuitLimit, lySuit.Suit);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时异常{1}", LingYuSuitUpFile, ex));
                }
            }

            #endregion

            #region 加载LingYuCollect

            xml = null;
            GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(LingYuCollectFile));
            xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(LingYuCollectFile));
            if (xml == null)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时出错!!!文件不存在", LingYuCollectFile));
            }
            else
            {
                try
                {
                    LingYuCollectList.Clear();
                    IEnumerable <XElement> xmlItems = xml.Elements();
                    foreach (var xmlItem in xmlItems)
                    {
                        if (null == xmlItem)
                        {
                            continue;
                        }

                        LingYuCollect lyCollect = new LingYuCollect();
                        lyCollect.Num      = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "Num", "0"));
                        lyCollect.NeedSuit = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "NeedSuit", "0"));
                        lyCollect.Luck     = Global.GetSafeAttributeDouble(xmlItem, "Luck");
                        lyCollect.DeLuck   = Global.GetSafeAttributeDouble(xmlItem, "DeLuck");

                        LingYuCollectList.Add(lyCollect);
                    }

                    //排序
                    LingYuCollectList.Sort((left, right) =>
                    {
                        if (left.NeedSuit > right.NeedSuit)
                        {
                            return(1);
                        }
                        else if (left.NeedSuit == right.NeedSuit)
                        {
                            if (left.Num > right.Num)
                            {
                                return(1);
                            }
                            else if (left.Num == right.Num)
                            {
                                return(0);
                            }
                            else
                            {
                                return(-1);
                            }
                        }
                        else
                        {
                            return(-1);
                        }
                    });
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("加载{0}时异常{1}", LingYuCollectFile, ex));
                }
            }

            #endregion
        }