Exemplo n.º 1
0
    // 大招技能指示器解析,这部分有点冗余,是自己抽出来的,不是dota源解析,那dota是怎么实现技能指示器的
    private static ActionTarget ParseAbilityRange(JsonData json, AbilityData abilityData)
    {
        if (json == null)
        {
            return(null);
        }

        var actionTarget = new ActionTarget();
        var targetTeam   = GetEnumValue <MultipleTargetsTeam>(json, "AbilityUnitTargetTeam");

        actionTarget.SetTargetTeam(targetTeam);

        var abilityBehavior = abilityData.abilityBehavior;

        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_DIRECTIONAL) != 0)
        {
            var lineJsonData = GetJsonValue(json, "AbilityAoeLine");
            if (lineJsonData == null)
            {
                BattleLog.LogError("技能[{0}]行为是ABILITY_BEHAVIOR_LINE_AOE,未找到AbilityAoeLine配置", abilityData.configFileName);
                return(null);
            }

            var length    = (float)GetJsonValue(lineJsonData, "Length");
            var thickness = (float)GetJsonValue(lineJsonData, "Thickness");
            actionTarget.SetLineAoe(ActionMultipleTargetsCenter.CASTER, length, thickness);
        }

        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_SECTOR_AOE) != 0)
        {
            var sectorJsonData = GetJsonValue(json, "AbilityAoeSector");
            if (sectorJsonData == null)
            {
                BattleLog.LogError("技能[{0}]行为是ABILITY_BEHAVIOR_SECTOR_AOE,未找到AbilityAoeSector配置", abilityData.configFileName);
                return(null);
            }

            var sectorRadius = (float)GetJsonValue(sectorJsonData, "Radius");
            var angle        = (float)GetJsonValue(sectorJsonData, "Angle");
            actionTarget.SetSectorAoe(ActionMultipleTargetsCenter.CASTER, sectorRadius, angle);
        }

        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_RADIUS_AOE) != 0)
        {
            var radiusJson = GetJsonValue(json, "AbilityAoeRadius");
            if (radiusJson == null)
            {
                BattleLog.LogError("技能[{0}]行为是ABILITY_BEHAVIOR_RADIUS_AOE,未找到AbilityAoeRadius配置", abilityData.configFileName);
                return(null);
            }

            float radius = (float)radiusJson;
            actionTarget.SetRadiusAoe(ActionMultipleTargetsCenter.CASTER, radius);
        }

        return(actionTarget);
    }
Exemplo n.º 2
0
    private static ActionTarget ParseActionTarget(JsonData json, AbilityData abilityData)
    {
        if (json == null)
        {
            return(null);
        }
        var actionTarget = new ActionTarget();

        if (json.IsObject)
        {
            var aoeAreaJsonData = GetJsonValue(json, "AoeArea");
            if (aoeAreaJsonData == null)
            {
                BattleLog.LogError("技能[%s]中Target配置是区域目标配置,但是未配置AoeArea或者配置错误", abilityData.configFileName);
                return(null);
            }
            var targetCenter = GetEnumValue <ActionMultipleTargetsCenter>(json, "Center");

            var areaType = GetStringValue(aoeAreaJsonData, "AreaType");
            var abilityAreaDamageType = GetEnumValue <AOEType>(areaType);

            switch (abilityAreaDamageType)
            {
            case AOEType.Radius:
                float radius = (int)GetJsonValue(aoeAreaJsonData, "Radius");
                actionTarget.SetRadiusAoe(targetCenter, radius);
                break;

            case AOEType.Line:
                JsonData lineJsonData = (int)GetJsonValue(aoeAreaJsonData, "Line");
                if (lineJsonData == null)
                {
                    BattleLog.LogError("技能[{0}]中Target配置是区域目标配置,但是未配置Line", abilityData.configFileName);
                    return(null);
                }
                var length    = (float)GetJsonValue(lineJsonData, "Length");
                var thickness = (float)GetJsonValue(lineJsonData, "Thickness");
                actionTarget.SetLineAoe(targetCenter, length, thickness);
                break;

            case AOEType.Sector:
                JsonData sectorJsonData = GetJsonValue(json, "Sector");
                if (sectorJsonData == null)
                {
                    BattleLog.LogError("技能[{0}]中Target配置是区域目标配置,但是未配置Sector", abilityData.configFileName);
                    return(null);
                }
                var sectorRadius = (float)GetJsonValue(sectorJsonData, "Radius");
                var angle        = (float)GetJsonValue(sectorJsonData, "Angle");
                actionTarget.SetSectorAoe(targetCenter, sectorRadius, angle);
                break;

            default:
                break;
            }
            var teamJsonData      = GetStringValue(json, "Teams");
            var abilityTargetTeam = GetEnumValue <MultipleTargetsTeam>(teamJsonData);
            actionTarget.SetTargetTeam(abilityTargetTeam);
        }
        else
        {
            var target = (ActionSingTarget)Enum.Parse(typeof(ActionSingTarget), json.ToString());
            actionTarget.SetSingTarget(target);
        }
        return(actionTarget);
    }