NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Vehicle/Data/VehicleConfigData.cs

304 lines
11 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using cfg.FightCfg;
using cfg.MonsterCfg;
2023-10-19 15:00:19 +08:00
using Framework;
using Gameplay.Common;
using Gameplay.Level;
using Gameplay.Unit.Data;
using Gameplay.Utils;
2024-09-06 18:11:35 +08:00
using UnityEngine;
2023-08-22 19:08:45 +08:00
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;
/// <summary>
/// 攻击距离缩放
/// </summary>
public List<float> attackDistanceScale = new List<float>()
{
1f
};
2023-08-22 19:08:45 +08:00
public int maxBulletCount;
public float reloadTime;
2024-06-20 13:30:39 +08:00
public float attackShiledScale;
public float attackHpScale;
2023-08-22 19:08:45 +08:00
public int moraleAttack;
public float scaleForHuman;
public float scaleForVehicle;
public float criticalRate;
public float criticalDamageScale;
public int weaponId;
2023-10-19 15:00:19 +08:00
public int sitCount;
2024-01-11 13:33:30 +08:00
public string prefabPath;
2023-08-22 19:08:45 +08:00
2023-10-19 15:00:19 +08:00
public int skillId;
2024-07-05 18:34:40 +08:00
public int deadEffectId;
public bool isAttackIgnoreBlock;
public float attackEndTime;
2024-10-18 14:53:50 +08:00
public int attackLoopCount;
public int ignoreDamage;
2024-01-11 13:33:30 +08:00
public DebugShowInfo debugShowInfo;
2024-10-10 19:06:51 +08:00
public VehicleAudioData audioData;
2024-09-06 18:11:35 +08:00
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");
return;
}
var batteryConfig = TableManager.Instance.Tables.BatteryConfig.GetOrDefault(rawConfig.WeaponId);
if (batteryConfig == null)
{
DebugUtil.LogError("VehicleConfigData.Init batteryConfig is null, weaponId:" + rawConfig.WeaponId);
return;
}
2024-10-10 19:06:51 +08:00
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;
2024-09-06 18:11:35 +08:00
level = monsterConfig.MonsterLevel;
2024-09-06 18:03:06 +08:00
attack = Mathf.RoundToInt(batteryConfig.DamagePower * monsterConfig.AttackFix);
defense = Mathf.RoundToInt(rawConfig.Defense * monsterConfig.DefenceFix);
hp = Mathf.RoundToInt(rawConfig.HP * monsterConfig.HPFix);
shield = 0;
ignoreDamage = rawConfig.ShieldCount;
moveSpeed = rawConfig.MoveSpeed;
turnSpeed = rawConfig.TurnSpeed;
crossLevel = rawConfig.MoveCrossLevel;
standLevel = rawConfig.StandCrossLevel;
attackDistance = batteryConfig.AttackDistance;
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;
scaleForHuman = batteryConfig.ScaleForHuman;
scaleForVehicle = batteryConfig.ScaleForVehicle;
isAttackIgnoreBlock = batteryConfig.AttackIgnoreBlock;
attackEndTime = batteryConfig.AttackSplitTime;
2024-09-06 18:03:06 +08:00
var skillUpgradeConfig = TableManager.Instance.Tables.VehicleSkllUpgrade.GetOrDefault(rawConfig.ID);
2024-09-06 18:03:06 +08:00
if (skillUpgradeConfig == null)
{
DebugUtil.LogError($"未找到敌人车辆技能配置:{rawConfig.ID}");
}
else
{
var skillLevelIndex = monsterConfig.SkillLevel - 1;
2024-09-06 18:03:06 +08:00
if (skillLevelIndex < 0)
{
skillLevelIndex = 0;
}
if (skillUpgradeConfig.SkillIdList.Count <= skillLevelIndex)
{
DebugUtil.LogError($"未找到敌人车辆技能配置:{rawConfig.ID} 等级:{monsterConfig.SkillLevel} 索引:{skillLevelIndex}");
2024-09-06 18:03:06 +08:00
// 使用最后一个技能
skillId = skillUpgradeConfig.SkillIdList[^1];
DebugUtil.LogError($"使用最后一个技能:{skillId}");
}
else
{
skillId = skillUpgradeConfig.SkillIdList[skillLevelIndex];
}
}
_InitTerrainSpecialParam(rawConfig.MalaAdjustTerrain, rawConfig.SupperAdjustTerrain);
}
private void _InitTerrainSpecialParam(List<ELevelTerrainType> noAdjust, List<ELevelTerrainType> spAdjust)
{
var adjustIndex = _GetAdjustIndex(noAdjust, spAdjust);
var speedScale = GLConfig.Inst.data.FightVehicleSpeedScaleParam[adjustIndex];
moveSpeed *= speedScale;
}
private int _GetAdjustIndex(List<ELevelTerrainType> noAdjust, List<ELevelTerrainType> spAdjust)
{
2024-11-21 14:38:35 +08:00
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;
}
2024-01-31 13:20:19 +08:00
public void Init(VehicleCultivateData rawConfig,
int passInLevel, int skillLevel)
2023-08-22 19:08:45 +08:00
{
2024-07-31 13:23:54 +08:00
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;
}
2024-10-10 19:06:51 +08:00
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;
2024-07-31 13:23:54 +08:00
configId = (int)rawConfig.Cfg.ID;
prefabPath = PathEx.GetVehicleGameModelPath(configId);
2023-08-22 19:08:45 +08:00
debugShowInfo = new DebugShowInfo();
debugShowInfo.configId = "VehicleConfig@" + configId;
debugShowInfo.name = rawConfig.Cfg.Name;
debugShowInfo.iconPath = rawConfig.Cfg.Icon;
level = passInLevel;
2023-08-22 19:08:45 +08:00
2024-01-31 13:20:19 +08:00
attack = rawConfig.Attack();
defense = rawConfig.Defense();
hp = rawConfig.Hp();
shield = 0;
ignoreDamage = rawConfig.Cfg.ShieldCount;
2023-08-22 19:08:45 +08:00
2024-01-31 13:20:19 +08:00
moveSpeed = rawConfig.Cfg.MoveSpeed;
turnSpeed = rawConfig.Cfg.TurnSpeed;
2023-08-22 19:08:45 +08:00
2024-01-31 13:20:19 +08:00
crossLevel = rawConfig.Cfg.MoveCrossLevel;
standLevel = rawConfig.Cfg.StandCrossLevel;
2023-08-22 19:08:45 +08:00
attackDistance = batteryConfig.AttackDistance;
2023-08-22 19:08:45 +08:00
shootCd = 1f / batteryConfig.FireRate;
attackDistanceScale = batteryConfig.ShootDistanceScale;
2023-08-22 19:08:45 +08:00
maxBulletCount = batteryConfig.MaxBulletCount;
reloadTime = batteryConfig.ReloadTime;
2023-08-22 19:08:45 +08:00
moraleAttack = batteryConfig.MoraleDamage;
2024-01-31 13:20:19 +08:00
criticalRate = rawConfig.Cfg.CriticalRate;
criticalDamageScale = rawConfig.Cfg.CriticalScale;
2023-08-22 19:08:45 +08:00
2024-07-05 18:34:40 +08:00
deadEffectId = rawConfig.Cfg.DeadEffectId;
2024-06-20 13:30:39 +08:00
sitCount = rawConfig.SeatCount();
2023-10-19 15:00:19 +08:00
2024-01-31 13:20:19 +08:00
weaponId = rawConfig.Cfg.WeaponId;
2023-08-22 19:08:45 +08:00
2024-06-20 13:30:39 +08:00
attackHpScale = rawConfig.AttackHpScale();
attackShiledScale = rawConfig.AttackShiledScale();
scaleForHuman = rawConfig.ScaleForHuman();
scaleForVehicle = rawConfig.ScaleForVehicle();
isAttackIgnoreBlock = batteryConfig.AttackIgnoreBlock;
attackEndTime = batteryConfig.AttackSplitTime;
attackLoopCount = batteryConfig.AttackLoopCount;
2024-01-31 13:20:19 +08:00
var skillConfig = TableManager.Instance.Tables.VehicleSkllUpgrade.Get(rawConfig.Cfg.ID);
2024-05-27 19:44:22 +08:00
if (skillConfig == null || skillConfig.SkillIdList.Count == 0)
2024-01-25 12:51:19 +08:00
{
2024-01-31 13:20:19 +08:00
DebugUtil.LogError($"未找到车辆技能配置:{rawConfig.Cfg.ID}");
2024-01-25 12:51:19 +08:00
skillId = -1;
}
else
{
var skillLevelIndex = skillLevel - 1;
2024-05-27 19:44:22 +08:00
if (skillConfig.SkillIdList.Count <= skillLevelIndex)
{
DebugUtil.LogError($"未找到车辆技能配置:{rawConfig.Cfg.ID} 等级:{skillLevel} 索引:{skillLevelIndex}");
// 使用最后一个技能
skillId = skillConfig.SkillIdList[^1];
DebugUtil.LogError($"使用最后一个技能:{skillId}");
}
else
{
skillId = skillConfig.SkillIdList[skillLevelIndex];
}
2024-01-25 12:51:19 +08:00
}
2023-10-19 15:00:19 +08:00
// TODO: 强制指定技能id
2024-01-17 14:31:53 +08:00
// skillId = 30009;
_InitTerrainSpecialParam(rawConfig.Cfg.MalaAdjustTerrain, rawConfig.Cfg.SupperAdjustTerrain);
2023-08-22 19:08:45 +08:00
}
}
}