迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public class EnemyData : TargetableObjectData
|
||||
{
|
||||
private readonly EnemyConfig _enemyConfig;
|
||||
private readonly EnemyType _enemyType;
|
||||
|
||||
public EnemyData(int entityId, EnemyConfig enemyConfig, EnemyType enemyType, int level)
|
||||
: base(enemyConfig != null ? enemyConfig.Prefab : string.Empty, entityId, CampType.Enemy)
|
||||
{
|
||||
_enemyConfig = enemyConfig;
|
||||
_enemyType = enemyType;
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
MaxHealthBase = _enemyConfig != null
|
||||
? _enemyConfig.MaxHealth + _enemyConfig.HpAddPerLevel * (effectiveLevel - 1)
|
||||
: 100;
|
||||
}
|
||||
|
||||
public EnemyType EnemyType => _enemyType;
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
|
||||
public int AttackDamage => _enemyConfig?.AttackDamage ?? 0;
|
||||
|
||||
public float AttackCooldown => _enemyConfig?.AttackCooldown ?? 1f;
|
||||
|
||||
public float AttackRange => _enemyConfig?.AttackRange ?? 1.5f;
|
||||
|
||||
public float SpeedBase => _enemyConfig?.Speed ?? 2f;
|
||||
|
||||
public int DropCoin => _enemyConfig?.CoinDrop ?? 0;
|
||||
|
||||
public int DropExp => _enemyConfig?.ExpDrop ?? 0;
|
||||
|
||||
public float DropPercent => _enemyConfig?.DropPercent ?? 0f;
|
||||
|
||||
public float Scale => _enemyConfig?.Scale ?? 1f;
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_enemyConfig != null &&
|
||||
!string.IsNullOrEmpty(_enemyConfig.Color) &&
|
||||
ColorUtility.TryParseHtmlString(_enemyConfig.Color, out Color color))
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
return Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, string> Params => null;
|
||||
|
||||
public bool TryGetParam(string key, out string value)
|
||||
{
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user