132 lines
3.6 KiB
C#
132 lines
3.6 KiB
C#
using cfg.VehicleCfg;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Gameplay.Net;
|
|
using cfg.CharacterCfg;
|
|
using cfg;
|
|
using Framework;
|
|
using PhxhSDK;
|
|
|
|
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 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 int Hp()
|
|
{
|
|
return Cfg.Hps[UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.HP]-1];
|
|
|
|
}
|
|
public int Damage()
|
|
{
|
|
return Cfg.Damages[UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Damage] - 1];
|
|
|
|
}
|
|
public float MoveSpeed()
|
|
{
|
|
return Cfg.MoveSpeed;
|
|
}
|
|
public int BulletCapacity() {
|
|
return Cfg.BulletCount;
|
|
}
|
|
public int Defense()
|
|
{
|
|
return Cfg.Defenses[UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Defense] - 1];
|
|
|
|
}
|
|
|
|
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 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;
|
|
}
|
|
}
|