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