Exemple #1
0
 public static void GiftSortByCategory(List <PropsInfo> sort, string mappingId)
 {
     if (giftSortMode.Value != SortMode.None)
     {
         //反正物品总共也没多少,开销应该不大,选择排序就完事了
         //先按分类排序
         if (giftSortMode.Value == SortMode.maxToMinByType || giftSortMode.Value == SortMode.minToMaxByType)
         {
             for (int i = 0; i < sort.Count; i++)
             {
                 int           minIndex         = i;
                 PropsCategory minPropsCategory = getPropsCategory(sort, i);
                 for (int j = i + 1; j < sort.Count; j++)
                 {
                     PropsCategory jPropsCategory = getPropsCategory(sort, j);
                     if ((giftSortMode.Value == SortMode.minToMaxByType && minPropsCategory > jPropsCategory) ||
                         (giftSortMode.Value == SortMode.maxToMinByType && minPropsCategory > jPropsCategory)
                         )
                     {
                         minIndex         = j;
                         minPropsCategory = getPropsCategory(sort, j);
                     }
                 }
                 if (i != minIndex)
                 {
                     PropsInfo temp = sort[i];
                     sort[i]        = sort[minIndex];
                     sort[minIndex] = temp;
                 }
             }
         }
     }
 }
Exemple #2
0
        public static void EquipSortByAttack(List <PropsInfo> sort)
        {
            if (equipSortMode.Value != SortMode.None)
            {
                //反正物品总共也没多少,开销应该不大,用选择排序就完事了

                //在按攻击力大小排序
                for (int i = 0; i < sort.Count; i++)
                {
                    PropsCategory iPropsCategory   = getPropsCategory(sort, i);
                    int           minIndex         = i;
                    int           minAttack        = getAttack(sort, i);
                    PropsCategory minPropsCategory = getPropsCategory(sort, i);
                    for (int j = i + 1; j < sort.Count; j++)
                    {
                        int           jAttack        = getAttack(sort, j);
                        PropsCategory jPropsCategory = getPropsCategory(sort, j);
                        if ((equipSortMode.Value == SortMode.minToMax && minAttack > jAttack) ||
                            (equipSortMode.Value == SortMode.maxToMin && minAttack < jAttack) ||
                            (equipSortMode.Value == SortMode.minToMaxByType && iPropsCategory == jPropsCategory && minAttack > jAttack) ||
                            (equipSortMode.Value == SortMode.maxToMinByType && iPropsCategory == jPropsCategory && minAttack < jAttack)
                            )
                        {
                            minIndex         = j;
                            minAttack        = getAttack(sort, j);
                            minPropsCategory = getPropsCategory(sort, j);
                        }
                    }
                    if (i != minIndex)
                    {
                        PropsInfo temp = sort[i];
                        sort[i]        = sort[minIndex];
                        sort[minIndex] = temp;
                    }
                }
            }
        }
Exemple #3
0
        public static void GiftSortByNumber(List <PropsInfo> sort, string mappingId)
        {
            if (giftSortMode.Value != SortMode.None)
            {
                //反正物品总共也没多少,开销应该不大,用选择排序就完事了

                //在按大小排序
                for (int i = 0; i < sort.Count; i++)
                {
                    PropsCategory iPropsCategory   = getPropsCategory(sort, i);
                    int           minIndex         = i;
                    int           minFavExp        = getFavExp(sort, mappingId, i);
                    PropsCategory minPropsCategory = getPropsCategory(sort, i);
                    for (int j = i + 1; j < sort.Count; j++)
                    {
                        int           jFavExp        = getFavExp(sort, mappingId, j);
                        PropsCategory jPropsCategory = getPropsCategory(sort, j);
                        if ((giftSortMode.Value == SortMode.minToMax && minFavExp > jFavExp) ||
                            (giftSortMode.Value == SortMode.maxToMin && minFavExp < jFavExp) ||
                            (giftSortMode.Value == SortMode.minToMaxByType && iPropsCategory == jPropsCategory && minFavExp > jFavExp) ||
                            (giftSortMode.Value == SortMode.maxToMinByType && iPropsCategory == jPropsCategory && minFavExp < jFavExp)
                            )
                        {
                            minIndex         = j;
                            minFavExp        = getFavExp(sort, mappingId, j);
                            minPropsCategory = getPropsCategory(sort, j);
                        }
                    }
                    if (i != minIndex)
                    {
                        PropsInfo temp = sort[i];
                        sort[i]        = sort[minIndex];
                        sort[minIndex] = temp;
                    }
                }
            }
        }
        public static bool ModExt_NewPropsUI(CtrlMedicine __instance)
        {
            var mapping = Traverse.Create(__instance).Field("mapping");
            var sort    = Traverse.Create(__instance).Field("sort").GetValue <List <PropsInfo> >();

            mapping.SetValue(GlobalLib.GetUICharacterMapping());
            sort.Clear();
            foreach (KeyValuePair <string, InventoryData> keyValuePair in Game.GameData.Inventory)
            {
                string key   = keyValuePair.Key;
                Props  props = Game.Data.Get <Props>(key);
                if (props != null && props.PropsType == PropsType.Medicine)
                {
                    bool show = false;
                    if (props.CanUseID != null && props.CanUseID.Count > 0)
                    {
                        for (int i = 0; i < props.CanUseID.Count; i++)
                        {
                            string text = props.CanUseID[i];
                            if (!text.IsNullOrEmpty() && text == mapping.GetValue <CharacterMapping>().Id)
                            {
                                show = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        show = true;
                        if (props.PropsCategory >= PropsCategory.Fist_Secret_Scroll && props.PropsCategory <= PropsCategory.Throw_Secret_Scroll && key.StartsWith("p_scroll"))
                        {
                            foreach (var pe in props.PropsEffect)
                            {
                                if (pe is PropsLearnSkill pls)
                                {
                                    PropsCategory skillType = Game.Data.Get <Skill>(pls.Id).Type;
                                    if (!GlobalLib.HasSkillType(mapping.GetValue <CharacterMapping>().InfoId, skillType))
                                    {
                                        show = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (show)
                    {
                        PropsInfo propsInfo = new PropsInfo(key)
                        {
                            ConditionStatus = ((props.UseTime == PropsUseTime.Battle) ? PropsInfo.PropsConditionStatus.UseTimeFail_Battle : PropsInfo.PropsConditionStatus.AllPass)
                        };
                        sort.Add(propsInfo);
                    }
                }
            }
            var view = Traverse.Create(__instance).Field("view").GetValue <UIMedicine>();

            view.UpdateProps(sort.Count);
            if (sort.Count <= 0)
            {
                view.UpdatePropsIntroduction(null);
            }
            return(false);
        }