Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static bool ModPatch_BattleAction(BattleAction __instance, ref bool __result)
        {
            if (!Application.isPlaying || __instance.battleId.IsNullOrEmpty())
            {
                __result = false;
                return(false);
            }
            string     battleId   = __instance.battleId;
            BattleArea battleArea = Game.Data.Get <BattleArea>(battleId);
            BattleGrid battleGrid = Game.Data.Get <BattleGrid>(battleArea?.BattleMap);

            if (battleGrid == null)
            {
                battleGrid = Randomizer.GetOneFromData <BattleGrid>(battleArea?.BattleMap);
                if (battleGrid != null)
                {
                    BattleArea battleAreaClone = battleArea.Clone <BattleArea>();
                    battleAreaClone.Id        = "!" + battleAreaClone.Id;
                    battleAreaClone.BattleMap = battleGrid.Id;  // 复写mapId
                    ModExtensionSaveData.AddTempItem(battleAreaClone);
                    battleId = battleAreaClone.Id;
                }
            }
            string mapId = battleGrid?.MapId;

            Console.WriteLine("当前MapId=" + Game.GameData.MapId);
            Console.WriteLine("需要MapId=" + mapId);
            if (mapId == Game.GameData.MapId)
            {
                Game.FSM.SendEvent("BATTLE", new Heluo.FSM.Main.BattleEventArgs()
                {
                    BattleId = battleId
                });
                __result = true;
            }
            else
            {
                CachedBattleId = battleId;
                Console.WriteLine("设置BattleId=" + CachedBattleId);
                Game.FSM.SendEvent("LOADING", new LoadingEventArgs
                {
                    MapId       = mapId,
                    CinematicId = null,
                    TimeStage   = Heluo.Manager.TimeStage.None,
                    LoadType    = LoadType.Default
                });
                __result = true;
            }
            return(false);
        }
Ejemplo n.º 3
0
        // Token: 0x0600423A RID: 16954 RVA: 0x00170F7C File Offset: 0x0016F17C
        public override bool GetValue()
        {
            bool result;

            if (!Application.isPlaying)
            {
                result = false;
            }
            else
            {
                if (this.count < 1)
                {
                    return(false);
                }
                string[] array = this.extraIds.Trim().Split(new char[]
                {
                    ','
                });
                for (int i = 0; i < this.count; i++)
                {
                    Props props = Game.Data.Get <Props>(sourceId) ?? Randomizer.GetOneFromData <Props>(sourceId);
                    if (props == null)
                    {
                        return(false);
                    }
                    Props props2 = props.Clone <Props>();
                    props2.Id   = "$fp_" + props.Id;
                    props2.Name = string.Format("<color=#FFEEDD>{0}+</color>", props.Name);
                    if (props2.PropsEffect == null)
                    {
                        props2.PropsEffect = new List <PropsEffect>();
                    }
                    if (props2.BuffList == null)
                    {
                        props2.BuffList = new List <string>();
                    }
                    if (props2.PropsEffectDescription == null)
                    {
                        props2.PropsEffectDescription = "";
                    }
                    foreach (string id in array)
                    {
                        Props props3 = Game.Data.Get <Props>(id) ?? Randomizer.GetOneFromData <Props>(id);
                        if (props3 == null)
                        {
                            continue;
                        }
                        if (props3.PropsEffect != null)
                        {
                            props2.PropsEffect.AddRange(props3.PropsEffect);
                        }
                        if (props3.BuffList != null)
                        {
                            props2.BuffList.AddRange(props3.BuffList);
                        }
                        if (!props3.PropsEffectDescription.IsNullOrEmpty())
                        {
                            Props props4 = props2;
                            props4.PropsEffectDescription += string.Format("\n附加:{0}", props3.PropsEffectDescription);
                        }
                    }
                    ModExtensionSaveData.AddUniqueItem(props2);
                    Game.GameData.Inventory.Add(props2.Id, 1, true);
                    if (base.Graph != null && (bool)base.Graph.GetVariable("IsShowMessage"))
                    {
                        this.ShowMessage(props2.Name, 1);
                    }
                }
                result = true;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public override bool GetValue()
        {
            bool result;

            if (!Application.isPlaying)
            {
                result = false;
            }
            else
            {
                if (this.count < 1)
                {
                    return(false);
                }
                for (int i = 0; i < this.count; i++)
                {
                    Props props;
                    if (!this.isMantra)
                    {
                        Skill skill = Game.Data.Get <Skill>(sourceId) ?? Randomizer.GetOneFromData <Skill>(sourceId);
                        props = new Props
                        {
                            Id            = "scroll_" + skill.Id,
                            Description   = skill.Description,
                            PropsType     = PropsType.Medicine,
                            PropsCategory = skill.Type - 101 + 401,
                            Name          = skill.Name + "秘籍",
                            PropsEffect   = new List <PropsEffect>
                            {
                                new PropsLearnSkill(skill.Id)
                            },
                            PropsEffectDescription = "学会独特招式:" + skill.Name
                        };
                    }
                    else
                    {
                        Mantra mantra = Game.Data.Get <Mantra>(sourceId) ?? Randomizer.GetOneFromData <Mantra>(sourceId);
                        props = new Props
                        {
                            Id            = "scroll_" + mantra.Id,
                            Description   = mantra.Description,
                            PropsType     = PropsType.Medicine,
                            PropsCategory = PropsCategory.InternalStyle_Secret_Scroll,
                            Name          = mantra.Name + "秘籍",
                            PropsEffect   = new List <PropsEffect>
                            {
                                new PropsLearnMantra(mantra.Id)
                            },
                            PropsEffectDescription = "学会独特心法:" + mantra.Name
                        };
                    }
                    ModExtensionSaveData.AddUniqueItem(props);
                    Game.GameData.Inventory.Add(props.Id, 1, true);
                    if (base.Graph != null && (bool)base.Graph.GetVariable("IsShowMessage"))
                    {
                        this.ShowMessage(props.Name, 1);
                    }
                }
                result = true;
            }
            return(result);
        }
Ejemplo n.º 5
0
 public T Get <T>(string id) where T : Item
 {
     return(data.Get <T>(id) ?? ModExtensionSaveData.GetItem <T>(id));
 }
Ejemplo n.º 6
0
        public static Props CreateUniquePropsByValue(string sourceId, int value)
        {
            Props props = Game.Data.Get <Props>(sourceId) ?? Randomizer.GetOneFromData <Props>(sourceId);

            if (props == null)
            {
                return(null);
            }
            Props props2 = props.Clone <Props>();

            if (props2.PropsEffect == null)
            {
                props2.PropsEffect = new List <PropsEffect>();
            }
            if (props2.BuffList == null)
            {
                props2.BuffList = new List <string>();
            }
            if (props2.PropsEffectDescription == null)
            {
                props2.PropsEffectDescription = "";
            }
            List <CharacterProperty> list = ((CharacterProperty[])Enum.GetValues(typeof(CharacterProperty))).ToList();

            list.Remove(CharacterProperty.Affiliation);
            list.Remove(CharacterProperty.Contribution);
            list.Remove(CharacterProperty.HP);
            list.Remove(CharacterProperty.MP);
            int           num   = value;
            List <string> list2 = new List <string>();

            while (num > 0 && list.Count > 0)
            {
                CharacterProperty characterProperty = list.Random();
                int num2;
                int num3;
                if (characterProperty < CharacterProperty.Attack)
                {
                    num2 = UnityEngine.Random.Range(0, num + value / 2);
                    num3 = num2 * 3 / 20 * 20;
                    num2 = num3 / 3;
                }
                else if (characterProperty < CharacterProperty.Hit)
                {
                    num2 = UnityEngine.Random.Range(-value / 2, num + value);
                    num3 = num2 / 5 * 5;
                    num2 = num3;
                }
                else if (characterProperty < CharacterProperty.Move)
                {
                    num2 = UnityEngine.Random.Range(-value / 2, num + value);
                    num3 = num2 / 5;
                    num2 = num3 * 5;
                }
                else
                {
                    num2 = UnityEngine.Random.Range(0, num + value / 2);
                    num3 = (num2 + 40) / 100;
                    num2 = Math.Max(0, num3 * 100 - 40);
                }
                if (num3 != 0)
                {
                    list.Remove(characterProperty);
                    PropsBattleProperty propsBattleProperty = new PropsBattleProperty
                    {
                        Type      = PropsEffectType.BattleProperty,
                        Property  = characterProperty,
                        isForever = false,
                        Value     = num3
                    };
                    props2.PropsEffect.Add(propsBattleProperty);
                    list2.Add(string.Format("{0}{1}{2}", Game.Data.Get <StringTable>("Property_" + Enum.GetName(typeof(CharacterProperty), characterProperty)).Text, (num3 > 0) ? "+" : "", num3));
                    num -= num2;
                }
            }
            Props props3 = props2;

            props3.PropsEffectDescription = string.Concat(new object[]
            {
                props3.PropsEffectDescription,
                "\n附加:",
                string.Join(",", list2)
            });
            ModExtensionSaveData.AddUniqueItem(props2);
            return(props2);
        }