Exemple #1
0
        /// <summary>
        /// 重新计算和设置角色从精灵奇缘系统活动的属性
        /// </summary>
        /// <param name="client"></param>
        /// <param name="notifyPorpsChangeInfo"></param>
        public void RefreshProps(GameClient client, bool notifyPorpsChangeInfo = true)
        {
            // 如果1.5的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot5))
            {
                return;
            }

            int sumPetLevel                  = 0;
            int findPetLevel                 = 0;
            int sumPetTianFuNum              = 0;
            int findPetTianFuNum             = 0;
            List <PetSkillInfo> petSkillList = new List <PetSkillInfo>();

            EquipPropItem petLevelAwardItem  = null;
            EquipPropItem petTianFuAwardItem = null;
            EquipPropItem petSkillAwardItem  = null;

            Dictionary <int, GoodsData>     havingPetDict     = new Dictionary <int, GoodsData>();
            Dictionary <int, EquipPropItem> groupPropItemDict = new Dictionary <int, EquipPropItem>();

            List <GoodsData> demonGoodsList = DamonMgr.GetDemonGoodsDataList(client);

            foreach (var goodsData in demonGoodsList)
            {
                GoodsData existGoodsData;
                if (!havingPetDict.TryGetValue(goodsData.GoodsID, out existGoodsData))
                {
                    existGoodsData         = new GoodsData();
                    existGoodsData.GoodsID = goodsData.GoodsID;
                    existGoodsData.GCount  = 0;
                    havingPetDict[existGoodsData.GoodsID] = existGoodsData;
                }

                existGoodsData.GCount++;
                sumPetLevel     += goodsData.Forge_level + 1; //潜规则,客户端显示的是这个值+1
                sumPetTianFuNum += Global.GetEquipExcellencePropNum(goodsData);

                petSkillList.AddRange(PetSkillManager.GetPetSkillInfo(goodsData));
            }

            lock (RuntimeData.Mutex)
            {
                //等级奇缘
                foreach (var item in RuntimeData.PetLevelAwardList)
                {
                    if (sumPetLevel >= item.Level && item.Level > findPetLevel)
                    {
                        findPetLevel      = item.Level;
                        petLevelAwardItem = item.PropItem;
                    }
                }

                //天赋奇缘
                foreach (var item in RuntimeData.PetTianFuAwardList)
                {
                    if (sumPetTianFuNum >= item.TianFuNum && item.TianFuNum > findPetTianFuNum)
                    {
                        findPetTianFuNum   = item.TianFuNum;
                        petTianFuAwardItem = item.PropItem;
                    }
                }

                //精灵组合
                foreach (var item in RuntimeData.PetGroupPropertyList)
                {
                    groupPropItemDict[item.Id] = null;
                    bool avalid = true;
                    foreach (var list in item.PetGoodsList)
                    {
                        GoodsData existGoodsData;
                        if (!havingPetDict.TryGetValue(list[0], out existGoodsData) || existGoodsData.GCount < list[1])
                        {
                            avalid = false;
                            break;
                        }
                    }

                    if (avalid)
                    {
                        groupPropItemDict[item.Id] = item.PropItem;
                    }
                }

                //精灵技能
                foreach (var item in RuntimeData.PetSkillAwardList)
                {
                    int sum = 0;
                    foreach (var p in item.SkillList)
                    {
                        var temp = from info in petSkillList
                                   where info.PitIsOpen && info.SkillID > 0 && info.SkillID == p
                                   select info;

                        if (temp.Any())
                        {
                            sum += temp.Count();
                        }
                    }

                    if (sum < item.SkillNum)
                    {
                        break;
                    }

                    petSkillAwardItem = item.GroupProp;
                }
            }

            client.ClientData.PropsCacheManager.SetExtProps(PropsSystemTypes.JingLingQiYuan, SubPropsTypes.Level, petLevelAwardItem);
            client.ClientData.PropsCacheManager.SetExtProps(PropsSystemTypes.JingLingQiYuan, SubPropsTypes.TianFuNum, petTianFuAwardItem);

            foreach (var groupPropItem in groupPropItemDict)
            {
                client.ClientData.PropsCacheManager.SetExtProps(PropsSystemTypes.JingLingQiYuan, SubPropsTypes.PetGroup, groupPropItem.Key, groupPropItem.Value);
            }

            client.ClientData.PropsCacheManager.SetExtProps(PropsSystemTypes.JingLingQiYuan, SubPropsTypes.PetSkill, petSkillAwardItem);

            if (notifyPorpsChangeInfo)
            {
                //通知客户端属性变化
                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

                // 总生命值和魔法值变化通知(同一个地图才需要通知)
                GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
            }
        }
 public void RefreshProps(GameClient client, bool notifyPorpsChangeInfo = true)
 {
     if (!GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot5))
     {
         int sumPetLevel       = 0;
         int findPetLevel      = 0;
         int sumPetTianFuNum   = 0;
         int findPetTianFuNum  = 0;
         int sumPetSkillLevel  = 0;
         int findPetSkillLevel = 0;
         List <PetSkillInfo>             petSkillList           = new List <PetSkillInfo>();
         EquipPropItem                   petLevelAwardItem      = null;
         EquipPropItem                   petTianFuAwardItem     = null;
         EquipPropItem                   petSkillAwardItem      = null;
         EquipPropItem                   petSkillLevelAwardItem = null;
         Dictionary <int, GoodsData>     havingPetDict          = new Dictionary <int, GoodsData>();
         Dictionary <int, EquipPropItem> groupPropItemDict      = new Dictionary <int, EquipPropItem>();
         List <GoodsData>                demonGoodsList         = DamonMgr.GetDemonGoodsDataList(client);
         foreach (GoodsData goodsData in demonGoodsList)
         {
             GoodsData existGoodsData;
             if (!havingPetDict.TryGetValue(goodsData.GoodsID, out existGoodsData))
             {
                 existGoodsData         = new GoodsData();
                 existGoodsData.GoodsID = goodsData.GoodsID;
                 existGoodsData.GCount  = 0;
                 havingPetDict[existGoodsData.GoodsID] = existGoodsData;
             }
             existGoodsData.GCount++;
             sumPetLevel     += goodsData.Forge_level + 1;
             sumPetTianFuNum += Global.GetEquipExcellencePropNum(goodsData);
             petSkillList.AddRange(PetSkillManager.GetPetSkillInfo(goodsData));
         }
         foreach (PetSkillInfo item in petSkillList)
         {
             sumPetSkillLevel += (item.PitIsOpen ? item.Level : 0);
         }
         lock (this.RuntimeData.Mutex)
         {
             foreach (PetLevelAwardItem item2 in this.RuntimeData.PetLevelAwardList)
             {
                 if (sumPetLevel >= item2.Level && item2.Level > findPetLevel)
                 {
                     findPetLevel      = item2.Level;
                     petLevelAwardItem = item2.PropItem;
                 }
             }
             foreach (PetTianFuAwardItem item3 in this.RuntimeData.PetTianFuAwardList)
             {
                 if (sumPetTianFuNum >= item3.TianFuNum && item3.TianFuNum > findPetTianFuNum)
                 {
                     findPetTianFuNum   = item3.TianFuNum;
                     petTianFuAwardItem = item3.PropItem;
                 }
             }
             foreach (PetGroupPropertyItem item4 in this.RuntimeData.PetGroupPropertyList)
             {
                 groupPropItemDict[item4.Id] = null;
                 bool avalid = true;
                 foreach (List <int> list in item4.PetGoodsList)
                 {
                     GoodsData existGoodsData;
                     if (!havingPetDict.TryGetValue(list[0], out existGoodsData) || existGoodsData.GCount < list[1])
                     {
                         avalid = false;
                         break;
                     }
                 }
                 if (avalid)
                 {
                     groupPropItemDict[item4.Id] = item4.PropItem;
                 }
             }
             foreach (PetSkillGroupInfo item5 in this.RuntimeData.PetSkillAwardList)
             {
                 int sum = 0;
                 using (List <int> .Enumerator enumerator8 = item5.SkillList.GetEnumerator())
                 {
                     while (enumerator8.MoveNext())
                     {
                         int p = enumerator8.Current;
                         IEnumerable <PetSkillInfo> temp = from info in petSkillList
                                                           where info.PitIsOpen && info.SkillID > 0 && info.SkillID == p
                                                           select info;
                         if (temp.Any <PetSkillInfo>())
                         {
                             sum += temp.Count <PetSkillInfo>();
                         }
                     }
                 }
                 if (sum < item5.SkillNum)
                 {
                     break;
                 }
                 petSkillAwardItem = item5.GroupProp;
             }
             foreach (PetSkillLevelAwardItem item6 in this.RuntimeData.PetSkillLevelAwardList)
             {
                 if (sumPetSkillLevel >= item6.Level && item6.Level > findPetSkillLevel)
                 {
                     findPetSkillLevel      = item6.Level;
                     petSkillLevelAwardItem = item6.PropItem;
                 }
             }
         }
         client.ClientData.PropsCacheManager.SetExtProps(new object[]
         {
             PropsSystemTypes.JingLingQiYuan,
             0,
             petLevelAwardItem
         });
         client.ClientData.PropsCacheManager.SetExtProps(new object[]
         {
             PropsSystemTypes.JingLingQiYuan,
             1,
             petTianFuAwardItem
         });
         foreach (KeyValuePair <int, EquipPropItem> groupPropItem in groupPropItemDict)
         {
             client.ClientData.PropsCacheManager.SetExtProps(new object[]
             {
                 PropsSystemTypes.JingLingQiYuan,
                 2,
                 groupPropItem.Key,
                 groupPropItem.Value
             });
         }
         client.ClientData.PropsCacheManager.SetExtProps(new object[]
         {
             PropsSystemTypes.JingLingQiYuan,
             3,
             petSkillAwardItem
         });
         client.ClientData.PropsCacheManager.SetExtProps(new object[]
         {
             PropsSystemTypes.JingLingQiYuan,
             4,
             petSkillLevelAwardItem
         });
         if (notifyPorpsChangeInfo)
         {
             GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
             GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
         }
     }
 }