コード例 #1
0
        /// <summary>
        /// 新建道具
        /// </summary>
        /// <param name="items">道具字典</param>
        public static void MakeMergeItem(Dictionary <int, int[]> items)
        {
            if (items.Count <= 0)
            {
                return;
            }

            DateFile df = DateFile.instance;

            foreach (KeyValuePair <int, int[]> item in items)
            {
                int id = int.Parse(df.GetItemDate(item.Key, 999)), surpluses = int.Parse(df.GetItemDate(item.Key, 901)), limit = int.Parse(df.GetItemDate(item.Key, 902)),
                                               level = int.Parse(df.GetItemDate(item.Key, 8)), type = int.Parse(df.GetItemDate(item.Key, 5));

                if (Main.settings.enabledSize && Main.settings.itemsSize > 1)
                {
                    int sizeCount = item.Value[1] / int.Parse(Main.settings.itemsSize.ToString());
                    int itemNaiJiu = item.Value[0], itemMaxNaiJiu = item.Value[1];
                    Main.logger.Log(sizeCount.ToString());
                    for (int i = 0; i <= sizeCount; i++)
                    {
                        int makeItemId = df.MakeNewItem(item.Key);
                        df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);

                        //耐久小于或等于0就创建为0的道具吧,然后结束循环。
                        //耐久大于合并大小才会继续拆,继续循环。
                        //耐久小于或者等于最大耐久就走最后一个,结束循环。
                        if (itemNaiJiu <= 0)
                        {
                            df.itemsDate[makeItemId][901] = "0";
                            df.itemsDate[makeItemId][902] = itemMaxNaiJiu.ToString();
                            break;
                        }
                        else if (itemNaiJiu > Main.settings.itemsSize)
                        {
                            df.itemsDate[makeItemId][901] = Main.settings.itemsSize.ToString();
                            df.itemsDate[makeItemId][902] = Main.settings.itemsSize.ToString();
                            itemNaiJiu    -= int.Parse(Main.settings.itemsSize.ToString());
                            itemMaxNaiJiu -= int.Parse(Main.settings.itemsSize.ToString());
                        }
                        else
                        {
                            df.itemsDate[makeItemId][901] = itemNaiJiu.ToString();
                            df.itemsDate[makeItemId][902] = itemMaxNaiJiu.ToString();
                            break;
                        }
                    }
                }
                else
                {
                    //不拆直接创建。
                    int makeItemId = df.MakeNewItem(item.Key);
                    df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                    df.itemsDate[makeItemId][901] = item.Value[0].ToString();
                    df.itemsDate[makeItemId][902] = item.Value[1].ToString();
                }
            }
        }
コード例 #2
0
ファイル: LKX_BookMerge.cs プロジェクト: zy9634/Taiwu_mods
        /// <summary>
        /// 执行合并道具
        /// </summary>
        public static void RunningMergeItems()
        {
            if (!Main.enabled || Main.settings.bookLevel.Count == 0 || Main.settings.bookMergeType.Count == 0)
            {
                return;
            }

            DateFile df = DateFile.instance;
            Dictionary <int, string[]> items   = new Dictionary <int, string[]>();
            Dictionary <int, int>      itemsId = new Dictionary <int, int>();

            if (df.actorItemsDate.TryGetValue(df.mianActorId, out itemsId))
            {
                Main.LevelSon = new List <int> {
                    DateFile.instance.enemyBorn, DateFile.instance.xxLevel, DateFile.instance.enemySize,
                    DateFile.instance.worldResource, DateFile.instance.randomHeir
                };

                //处理人物身上所有书籍
                List <int> buffer = itemsId.Keys.ToList();
                foreach (int itemId in buffer)
                {
                    string id = df.GetItemDate(itemId, 999), surpluses = df.GetItemDate(itemId, 901), limit = df.GetItemDate(itemId, 902),
                             level = df.GetItemDate(itemId, 8), type = df.GetItemDate(itemId, 5), group = df.GetItemDate(itemId, 98);
                    if (type != "21" || !Main.settings.bookMergeType.Contains(int.Parse(group)))
                    {
                        continue;
                    }
                    if (!Main.settings.bookLevel.Contains(int.Parse(level)) || id == "5005")
                    {
                        continue;
                    }

                    if (items.ContainsKey(int.Parse(id)))
                    {
                        items[int.Parse(id)][0] = (int.Parse(surpluses) + int.Parse(items[int.Parse(id)][0])).ToString();
                        items[int.Parse(id)][1] = (int.Parse(limit) + int.Parse(items[int.Parse(id)][1])).ToString();
                        items[int.Parse(id)][2] = ProcessingPages(df.itemsDate[itemId][33], items[int.Parse(id)][2], int.Parse(group), int.Parse(level));
                    }
                    else
                    {
                        items.Add(int.Parse(id), new string[] { surpluses, limit, df.itemsDate[itemId][33] });
                    }

                    df.LoseItem(df.mianActorId, itemId, itemsId[itemId], true);
                }

                //生成合并后的书籍
                foreach (KeyValuePair <int, string[]> item in items)
                {
                    int makeItemId = df.MakeNewItem(item.Key);
                    df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                    df.itemsDate[makeItemId][901] = item.Value[0];
                    df.itemsDate[makeItemId][902] = item.Value[1];
                    df.itemsDate[makeItemId][33]  = item.Value[2];
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 拆分药品
        /// </summary>
        public static void ResolveMergeDrugs()
        {
            if (!Main.enabled || Main.settings.drugsCount <= 0) return;

            DateFile df = DateFile.instance;
            Dictionary<int, int> items = new Dictionary<int, int>();
            Dictionary<int, int> itemsId = new Dictionary<int, int>();
            if (df.actorItemsDate.TryGetValue(df.mianActorId, out itemsId))
            {
                List<int> buffer = itemsId.Keys.ToList();
                foreach (int itemId in buffer)
                {
                    string id = df.GetItemDate(itemId, 999), surpluses = df.GetItemDate(itemId, 901), limit = df.GetItemDate(itemId, 902),
                        level = df.GetItemDate(itemId, 8), type = df.GetItemDate(itemId, 5);
                    
                    if (type != "31") continue;
                    if (!Main.settings.drugsLevel.Contains(int.Parse(level))) continue;
                    if (int.Parse(surpluses) < (Main.settings.drugsCount * Main.settings.drugsSize)) continue;

                    if (!items.ContainsKey(int.Parse(id))) items.Add(int.Parse(id), itemId);
                    
                }
                Main.logger.Log(items.Count.ToString());
                if (items.Count <= 0)
                {
                    Main.logger.Log("拆分失败:没有找到足够拆分的药品,合并后再试试。");
                }
                else
                {
                    foreach (KeyValuePair<int, int> item in items)
                    {
                        Dictionary<int, string> baseItem = df.itemsDate[item.Value];
                        int size = int.Parse(Main.settings.drugsSize.ToString()) + 1;
                        if (Main.settings.drugsSize <= 1) size = 2;
                        if (Main.settings.drugsSize > 5) size = 5;

                        for (int i = 0; i < Main.settings.drugsCount; i++)
                        {
                            if (int.Parse(df.itemsDate[item.Value][901]) == size) break;

                            int makeItemId = df.MakeNewItem(item.Key);
                            df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                            df.itemsDate[makeItemId][901] = size.ToString();
                            df.itemsDate[makeItemId][902] = size.ToString();
                            df.itemsDate[item.Value][901] = (int.Parse(df.itemsDate[item.Value][901]) - size).ToString();
                            df.itemsDate[item.Value][902] = (int.Parse(df.itemsDate[item.Value][902]) - size).ToString();
                        }
                    }
                    Main.logger.Log("拆分成功。");
                }
            }

            Main.logger.Log("拆分失败:没有进入游戏存档,无法读取数据。");
        }
コード例 #4
0
        /// <summary>
        /// 创建食物
        /// </summary>
        /// <param name="foods">合并好的食物字典</param>
        static void MakeFoods(Dictionary <int, Dictionary <int, string> > foods)
        {
            DateFile df = DateFile.instance;

            foreach (KeyValuePair <int, Dictionary <int, string> > food in foods)
            {
                int makeItemId = df.MakeNewItem(food.Key);
                df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                foreach (KeyValuePair <int, string> pair in food.Value)
                {
                    df.itemsDate[makeItemId][pair.Key] = pair.Value;
                }
            }
        }
コード例 #5
0
ファイル: Class1.cs プロジェクト: yyuueexxiinngg/Taiwu_mods
        /// <summary>
        /// 执行合并道具
        /// </summary>
        public static void RunningMergeItems()
        {
            if (!Main.enabled && Main.settings.mergeType.Count <= 0)
            {
                return;
            }

            DateFile df = DateFile.instance;
            Dictionary <int, int[]> items   = new Dictionary <int, int[]>();
            Dictionary <int, int>   itemsId = new Dictionary <int, int>();

            if (df.actorItemsDate.TryGetValue(df.mianActorId, out itemsId))
            {
                List <int> buffer = itemsId.Keys.ToList();
                foreach (int itemId in buffer)
                {
                    string id = df.GetItemDate(itemId, 999), surpluses = df.GetItemDate(itemId, 901), limit = df.GetItemDate(itemId, 902),
                             level = df.GetItemDate(itemId, 8), type = df.GetItemDate(itemId, 5);
                    if (!Main.settings.mergeType.Contains(int.Parse(type)))
                    {
                        continue;
                    }
                    if ((type == "35" || type == "34") && !Main.settings.itemLevel.Contains(int.Parse(level)))
                    {
                        continue;
                    }

                    if (items.ContainsKey(int.Parse(id)))
                    {
                        items[int.Parse(id)][0] += int.Parse(surpluses);
                        items[int.Parse(id)][1] += int.Parse(limit);
                    }
                    else
                    {
                        items.Add(int.Parse(id), new int[] { int.Parse(surpluses), int.Parse(limit) });
                    }

                    df.LoseItem(df.mianActorId, itemId, itemsId[itemId], true);
                }

                foreach (KeyValuePair <int, int[]> item in items)
                {
                    int makeItemId = df.MakeNewItem(item.Key);
                    df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                    df.itemsDate[makeItemId][901] = item.Value[0].ToString();
                    df.itemsDate[makeItemId][902] = item.Value[1].ToString();
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// 改變使用的裝備集合
        /// </summary>
        /// <param name="index">0~2</param>
        public static void ChangeEquipGroup(int index)
        {
            if (index < 0 || index >= 3)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            DateFile df = DateFile.instance;

            if (df.nowEquipConfigIndex == index)
            {
                return;
            }

            var equipToggleGroup = GetEquipToggleGroup();

            if (equipToggleGroup != null)
            {
                // Main.Logger.Debug("ChangeEquipGroup By UI");
                // 使用 現有的UI做切換, 避免UI顯示不正常
                equipToggleGroup.Set(index);
            }
            else
            {
                // UI尚未建立, 使用程式碼做切換
                if (df.mainActorequipConfig == null)
                {
                    return;
                }
                int mainActorId = df.MianActorID();
                Dictionary <int, int>    currentEquipConfig = df.mainActorequipConfig[df.nowEquipConfigIndex];
                Dictionary <int, string> playerActorsData   = df.actorsDate[mainActorId];

                // 脫下現在的裝備, 移動到身上(行李)
                foreach (KeyValuePair <int, int> slotItemPair in currentEquipConfig)
                {
                    int itemId = slotItemPair.Value;
                    int slot   = slotItemPair.Key;
                    if (itemId != 0 &&
                        itemId.ToString() == playerActorsData[slotItemPair.Key])
                    {
                        df.GetItem(mainActorId, itemId, 1, false, -1, 0);
                        playerActorsData[slot] = "0";
                    }
                }

                // 裝備 + 從行李內移除物件
                Dictionary <int, int> newEquipGroup = df.mainActorequipConfig[index];
                foreach (KeyValuePair <int, int> slotItemPair in newEquipGroup)
                {
                    int itemId = slotItemPair.Value;
                    int slot   = slotItemPair.Key;
                    if (itemId != 0 &&
                        df.HasItem(mainActorId, itemId))
                    {
                        df.LoseItem(mainActorId, itemId, 1, false, false);
                        playerActorsData[slot] = itemId.ToString();
                    }
                }
                df.nowEquipConfigIndex = index;
            }
        }
コード例 #7
0
        /// <summary>
        /// 执行合并道具
        /// </summary>
        public static void RunningMergeItems()
        {
            if (!Main.enabled || Main.settings.mergeType.Count <= 0) return;

            DateFile df = DateFile.instance;
            Dictionary<int, int[]> items = new Dictionary<int, int[]>();
            Dictionary<int, int> itemsId = new Dictionary<int, int>();
            if (df.actorItemsDate.TryGetValue(df.mianActorId, out itemsId))
            {
                List<int> buffer = itemsId.Keys.ToList();
                foreach (int itemId in buffer)
                {
                    string id = df.GetItemDate(itemId, 999), surpluses = df.GetItemDate(itemId, 901), limit = df.GetItemDate(itemId, 902),
                        level = df.GetItemDate(itemId, 8), type = df.GetItemDate(itemId, 5);

                    if (!Main.settings.mergeType.Contains(int.Parse(type))) continue;
                    if ((type == "37" || type == "41") && !Main.settings.itemLevel.Contains(int.Parse(level))) continue;
                    if (Main.settings.enabledSize && int.Parse(df.itemsDate[itemId][902]) >= Main.settings.itemsSize) continue;
                    
                    if (items.ContainsKey(int.Parse(id)))
                    {
                        items[int.Parse(id)][0] += int.Parse(surpluses);
                        items[int.Parse(id)][1] += int.Parse(limit);
                    }
                    else
                    {
                        items.Add(int.Parse(id), new int[] { int.Parse(surpluses), int.Parse(limit) });
                    }
                    
                    df.LoseItem(df.mianActorId, itemId, itemsId[itemId], true);
                }
                
                foreach (KeyValuePair<int, int[]> item in items)
                {
                    if (Main.settings.enabledSize && Main.settings.itemsSize > 0)
                    {
                        int sizeCount = (item.Value[1] / int.Parse(Main.settings.itemsSize.ToString()));
                        int itemNaiJiu = item.Value[0], itemMaxNaiJiu = item.Value[1];
                        
                        for (int i = 0; i <= sizeCount; i++)
                        {
                            int makeItemId = df.MakeNewItem(item.Key);
                            df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                            if (itemNaiJiu > Main.settings.itemsSize)
                            {
                                df.itemsDate[makeItemId][901] = Main.settings.itemsSize.ToString();
                                df.itemsDate[makeItemId][902] = Main.settings.itemsSize.ToString();
                                itemNaiJiu -= int.Parse(Main.settings.itemsSize.ToString());
                                itemMaxNaiJiu -= int.Parse(Main.settings.itemsSize.ToString());
                            }
                            else
                            {
                                df.itemsDate[makeItemId][901] = itemNaiJiu.ToString();
                                df.itemsDate[makeItemId][902] = itemMaxNaiJiu >= Main.settings.itemsSize ? Main.settings.itemsSize.ToString() : itemMaxNaiJiu.ToString();
                            }
                        }
                    }
                    else
                    {
                        int makeItemId = df.MakeNewItem(item.Key);
                        df.GetItem(df.mianActorId, makeItemId, 1, false, -1, 0);
                        df.itemsDate[makeItemId][901] = item.Value[0].ToString();
                        df.itemsDate[makeItemId][902] = item.Value[1].ToString();
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 拆分药品
        /// </summary>
        public static void ResolveMergeDrugs(int actorId)
        {
            if (!Main.enabled || Main.settings.drugsCount <= 0)
            {
                return;
            }

            DateFile df = DateFile.instance;
            Dictionary <int, int> items   = new Dictionary <int, int>();
            Dictionary <int, int> itemsId = new Dictionary <int, int>();

            if (df.actorItemsDate.TryGetValue(actorId, out itemsId))
            {
                //层层过滤,符合条件的就加入字典。
                List <int> buffer = itemsId.Keys.ToList();
                foreach (int itemId in buffer)
                {
                    string id = df.GetItemDate(itemId, 999), surpluses = df.GetItemDate(itemId, 901), limit = df.GetItemDate(itemId, 902),
                             level = df.GetItemDate(itemId, 8), type = df.GetItemDate(itemId, 5);

                    if (type != "31")
                    {
                        continue;
                    }
                    if (!Main.settings.drugsLevel.Contains(int.Parse(level)))
                    {
                        continue;
                    }
                    if (int.Parse(surpluses) < (Main.settings.drugsCount * Main.settings.drugsSize))
                    {
                        continue;
                    }

                    if (!items.ContainsKey(int.Parse(id)))
                    {
                        items.Add(int.Parse(id), itemId);
                    }
                }

                //处理拆分
                if (items.Count == 0)
                {
                    Main.logger.Log("拆分失败:没有找到足够拆分的药品,合并后再试试。");
                }
                else
                {
                    foreach (KeyValuePair <int, int> item in items)
                    {
                        //Dictionary<int, string> baseItem = df.itemsDate[item.Value];
                        Dictionary <int, string> baseItem = Items.GetItem(item.Value);
                        int size = int.Parse(Main.settings.drugsSize.ToString()) + 1;
                        if (Main.settings.drugsSize <= 1)
                        {
                            size = 2;
                        }
                        if (Main.settings.drugsSize > 5)
                        {
                            size = 5;
                        }

                        for (int i = 0; i < Main.settings.drugsCount; i++)
                        {
                            //if (int.Parse(df.itemsDate[item.Value][901]) == size || int.Parse(df.itemsDate[item.Value][901]) < size) break;
                            if (int.Parse(df.GetItemDate(item.Value, 901)) == size || int.Parse(df.GetItemDate(item.Value, 901)) < size)
                            {
                                break;
                            }

                            int makeItemId = df.MakeNewItem(item.Key);
                            df.GetItem(actorId, makeItemId, 1, false, -1, 0);
                            Items.SetItemProperty(makeItemId, 901, size.ToString());
                            Items.SetItemProperty(makeItemId, 902, size.ToString());
                            string itemString = (int.Parse(df.GetItemDate(item.Value, 901)) - size).ToString();
                            Items.SetItemProperty(item.Value, 901, itemString);
                            Items.SetItemProperty(item.Value, 902, itemString);
                            //df.itemsDate[makeItemId][901] = size.ToString();
                            //df.itemsDate[makeItemId][902] = size.ToString();
                            //df.itemsDate[item.Value][901] = (int.Parse(df.itemsDate[item.Value][901]) - size).ToString();
                            //df.itemsDate[item.Value][902] = (int.Parse(df.itemsDate[item.Value][902]) - size).ToString();
                        }
                    }
                    Main.logger.Log("拆分成功。");
                }
            }
            else
            {
                Main.logger.Log("拆分失败:没有进入游戏存档,无法读取数据。");
            }
        }