228 lines
6.5 KiB
C#
228 lines
6.5 KiB
C#
using cfg.ActorCfg;
|
|
using cfg.VehicleCfg;
|
|
using cfg.VihecleCultivateCfg;
|
|
using Framework;
|
|
using PhxhSDK;
|
|
using System.Collections.Generic;
|
|
using Gameplay;
|
|
|
|
public class VehicleCultivateDataManager : Singlenton<VehicleCultivateDataManager>, IInitable
|
|
{
|
|
public List<VehicleCultivateData> DataList;
|
|
public Dictionary<uint, VehicleCultivateData> DataDic;
|
|
|
|
void IInitable.Init()
|
|
{
|
|
DataList = new List<VehicleCultivateData>();
|
|
DataDic = new Dictionary<uint, VehicleCultivateData>();
|
|
|
|
}
|
|
|
|
void IInitable.Release()
|
|
{
|
|
DataList.Clear();
|
|
DataDic.Clear();
|
|
}
|
|
public void Add(Gameplay.Net.VehicleInfo info)
|
|
{
|
|
VehicleCultivateData info2;
|
|
|
|
if (DataDic.TryGetValue(info.nID, out info2))
|
|
{
|
|
DataDic[info.nID].Refresh(info);
|
|
}
|
|
else
|
|
{
|
|
info2 = new VehicleCultivateData();
|
|
info2.Refresh(info);
|
|
DataList.Add(info2);
|
|
DataDic[info.nID] = info2;
|
|
|
|
}
|
|
}
|
|
|
|
public void AddAllCfgVehicles()
|
|
{
|
|
var allConfigList = TableManager.Instance.Tables.VehicleConfig.DataList;
|
|
for (int i = 0; i < allConfigList.Count; i++)
|
|
{
|
|
var configItem = allConfigList[i];
|
|
var nId = (uint)configItem.ID;
|
|
if (DataDic.ContainsKey(nId))
|
|
{
|
|
continue;
|
|
}
|
|
var info2 = new VehicleCultivateData();
|
|
info2.Cfg = configItem;
|
|
info2.nID = nId;
|
|
DataList.Add(info2);
|
|
DataDic[nId] = info2;
|
|
}
|
|
}
|
|
|
|
|
|
public VehicleCultivateData GetVehicleCultivateData(uint selectID)
|
|
{
|
|
VehicleCultivateData info;
|
|
if (DataDic.TryGetValue(selectID, out info))
|
|
{
|
|
return info;
|
|
}
|
|
else
|
|
{
|
|
DebugUtil.LogError("该角色找不到没有Id为 {0}的载具", selectID);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public class VehicleCultivateData : Gameplay.Net.VehicleInfo
|
|
{
|
|
public DataVehicle Cfg;
|
|
|
|
public VehicleCultivateData(uint ID,ushort[] UpgradeCountParam)
|
|
{
|
|
nID = ID;
|
|
for (ushort i = 0; i < UpgradeCount.Length; i++)
|
|
{
|
|
UpgradeCount[i] = UpgradeCountParam[i];
|
|
|
|
}
|
|
}
|
|
public VehicleCultivateData() { }
|
|
|
|
public string Name => CommonUtils.GetLocalizeText(Cfg.Name);
|
|
|
|
public int Hp()
|
|
{
|
|
return Cfg.Hps[UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.HP]]+(int)SumBonus(BonusType.Hp);
|
|
|
|
}
|
|
|
|
public float SumBonus(BonusType bType)
|
|
{
|
|
float count = 0;
|
|
VehicleUpgradeBonusAttri vTable = TableManager.Instance.Tables.VehicleUpgradeBonusAttri;
|
|
for (int i = 0; i < vTable.DataList.Count; i++)
|
|
{
|
|
if ((vTable.DataList[i].BonusType == bType) && (vTable.DataList[i].SumCount<SumPowerLevel()))
|
|
{
|
|
count += (int)vTable.DataList[i].BonusPropertyCount;
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
public int Attack()
|
|
{
|
|
return Cfg.Damages[UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Damage]];
|
|
|
|
}
|
|
public float MoveSpeed()
|
|
{
|
|
return Cfg.MoveSpeed+SumBonus(BonusType.MoveSpeed);
|
|
}
|
|
public int BulletCapacity() {
|
|
return Cfg.BulletCount;
|
|
}
|
|
public int Defense()
|
|
{
|
|
return Cfg.Defenses[UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Defense]];
|
|
|
|
}
|
|
|
|
public void Refresh(Gameplay.Net.VehicleInfo info)
|
|
{
|
|
nID = info.nID;
|
|
for (int i = 0; i < info.UpgradeCount.Length; i++)
|
|
{
|
|
UpgradeCount[i] = (ushort)info.UpgradeCount[i];
|
|
|
|
}
|
|
Cfg = TableManager.Instance.Tables.VehicleConfig.GetOrDefault((int)nID);
|
|
}
|
|
|
|
public int SumPowerLevel()
|
|
{
|
|
int lv = 0;
|
|
for (int i = 0; i < UpgradeCount.Length; i++)
|
|
{
|
|
lv += UpgradeCount[i];
|
|
}
|
|
return lv;
|
|
}
|
|
public float GetMaxHp()
|
|
{
|
|
return Cfg.Hps[Cfg.Hps.Count - 1] + VehicleCulitvateLevelUpBonusTableHelper.GetMaxValBonusByID(nID, BonusType.Hp);
|
|
|
|
}
|
|
public float GetMaxAttack()
|
|
{
|
|
return Cfg.Damages[Cfg.Damages.Count - 1];
|
|
}
|
|
public float GetMaxDenfense()
|
|
{
|
|
return Cfg.Defenses[Cfg.Defenses.Count - 1];
|
|
}
|
|
public int SeatCount()
|
|
{
|
|
return Cfg.SeatCount+(int)SumBonus(BonusType.SeatCount);
|
|
}
|
|
public int SumPowerMaxLevel()
|
|
{
|
|
int lv = 0;
|
|
|
|
VehicleUpgrade vehicleUpgradeTab = TableManager.Instance.Tables.VehicleUpgrade;
|
|
for (int i = 0; i < vehicleUpgradeTab.DataList.Count; i++)
|
|
{
|
|
if (vehicleUpgradeTab.DataList[i].ID==Cfg.ID)
|
|
{
|
|
lv += vehicleUpgradeTab.DataList[i].MaxCount;
|
|
}
|
|
}
|
|
return lv;
|
|
|
|
}
|
|
public bool IsMaxHpLv()
|
|
{
|
|
return UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.HP] >= TableManager.Instance.Tables.VehicleUpgrade.Get((int)nID, cfg.ActorCfg.VihecleUpgradeType.HP).MaxCount;
|
|
}
|
|
public bool IsMaxDamageLv()
|
|
{
|
|
return UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Damage] >= TableManager.Instance.Tables.VehicleUpgrade.Get((int)nID, cfg.ActorCfg.VihecleUpgradeType.Damage).MaxCount;
|
|
}
|
|
public bool IsMaxMoveSpeedLv()
|
|
{
|
|
return UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.MoveSpeed - 1] >= TableManager.Instance.Tables.VehicleUpgrade.Get((int)nID, cfg.ActorCfg.VihecleUpgradeType.MoveSpeed).MaxCount;
|
|
}
|
|
public bool IsMaxBulletCountLv()
|
|
{
|
|
return UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.BulletCount - 1] >= TableManager.Instance.Tables.VehicleUpgrade.Get((int)nID, cfg.ActorCfg.VihecleUpgradeType.BulletCount).MaxCount;
|
|
}
|
|
public bool IsMaxDefenseCountLv()
|
|
{
|
|
return UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Defense - 1] >= TableManager.Instance.Tables.VehicleUpgrade.Get((int)nID, cfg.ActorCfg.VihecleUpgradeType.Defense).MaxCount;
|
|
}
|
|
|
|
public string GetTerrainAdapt(BonusType terrainType)//仅供地形使用
|
|
{
|
|
VehicleUpgradeBonusAttri vTable = TableManager.Instance.Tables.VehicleUpgradeBonusAttri;
|
|
int terrinBonusVal=Cfg.TerrainPlain;
|
|
for (int i = 0; i <vTable.DataList.Count ; i++)
|
|
{
|
|
if (vTable.DataList[i].SumCount<SumPowerLevel())
|
|
{
|
|
if (vTable.DataList[i].BonusType==BonusType.TerrainPlain)
|
|
{
|
|
terrinBonusVal = (int)vTable.DataList[i].BonusPropertyCount;
|
|
}
|
|
}
|
|
}
|
|
return VehicleDataHelper.GetTerrainAdaptStr(terrinBonusVal);
|
|
|
|
}
|
|
|
|
|
|
}
|