コード例 #1
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);
        }
コード例 #2
0
ファイル: GlobalLib.cs プロジェクト: zhb514685388/Plugin-Pow
        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);
        }