NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/VehicleCultivate/VehicleDataHelper.cs

109 lines
3.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using cfg.VihecleCultivateCfg;
using Framework;
using Gameplay;
using Gameplay.Level;
using Gameplay.Vehicle.Data;
public static class VehicleDataHelper
{
public const int NotAdapt = 0;
public const int Adapt = 1;
public const int VeryAdapt = 2;
public static int GetVehicleSkillId(int vehicleId)
{
VehicleCultivateData vehicleInfo = VehicleCultivateDataManager.Instance.GetVehicleCultivateData((uint)vehicleId);
int skillLv = (int)vehicleInfo.SumBonus(BonusType.SkillLv);
var skillLevelInfo = TableManager.Instance.Tables.VehicleSkllUpgrade.Get(vehicleInfo.Cfg.ID);
if (skillLevelInfo == null || skillLevelInfo.SkillIdList.Count == 0)
{
DebugUtil.LogError("载具id为{0}技能等级为{1}的表没配", vehicleInfo.Cfg.ID, skillLv);
return -1;
}
var levelIndex = skillLv;
if (levelIndex >= skillLevelInfo.SkillIdList.Count)
{
DebugUtil.LogError($"数据需求等级{skillLv}超过配置等级{skillLevelInfo.SkillIdList.Count},此处返回最大等级");
return skillLevelInfo.SkillIdList[^1];//-1;
}
return skillLevelInfo.SkillIdList[levelIndex];
}
public static BonusType GetBonusTypeByTerrainID(int terrainId)
{
switch (terrainId)
{
case 1:
return BonusType.TerrainPlain;
case 2:
return BonusType.TerrainMountain;
case 4:
return BonusType.TerrainForest;
case 5:
return BonusType.TerrainSnow;
}
DebugUtil.LogError("因为VehicleBonusType暂时不需要其他地形类型所以妹写");
return BonusType.TerrainPlain;
}
public static string GetTerrainAdaptStr(int terrainAdaptVal)
{
switch (terrainAdaptVal)
{
case NotAdapt:
return CommonUtils. GetLocalizeText("vehicleCultivate_NotAdapt");
case Adapt:
return CommonUtils.GetLocalizeText("vehicleCultivate_Adapt");
case VeryAdapt:
return CommonUtils.GetLocalizeText("vehicleCultivate_TeHua");
}
DebugUtil.LogError("载具的地形适应配置错了载具upbonus表");
return "拉取中";
}
public static string GetVehiclePicPath(int iD)
{
var vehicleCfg = TableManager.Instance.Tables.VehicleConfig.GetOrDefault(iD);
if (vehicleCfg == null)
{
DebugUtil.LogError("载具配置表中没有id为{0}的配置", iD);
return null;
}
DebugUtil.Log("====当前VehicleConfig内Icon项暂未使用如有特殊需要请在此更改====\n已自动传递UIHeadPath内图片地址配置");
return CommonUtils.GetDefaultVehicleHeadPath((uint)iD);
return vehicleCfg.Icon;
}
public static VehicleConfigData CombineConfigData(VehicleCultivateData infoData)
{
var rawConfig = infoData;
// 临时写死
var level = 1;
// 因为里面有-1
var skillLevel = infoData.SkillLevel() + 1;
var configData = new VehicleConfigData();
configData.Init(rawConfig, level, skillLevel);
return configData;
}
public static VehicleConfigData CombineEnemyConfigData(LevelData.NPCInfo npcInfo)
{
var monsterConfig = TableManager.Instance.Tables.Monster.GetOrDefault(npcInfo.id);
var configData = new VehicleConfigData();
var rawConfig = TableManager.Instance.Tables.EnemyVehicleConfig.GetOrDefault(monsterConfig.MonsterClassID);
if (rawConfig == null)
{
DebugUtil.LogError("EnemyVehicleConfig表中没有id为{0}的配置", npcInfo.id);
return null;
}
configData.Init(rawConfig, npcInfo.level);
return configData;
}
}