Example #1
0
        public override bool GetValue()
        {
            bool result;

            if (!Application.isPlaying)
            {
                result = false;
            }
            else
            {
                if (count < 1)
                {
                    return(false);
                }
                for (int i = 0; i < this.count; i++)
                {
                    Props uniqueProps = GlobalLib.CreateUniquePropsByValue(sourceId, value);
                    if (uniqueProps != null)
                    {
                        Game.GameData.Inventory.Add(uniqueProps.Id, 1, true);
                        if (base.Graph != null && (bool)base.Graph.GetVariable("IsShowMessage"))
                        {
                            this.ShowMessage(uniqueProps.Name, 1);
                        }
                    }
                }
                result = true;
            }
            return(result);
        }
Example #2
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);
        }