public int Compare(BaseEquip x1, BaseEquip x2) { EquipManager em = DataManager.Manager <EquipManager>(); if (x1.Power > x2.Power) { return(1); } else if (x1.Power < x2.Power) { return(-1); } else { if (em.IsWearEquip(x1.QWThisID)) { return(1); } if (em.IsWearEquip(x2.QWThisID)) { return(1); } return(0); } }
/// <summary> ///从新排列圣魂 /// </summary> public void SortDataList() { if (null != dataList) { List <uint> equipList = new List <uint>(); List <uint> knapList = new List <uint>(); for (int i = 0; i < dataList.Count; i++) { if (emgr.IsWearEquip(dataList[i])) { equipList.Add(dataList[i]); } else { knapList.Add(dataList[i]); } } if (equipList.Count >= 2) { equipList.Sort((left, right) => { Muhon leftM = imgr.GetBaseItemByQwThisId <Muhon>(left); Muhon rightM = imgr.GetBaseItemByQwThisId <Muhon>(right); if (null != leftM && null != rightM) { if ((int)leftM.Position.y < (int)rightM.Position.y) { return(-1); } else { return(1); } } return(0); }); } if (knapList.Count > 0) { knapList.Sort((left, right) => { Muhon leftM = imgr.GetBaseItemByQwThisId <Muhon>(left); Muhon rightM = imgr.GetBaseItemByQwThisId <Muhon>(right); if (null != leftM && null != rightM) { if (leftM.Power > rightM.Power) { return(-1); } else { return(1); } } return(0); }); } dataList.Clear(); dataList.AddRange(equipList); dataList.AddRange(knapList); } }
List <uint> GetPushList(BaseItem bi = null) { EquipManager em = DataManager.Manager <EquipManager>(); if (em == null) { return(null); } Dictionary <GameCmd.EquipType, List <BaseEquip> > dic = GetWillCompareDic(bi); //Array enumArray = Enum.GetValues(typeof(GameCmd.EquipType)); //for (int i = 0; i < enumArray.Length; i++) //{ // GameCmd.EquipType type = (GameCmd.EquipType)enumArray.GetValue(i); // List<BaseEquip> wareList = em.GetEquipsByPackageType(PACKAGETYPE.PACKAGETYPE_EQUIP, type); // List<BaseEquip> packageList = em.GetEquipsByPackageType(PACKAGETYPE.PACKAGETYPE_MAIN, type); // wareList.AddRange(packageList); // //if(type == EquipType.EquipType_AdornlOne) // //{ // // int a = 10; // //} // List<BaseEquip> tempList = GetSortList(wareList); // dic.Add(type, tempList); //} List <uint> pushList = new List <uint>(); Array posenumArray = Enum.GetValues(typeof(GameCmd.EquipPos)); for (int i = 0; i < posenumArray.Length; i++) { GameCmd.EquipPos pos = (GameCmd.EquipPos)posenumArray.GetValue(i); if (pos != null) { EquipType type = em.GetEquipTypeByEquipPos(pos); if (type == EquipType.EquipType_AdornlOne || type == EquipType.EquipType_SoulOne || type == EquipType.EquipType_None) { continue; } if (!dic.ContainsKey(type)) { continue; } List <BaseEquip> allList = dic[type]; if (allList == null) { continue; } uint posEquipID = 0; for (int m = 0; m < allList.Count; m++) { BaseEquip tempEquip = allList[m]; if (em.IsWearEquip(tempEquip.QWThisID)) { continue; } if (em.IsEquipPos(pos, out posEquipID)) { ItemManager im = DataManager.Manager <ItemManager>(); BaseEquip wareEquip = im.GetBaseItemByQwThisId(posEquipID) as BaseEquip; if (wareEquip.Power < tempEquip.Power) { pushList.Add(tempEquip.QWThisID); allList.RemoveAt(m); break; } } else { pushList.Add(tempEquip.QWThisID); allList.RemoveAt(m); break; } } } } //处理戒指和圣魂 if (type == EquipType.EquipType_AdornlOne || type ==EquipType.EquipType_SoulOne) if (dic.ContainsKey(EquipType.EquipType_AdornlOne)) { List <BaseEquip> adornList = dic[EquipType.EquipType_AdornlOne]; if (adornList != null) { for (int i = 0; i < adornList.Count; i++) { if (i > 1) { break; } BaseEquip temp = adornList[i]; if (!em.IsWearEquip(temp.QWThisID)) { pushList.Add(temp.QWThisID); } } } } if (dic.ContainsKey(EquipType.EquipType_SoulOne)) { List <BaseEquip> soulList = dic[EquipType.EquipType_SoulOne]; if (soulList != null) { for (int i = 0; i < soulList.Count; i++) { if (i > 1) { break; } BaseEquip temp = soulList[i]; if (!em.IsWearEquip(temp.QWThisID)) { pushList.Add(temp.QWThisID); } } } } return(pushList); }