コード例 #1
0
        public static bool Reforge_Execute(CtrlForge __instance)
        {
            if (isReforgeMode)
            {
                var       t             = Traverse.Create(__instance);
                int       categoryIndex = t.Field("categoryIndex").GetValue <int>();
                int       equipIndex    = t.Field("equipIndex").GetValue <int>();
                var       array         = t.Field("sort").Field("array").GetValue() as List <ForgeInfo>[];
                ForgeInfo forgeInfo     = array[categoryIndex][equipIndex];

                Console.WriteLine("重铸");
                string id    = forgeInfo.Equip.Id;
                Props  item  = Game.Data.Get <Props>(id);
                int    price = GetReforgePrice(item);

                Console.WriteLine("id=" + id);
                string sourceId = ModExtensionSaveData.GetUniqueSourceId(id);
                Console.WriteLine("sourceId=" + sourceId);
                Props source = Game.Data.Get <Props>(sourceId);
                Console.WriteLine("sourceName=" + source.Name);

                int.TryParse(item.Remark, out int value);
                value = Math.Max(5, value + UnityEngine.Random.Range(-10, 20));
                Props newProps = GlobalLib.CreateUniquePropsByValue(sourceId, value);
                newProps.Name   = source.Name + "+"; // mark as reforged
                newProps.Remark = value.ToString();  // use remark to save value
                Game.GameData.Inventory.Add(newProps.Id, 1);
                Game.GameData.Inventory.Remove(id, 1);
                if (id != sourceId)
                {
                    ModExtensionSaveData.RemoveUniqueItem <Props>(id);
                }
                Game.GameData.Money -= price;

                ForgeInfo newForgeInfo = new ForgeInfo {
                    Id = newProps.Id, IsConditionPass = true
                };
                Traverse.Create(newForgeInfo).Property("Item").SetValue(new Forge()
                {
                    Id      = newProps.Id,
                    PropsId = newProps.Id,
                });
                Traverse.Create(newForgeInfo).Property("Equip").SetValue(newProps);
                InventoryData inventoryData = Game.GameData.Inventory[id];
                if (inventoryData != null)
                {
                    array[categoryIndex].Add(newForgeInfo);
                }
                else
                {
                    array[categoryIndex][equipIndex] = newForgeInfo;
                }

                t.Field("view").GetValue <UIForge>().UpdateEquip(array[categoryIndex].Count, false, true);
                t.Field("view").GetValue <UIForge>().UpdateMoney(Game.GameData.Money.ToString());
                return(false);
            }
            return(true);
        }
コード例 #2
0
 public static bool Reforge_UpdateNew(CtrlForge __instance)
 {
     if (isReforgeMode)
     {
         var array = Traverse.Create(__instance).Field("sort").Field("array").GetValue() as List <ForgeInfo>[];
         for (int i = 0; i < 5; i++)
         {
             Traverse.Create(__instance).Field("view").Method("UpdateTabNotice", i, false).GetValue();//this.view.HideTabBtn(k);
         }
         return(false);
     }
     return(true);
 }
コード例 #3
0
 public static bool Reforge_UpdateEquipBtn(CtrlForge __instance, IScrollItme item)
 {
     if (isReforgeMode)
     {
         var       t             = Traverse.Create(__instance);
         int       categoryIndex = t.Field("categoryIndex").GetValue <int>();
         var       array         = t.Field("sort").Field("array").GetValue() as List <ForgeInfo>[];
         ForgeInfo forgeInfo     = array[categoryIndex][item.Index];
         Forge     item2         = forgeInfo.Item;
         Props     equip         = forgeInfo.Equip;
         forgeInfo.Dialog.Clear();
         int price = GetReforgePrice(equip);
         if (Game.GameData.Money < price)
         {
             forgeInfo.IsConditionPass = false;
             for (int j = 1; j < 3; j++)
             {
                 forgeInfo.Dialog.Add(string.Format("SecondaryInterface031{0}", j));
             }
         }
         InventoryData inventoryData = Game.GameData.Inventory[equip.Id];
         if (forgeInfo.Dialog.Count <= 0)
         {
             forgeInfo.IsConditionPass = true;
             for (int l = 1; l < 3; l++)
             {
                 forgeInfo.Dialog.Add(string.Format("SecondaryInterface034{0}", l));
             }
         }
         ForgeScrollInfo forgeScrollInfo = new ForgeScrollInfo
         {
             ItemName        = equip.Name,
             ItemIcon        = Game.Resource.Load <Sprite>(string.Format(GameConfig.PropsCategoryPath, (int)equip.PropsCategory)),
             Remark          = price.ToString(),
             IsNew           = false,
             IsShowSign      = item2.IsSpecial,
             IsConditionPass = forgeInfo.IsConditionPass
         };
         if (item != null)
         {
             item.UpdateWidget(new object[]
             {
                 forgeScrollInfo
             });
         }
         return(false);
     }
     return(true);
 }
コード例 #4
0
        public static void Reforge_OnShow(CtrlForge __instance)
        {
            if (isReforgeMode)
            {
                var array = Traverse.Create(__instance).Field("sort").Field("array").GetValue() as List <ForgeInfo>[];
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] != null)
                    {
                        array[i].Clear();
                    }
                    else
                    {
                        array[i] = new List <ForgeInfo>();
                    }
                }
                List <string> showed = new List <string>();
                Game.GameData.Inventory.GetDictionary();
                foreach (var key in Game.GameData.Inventory.Keys)
                {
                    Props props = Game.Data.Get <Props>(key);
                    if (props == null)
                    {
                        continue;
                    }
                    PropsCategory propsCategory = props.PropsCategory;
                    int           index         = -1;
                    switch (propsCategory)
                    {
                    case PropsCategory.Fist:
                    case PropsCategory.Leg:
                        index = 0;
                        break;

                    case PropsCategory.Sword:
                    case PropsCategory.Blade:
                        index = 1;
                        break;

                    case PropsCategory.Long:
                    case PropsCategory.Short:
                        index = 2;
                        break;

                    case PropsCategory.DualWielding:
                    case PropsCategory.Special:
                        index = 3;
                        break;

                    case PropsCategory.Armor:
                        index = 4;
                        break;
                    }
                    if (index >= 0)
                    {
                        ForgeInfo forgeInfo = new ForgeInfo
                        {
                            Id = key,
                            IsConditionPass = true
                        };
                        Traverse.Create(forgeInfo).Property("Item").SetValue(new Forge()
                        {
                            Id      = key,
                            PropsId = key,
                        });
                        Traverse.Create(forgeInfo).Property("Equip").SetValue(props);
                        array[index].Add(forgeInfo);
                    }
                }
            }
        }