using System.Collections.Generic; using cfg.FightCfg; using cfg.MonsterCfg; using Framework; using Gameplay.Common; using Gameplay.Level; using Gameplay.Unit.Data; using Gameplay.Utils; using UnityEngine; namespace Gameplay.Vehicle.Data { public class VehicleConfigData { public int configId; public int level; public int attack; public int defense; public int hp; public int shield; public float moveSpeed; public float turnSpeed; public int attackDistance; public int standLevel; public int crossLevel; public float shootCd; /// /// 攻击距离缩放 /// public List attackDistanceScale = new List() { 1f }; public int maxBulletCount; public float reloadTime; public float attackShiledScale; public float attackHpScale; public int moraleAttack; public float scaleForCharacter = 1f; public float scaleForVehicle = 1f; public float scaleForBuilding = 1f; public float criticalRate; public float criticalDamageScale; public long weaponId; public int sitCount; public string prefabPath; public int skillId; public int deadEffectId; public bool isAttackIgnoreBlock; public float attackEndTime; public int attackLoopCount; public int defensePowerLevel; public int attackPowerLevel; public DebugShowInfo debugShowInfo; public VehicleAudioData audioData; public void Init(DataMonster monsterConfig) { var rawConfig = TableManager.Instance.Tables.VehicleConfig.GetOrDefault(monsterConfig.MonsterClassID); if (rawConfig == null) { DebugUtil.LogError("VehicleConfigData.Init rawConfig(Class DataEnemyVehicle) is null, MonsterClassID:" + monsterConfig.MonsterClassID); return; } var batteryConfig = TableManager.Instance.Tables.BatteryConfig.GetOrDefault(rawConfig.WeaponId); if (batteryConfig == null) { DebugUtil.LogError("VehicleConfigData.Init batteryConfig is null, weaponId:" + rawConfig.WeaponId); return; } audioData = new VehicleAudioData(); audioData.deadAudioId = rawConfig.DeadAudioId; audioData.walkLoopAudioId = rawConfig.WalkLoopAudioId; audioData.walkStopAudioId = rawConfig.WalkStopAudioId; audioData.IdleLoopAudioId = rawConfig.IdleLoopAudioId; audioData.ReadyAudioId = rawConfig.ReadyAudioId; configId = rawConfig.ID; prefabPath = PathEx.GetVehicleGameModelPath(configId); debugShowInfo = new DebugShowInfo(); debugShowInfo.configId = "EnemyVehicle@" + configId; debugShowInfo.name = rawConfig.Name; level = monsterConfig.MonsterLevel; attack = Mathf.RoundToInt(batteryConfig.DamagePower * monsterConfig.AttackFix); defense = Mathf.RoundToInt(rawConfig.Defense * monsterConfig.DefenceFix); hp = Mathf.RoundToInt(rawConfig.HP * monsterConfig.HPFix); shield = 0; defensePowerLevel = rawConfig.ShieldCount; moveSpeed = rawConfig.MoveSpeed; turnSpeed = rawConfig.TurnSpeed; crossLevel = rawConfig.MoveCrossLevel; standLevel = rawConfig.StandCrossLevel; attackDistance = batteryConfig.AttackDistance; attackPowerLevel = batteryConfig.AttackPowerLevel; shootCd = 1f / batteryConfig.FireRate; attackDistanceScale = batteryConfig.ShootDistanceScale; maxBulletCount = batteryConfig.MaxBulletCount; reloadTime = batteryConfig.ReloadTime; moraleAttack = batteryConfig.MoraleDamage; criticalRate = rawConfig.CriticalRate; criticalDamageScale = rawConfig.CriticalScale; deadEffectId = rawConfig.DeadEffectId; sitCount = rawConfig.SeatCount; weaponId = rawConfig.WeaponId; attackHpScale = batteryConfig.AttackHpScale; attackShiledScale = batteryConfig.AttackShiledScale; scaleForCharacter = batteryConfig.ScaleForHuman; scaleForVehicle = batteryConfig.ScaleForVehicle; scaleForBuilding = batteryConfig.ScaleForBuilding; isAttackIgnoreBlock = batteryConfig.AttackIgnoreBlock; attackEndTime = batteryConfig.AttackSplitTime; var skillUpgradeConfig = TableManager.Instance.Tables.VehicleSkllUpgrade.GetOrDefault(rawConfig.ID); if (skillUpgradeConfig == null) { DebugUtil.LogError($"未找到敌人车辆技能配置:{rawConfig.ID}"); } else { var skillLevelIndex = monsterConfig.SkillLevel - 1; if (skillLevelIndex < 0) { skillLevelIndex = 0; } if (skillUpgradeConfig.SkillIdList.Count <= skillLevelIndex) { DebugUtil.LogError($"未找到敌人车辆技能配置:{rawConfig.ID} 等级:{monsterConfig.SkillLevel} 索引:{skillLevelIndex}"); // 使用最后一个技能 skillId = skillUpgradeConfig.SkillIdList[^1]; DebugUtil.LogError($"使用最后一个技能:{skillId}"); } else { skillId = skillUpgradeConfig.SkillIdList[skillLevelIndex]; } } _InitTerrainSpecialParam(rawConfig.MalaAdjustTerrain, rawConfig.SupperAdjustTerrain); } private void _InitTerrainSpecialParam(List noAdjust, List spAdjust) { var adjustIndex = _GetAdjustIndex(noAdjust, spAdjust); var speedScale = GLConfig.Inst.data.FightVehicleSpeedScaleParam[adjustIndex]; moveSpeed *= speedScale; } private int _GetAdjustIndex(List noAdjust, List spAdjust) { if (LevelManager.Instance.CurrentLevel == null) return 0; var currentTerrain = LevelManager.Instance.CurrentLevel.GetLevelInfo().MapData.environmentType; if (noAdjust.Contains(currentTerrain)) { return 0; } if (spAdjust.Contains(currentTerrain)) { return 2; } return 0; } public void Init(VehicleCultivateData rawConfig, int passInLevel, int skillLevel) { if (rawConfig == null || rawConfig.Cfg == null) { DebugUtil.LogError("VehicleConfigData.Init rawConfig(Class VehicleCultivateData) is null"); return; } var batteryConfig = TableManager.Instance.Tables.BatteryConfig.GetOrDefault(rawConfig.Cfg.WeaponId); if (batteryConfig == null) { DebugUtil.LogError("VehicleConfigData.Init batteryConfig is null, weaponId:" + rawConfig.Cfg.WeaponId); return; } audioData = new VehicleAudioData(); audioData.ReadyAudioId = rawConfig.Cfg.ReadyAudioId; audioData.IdleLoopAudioId = rawConfig.Cfg.IdleLoopAudioId; audioData.walkLoopAudioId = rawConfig.Cfg.WalkLoopAudioId; audioData.walkStopAudioId = rawConfig.Cfg.WalkStopAudioId; audioData.deadAudioId = rawConfig.Cfg.DeadAudioId; configId = (int)rawConfig.Cfg.ID; prefabPath = PathEx.GetVehicleGameModelPath(configId); debugShowInfo = new DebugShowInfo(); debugShowInfo.configId = "VehicleConfig@" + configId; debugShowInfo.name = rawConfig.Cfg.Name; debugShowInfo.iconPath = rawConfig.Cfg.Icon; level = passInLevel; attack = rawConfig.Attack(); defense = rawConfig.Defense(); hp = rawConfig.Hp(); shield = 0; defensePowerLevel = rawConfig.Cfg.ShieldCount; moveSpeed = rawConfig.Cfg.MoveSpeed; turnSpeed = rawConfig.Cfg.TurnSpeed; crossLevel = rawConfig.Cfg.MoveCrossLevel; standLevel = rawConfig.Cfg.StandCrossLevel; attackDistance = batteryConfig.AttackDistance; shootCd = 1f / batteryConfig.FireRate; attackDistanceScale = batteryConfig.ShootDistanceScale; maxBulletCount = batteryConfig.MaxBulletCount; reloadTime = batteryConfig.ReloadTime; moraleAttack = batteryConfig.MoraleDamage; criticalRate = rawConfig.Cfg.CriticalRate; criticalDamageScale = rawConfig.Cfg.CriticalScale; deadEffectId = rawConfig.Cfg.DeadEffectId; sitCount = rawConfig.SeatCount(); weaponId = rawConfig.Cfg.WeaponId; attackHpScale = rawConfig.AttackHpScale(); attackShiledScale = rawConfig.AttackShiledScale(); scaleForCharacter = rawConfig.ScaleForHuman(); scaleForVehicle = rawConfig.ScaleForVehicle(); isAttackIgnoreBlock = batteryConfig.AttackIgnoreBlock; attackEndTime = batteryConfig.AttackSplitTime; attackLoopCount = batteryConfig.AttackLoopCount; var skillConfig = TableManager.Instance.Tables.VehicleSkllUpgrade.Get(rawConfig.Cfg.ID); if (skillConfig == null || skillConfig.SkillIdList.Count == 0) { DebugUtil.LogError($"未找到车辆技能配置:{rawConfig.Cfg.ID}"); skillId = -1; } else { var skillLevelIndex = skillLevel - 1; if (skillConfig.SkillIdList.Count <= skillLevelIndex) { DebugUtil.LogError($"未找到车辆技能配置:{rawConfig.Cfg.ID} 等级:{skillLevel} 索引:{skillLevelIndex}"); // 使用最后一个技能 skillId = skillConfig.SkillIdList[^1]; DebugUtil.LogError($"使用最后一个技能:{skillId}"); } else { skillId = skillConfig.SkillIdList[skillLevelIndex]; } } // TODO: 临时覆写 // skillId = 30029; // DebugUtil.LogError("临时覆写技能ID:" + skillId); _InitTerrainSpecialParam(rawConfig.Cfg.MalaAdjustTerrain, rawConfig.Cfg.SupperAdjustTerrain); } } }