- 补充游戏核心逻辑
- 完成 TodOList P0
- 添加游戏内控制台便于调试
- 增加敌人互斥机制提高运算负载
- 优化互斥算法将游戏性能基准线拉到 1k 敌人
This commit is contained in:
@@ -8,50 +8,51 @@ namespace Entity.EntityData
|
||||
[Serializable]
|
||||
public class EnemyData : TargetableObjectData
|
||||
{
|
||||
[SerializeField] private EnemyType _enemyType;
|
||||
|
||||
[SerializeField] private int _entityTypeId;
|
||||
|
||||
[SerializeField] private float _speedBase = 0;
|
||||
|
||||
|
||||
[SerializeField] private int _dropCoin = 0;
|
||||
|
||||
|
||||
[SerializeField] private int _dropExp = 0;
|
||||
|
||||
|
||||
[SerializeField] private float _dropPercent = 0;
|
||||
|
||||
public EnemyData(int entityId, int typeId, int level) : base(
|
||||
entityId, typeId, CampType.Enemy)
|
||||
public EnemyData(int entityId, EnemyType enemyType, int level) : base(
|
||||
entityId, (int)enemyType, CampType.Enemy)
|
||||
{
|
||||
DREnemy enemyRow = GameEntry.DataTable.GetDataTableRow<DREnemy>(typeId);
|
||||
DREnemy enemyRow = GameEntry.DataTable.GetDataTableRow<DREnemy>((int)enemyType);
|
||||
|
||||
if (enemyRow == null)
|
||||
{
|
||||
throw new Exception($"Enemy data table row is missing, EnemyType='{enemyType}'.");
|
||||
}
|
||||
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
|
||||
_enemyType = enemyType;
|
||||
_entityTypeId = enemyRow.EntityTypeId;
|
||||
MaxHealthBase = enemyRow.MaxHealth + enemyRow.HpAddPerLevel * (effectiveLevel - 1);
|
||||
SpeedBase = enemyRow.Speed;
|
||||
DropCoin = enemyRow.DropCoin;
|
||||
DropExp = enemyRow.DropExp;
|
||||
DropPercent = enemyRow.DropPercent;
|
||||
_speedBase = enemyRow.Speed;
|
||||
_dropCoin = enemyRow.DropCoin;
|
||||
_dropExp = enemyRow.DropExp;
|
||||
_dropPercent = enemyRow.DropPercent;
|
||||
}
|
||||
|
||||
public EnemyType EnemyType => _enemyType;
|
||||
|
||||
public int EntityTypeId => _entityTypeId;
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
|
||||
public float SpeedBase
|
||||
{
|
||||
get => _speedBase;
|
||||
set => _speedBase = value;
|
||||
}
|
||||
public float SpeedBase => _speedBase;
|
||||
|
||||
public int DropCoin
|
||||
{
|
||||
get => _dropCoin;
|
||||
set => _dropCoin = value;
|
||||
}
|
||||
public int DropCoin => _dropCoin;
|
||||
|
||||
public int DropExp
|
||||
{
|
||||
get => _dropExp;
|
||||
set => _dropExp = value;
|
||||
}
|
||||
public int DropExp => _dropExp;
|
||||
|
||||
public float DropPercent
|
||||
{
|
||||
get => _dropPercent;
|
||||
set => _dropPercent = value;
|
||||
}
|
||||
public float DropPercent => _dropPercent;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user