63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using SepCore.Definition;
|
|
using UnityEngine;
|
|
|
|
namespace SepCore.Entity
|
|
{
|
|
[Serializable]
|
|
public class EnemyData : TargetableObjectData
|
|
{
|
|
private readonly EnemyConfig _enemyConfig;
|
|
|
|
public EnemyData(int entityId, EnemyConfig enemyConfig, int level)
|
|
: base(enemyConfig.Prefab, entityId, CampType.Enemy)
|
|
{
|
|
_enemyConfig = enemyConfig;
|
|
int effectiveLevel = Mathf.Max(1, level);
|
|
MaxHealthBase = enemyConfig.MaxHealth + enemyConfig.HpAddPerLevel * (effectiveLevel - 1);
|
|
}
|
|
|
|
public EnemyType EnemyType => _enemyConfig.EnemyType;
|
|
|
|
public string LogicType => _enemyConfig.LogicType;
|
|
|
|
public override int MaxHealthBase { get; }
|
|
|
|
public int AttackDamage => _enemyConfig.AttackDamage;
|
|
|
|
public float AttackCooldown => _enemyConfig.AttackCooldown;
|
|
|
|
public float AttackRange => _enemyConfig.AttackRange;
|
|
|
|
public float SpeedBase => _enemyConfig.Speed;
|
|
|
|
public int DropCoin => _enemyConfig.CoinDrop;
|
|
|
|
public int DropExp => _enemyConfig.ExpDrop;
|
|
|
|
public float DropPercent => _enemyConfig.DropPercent;
|
|
|
|
public float Scale => _enemyConfig.Scale;
|
|
|
|
public Color Color
|
|
{
|
|
get
|
|
{
|
|
// 空/非法颜色值视为无染色(乘以白色)。
|
|
return ColorUtility.TryParseHtmlString(_enemyConfig.Color, out Color color)
|
|
? color
|
|
: Color.white;
|
|
}
|
|
}
|
|
|
|
public IReadOnlyDictionary<string, string> Params => null;
|
|
|
|
public bool TryGetParam(string key, out string value)
|
|
{
|
|
value = null;
|
|
return false;
|
|
}
|
|
}
|
|
}
|