示例#1
0
 public SkillAction(IScope scope, ICost cost, int power, int maxTimes, AttackType attackType,
     AttackDependency atkDependency, DefenseDependency defDependency, IScreenEffect screenEffect)
 {
     _scope = scope;
     _cost = cost;
     _power = power;
     _maxTimes = Math.Max(1, maxTimes);
     _attackType = attackType;
     _atkDependency = atkDependency;
     _defDependency = defDependency;
     _screenEffect = screenEffect;
 }
        public static int GetSkillValue(WarUnit doer, WarUnit taker, int power, AttackType type, AttackDependency atkDep, DefenseDependency defDep, out AdditionalEffect effect)
        {
            // 状態異常の結果を初期化
            effect = AdditionalEffect.なし;

            // 防御ステータスの決定
            int defStatus = 0;
            if (defDep == DefenseDependency.Defense)
            {
                if (!IsHit(taker, doer))
                    return 0;
                defStatus = taker.Status.Def;
            }
            else if (defDep == DefenseDependency.Resistivity)
            {
                defStatus = taker.Status.Res;
            }

            // 攻撃ステータスの決定
            int atkStatus = 0;
            if (atkDep == AttackDependency.Attack)
                atkStatus = (int)(doer.Status.Atk * 0.8);
            else if (atkDep == AttackDependency.Magic)
                atkStatus = doer.Status.Mag;

            // Attack=(Attack+random(8)+30)*技威力/100
            var atk = (atkStatus + WarGlobal.Random.Next(8) + 30) * power / 100;
            // Defense=Defense+30
            var def = defStatus + 30;

            if (AttackTypes.Attack.Contains(type))
            {
                // 状態異常の判定
                var resType = taker.Resistivity[type];
                if (AttackTypes.AbnormalCondition.Contains(type))
                {
                    if (resType == ResistivityType.弱い ||
                        (resType == ResistivityType.普通 && IsMagicConditionHit(doer, taker)))
                    {
                        effect = type - AttackType.毒 + AdditionalEffect.毒;
                    }
                    else if (resType == ResistivityType.強い ||
                        resType == ResistivityType.吸収)
                    {
                        // ダメージの処理は通常攻撃扱い
                        resType = taker.Resistivity[AttackType.物理];
                    }
                }
                else if (type == AttackType.吸収)
                {
                    // 吸収属性の吸収はミス
                    if (resType == ResistivityType.吸収)
                        return 0;
                    // 吸収属性があれば、ここでマイナスに反転。
                    effect = AdditionalEffect.吸収;
                }

                // ここで弱い属性が有る場合、Attackは二倍。強い属性があった場合、Defenseは3倍。
                if (resType == ResistivityType.弱い)
                    atk *= 2;
                else if (resType == ResistivityType.強い)
                    def *= 3;
            }

            //Attack^0.7*(Attack/(Defense+10+random(10)+0.5)*(20+random(5))/35
            var point = (int)(Math.Pow(atk, 0.7) * atk / (def + 10 + WarGlobal.Random.Next(10) + 0.5) * (20 + WarGlobal.Random.Next(5)) / 35);
            // ダメージが1以下なら1、999以上なら999。
            point = XMath.Center(point, 1, 999);

            return point;
        }