/*
     * "Damage":
     * {
     *    "Target":"TARGET",
     *    "DamageFlags" : ["DAMAGE_FLAG_CRIT","DAMAGE_FLAG_LIFELINK"],
     *    "DamageType" : "DAMAGE_TYPE_PHYSICAL",
     *    "ValueSource":
     *    {
     *      "ValueBasicParams":[0, 0],
     *      "ValueAdditionParams":
     *      [
     *       {
     *        "ValueSourceType":"SOURCE_TYPE_PHYSICAL_ATTACK",
     *        "ValueSourceParams":[27500, 0]
     *       }
     *      ]
     *    }
     *    "OnSuccess":
     *    {
     *        "FireSound":
     *        {
     *            "SoundType":"SOUND_NORMAL",
     *            "SoundName":99082
     *        }
     *    }
     * }*/
    private static D2Action CreateDamageAction(JsonData json, ActionTarget actionTarget, AbilityData abilityData)
    {
        var damageTypeConfig = GetStringValue(json, "DamageType");

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

        var damageType       = GetEnumValue <AbilityDamageType>(damageTypeConfig);
        var damageFlagConfig = GetJsonValue(json, "DamageFlags");

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

        AbilityDamageFlag damageFlag = ParseDamageFlagArray(damageFlagConfig);

        var damageValueSource             = ParseValueSource(json, abilityData);
        var dealDamageSuccessActionConfig = GetJsonValue(json, "OnSuccess");
        var actions         = ParseActions(dealDamageSuccessActionConfig, abilityData);
        var d2Action_Damage = new D2Action_Damage(damageType, damageFlag, damageValueSource, actions, actionTarget);

        return(d2Action_Damage);
    }
Example #2
0
 public D2Action_Damage(AbilityDamageType damageType, AbilityDamageFlag damageFlag,
                        AbilityValueSource damageValueSource, List <D2Action> successActions, ActionTarget actionTarget) : base(actionTarget)
 {
     this.damageType      = damageType;
     this.damageFlag      = damageFlag;
     m_SuccessActions     = successActions;
     m_AbilityValueSource = damageValueSource;
 }
    // 造成伤害
    public static void ApplyDamage(BattleUnit caster, BattleUnit victim, AbilityDamageType damageType,
                                   AbilityDamageFlag damageFlag, AbilityValueSource damageValueSource, string configName)
    {
        int            casterLevel    = caster.GetLevel();
        BattleProperty casterProperty = caster.GetProperty();
        BattleProperty victimProperty = victim.GetProperty();
        float          abilityValue   = damageValueSource.GetAbilityValue(casterLevel, casterProperty, victimProperty);
        float          finalDamage    = CalcDamageByDamageType(abilityValue, damageType, casterProperty, victimProperty);

        // 护盾
        // 吸血

        victim.UpdateHP(-finalDamage);
        BattleLog.LogRpgBattleAttacker(BattleLogic.instance.logicFrame, caster, victim, configName, finalDamage);
    }