Esempio n. 1
0
        public Affix GenerateAffix(Character character, string name, int tier = 0, int roll = 0)
        {
            var affixData = GameData.Affixes.FirstOrDefault(x => x.Name == name);

            if (affixData == null)
            {
                return(null);
            }

            roll = Math.Max(roll, 1);
            var affix = new Affix(character, affixData, tier, roll);

            if (affixData.Conditions != null)
            {
                foreach (var conditionLine in affixData.Conditions)
                {
                    string[] postParams     = null;
                    var      parenthesisIdx = conditionLine.IndexOf('(');
                    var      condName       = conditionLine;
                    if (parenthesisIdx != -1)
                    {
                        condName = conditionLine.Substring(0, parenthesisIdx);
                        var parameterList = conditionLine.Substring(parenthesisIdx + 1, conditionLine.IndexOf(')') - parenthesisIdx - 1);
                        postParams = Array.ConvertAll(parameterList.Split(','), p => p.Trim());
                    }

                    var condData = GameData.Conditions.First(x => x.Name == condName);
                    if (condData != null)
                    {
                        var condType  = (ConditionType)Enum.Parse(typeof(ConditionType), condData.Type);
                        var condition = condData.Condition;
                        affix.AddNode(new ScriptedCondition(affix, condType, () => LuaContext, condition, postParams));
                        break;
                    }
                }
            }

            var affixType = (AffixType)Enum.Parse(typeof(AffixType), affixData.Type);

            switch (affixType)
            {
            case AffixType.AttributeModifier:
                affix.AddNode(new AttributeModifier(affix));
                break;

            case AffixType.Logic:
                affix.AddNode(new LogicNode(affix, () => LuaContext, affixData));
                break;
            }

            return(affix);
        }
Esempio n. 2
0
 public FrenzyBuff(D4Hero hero)
     : base(hero)
 {
     _frenzyAffix = new Affix(_hero.Character, _frenzyAffixData, 0, 0);
     _frenzyAffix.AddNode(new AttributeModifier(_frenzyAffix, false));
 }