重构清理敌人类
This commit is contained in:
@@ -8,55 +8,47 @@ namespace SepCore.Entity
|
||||
[Serializable]
|
||||
public class EnemyData : TargetableObjectData
|
||||
{
|
||||
private readonly EnemyConfig _enemyConfig;
|
||||
public EnemyConfig Config { get; }
|
||||
|
||||
public EnemyData(int entityId, EnemyConfig enemyConfig, int level)
|
||||
: base(enemyConfig.Prefab, entityId, CampType.Enemy)
|
||||
{
|
||||
_enemyConfig = enemyConfig;
|
||||
Config = enemyConfig;
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
MaxHealthBase = enemyConfig.MaxHealth + enemyConfig.HpAddPerLevel * (effectiveLevel - 1);
|
||||
}
|
||||
|
||||
public EnemyType EnemyType => _enemyConfig.EnemyType;
|
||||
public EnemyType EnemyType => Config.EnemyType;
|
||||
|
||||
public string LogicType => _enemyConfig.LogicType;
|
||||
public string LogicType => Config.LogicType;
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
|
||||
public int AttackDamage => _enemyConfig.AttackDamage;
|
||||
public int AttackDamage => Config.AttackDamage;
|
||||
|
||||
public float AttackCooldown => _enemyConfig.AttackCooldown;
|
||||
public float AttackCooldown => Config.AttackCooldown;
|
||||
|
||||
public float AttackRange => _enemyConfig.AttackRange;
|
||||
public float AttackRange => Config.AttackRange;
|
||||
|
||||
public float SpeedBase => _enemyConfig.Speed;
|
||||
public float SpeedBase => Config.Speed;
|
||||
|
||||
public int DropCoin => _enemyConfig.CoinDrop;
|
||||
public int DropCoin => Config.CoinDrop;
|
||||
|
||||
public int DropExp => _enemyConfig.ExpDrop;
|
||||
public int DropExp => Config.ExpDrop;
|
||||
|
||||
public float DropPercent => _enemyConfig.DropPercent;
|
||||
public float DropPercent => Config.DropPercent;
|
||||
|
||||
public float Scale => _enemyConfig.Scale;
|
||||
public float Scale => Config.Scale;
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get
|
||||
{
|
||||
// 空/非法颜色值视为无染色(乘以白色)。
|
||||
return ColorUtility.TryParseHtmlString(_enemyConfig.Color, out Color color)
|
||||
return ColorUtility.TryParseHtmlString(Config.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SepCore.Entity
|
||||
public class EnemyProjectileData : EntityDataBase
|
||||
{
|
||||
public EnemyProjectileData(int entityId, int ownerEntityId, CampType ownerCamp, int attackDamage,
|
||||
float speed, float lifeTime, Vector3 direction, string assetName = "BulletHandgun")
|
||||
float speed, float lifeTime, Vector3 direction, string assetName = "Projectile")
|
||||
: base(assetName, entityId)
|
||||
{
|
||||
OwnerEntityId = ownerEntityId;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 敌人状态
|
||||
/// </summary>
|
||||
public enum EnemyStateType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 无
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 攻击
|
||||
/// </summary>
|
||||
Attack = 1,
|
||||
/// <summary>
|
||||
/// 待机
|
||||
/// </summary>
|
||||
Idle = 2,
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
Seek = 3,
|
||||
/// <summary>
|
||||
/// 追逐
|
||||
/// </summary>
|
||||
Chase = 4,
|
||||
/// <summary>
|
||||
/// 死亡
|
||||
/// </summary>
|
||||
Dead = 5,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d55e30fdec251d141bab19b1b87806b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,15 +18,31 @@ public sealed partial class GlobalConfig : Luban.BeanBase
|
||||
{
|
||||
WeaponCapacity = _buf.ReadInt();
|
||||
PropMaxCount = _buf.ReadInt();
|
||||
PlayerEntity = _buf.ReadString();
|
||||
PlayerEntity_Ref = null;
|
||||
WeaponRecycleRate = _buf.ReadInt();
|
||||
ShopGoodsCount = _buf.ReadInt();
|
||||
ShopPriceRandomPercent = _buf.ReadInt();
|
||||
ShopMinPrice = _buf.ReadInt();
|
||||
LevelUpRefreshPriceBase = _buf.ReadInt();
|
||||
LevelUpRewardCount = _buf.ReadInt();
|
||||
EnemyGroupName = _buf.ReadString();
|
||||
SpawnEnemyMaxCount = _buf.ReadInt();
|
||||
SpawnDistanceFromPlayer = _buf.ReadInt();
|
||||
EnemySpawnDistanceMin = _buf.ReadInt();
|
||||
EnemySpawnDistanceMax = _buf.ReadInt();
|
||||
WeaponRotateSpeed = _buf.ReadInt();
|
||||
PlayerGroupName = _buf.ReadString();
|
||||
EnemyGroupName = _buf.ReadString();
|
||||
ProjectileGroupName = _buf.ReadString();
|
||||
DropGroupName = _buf.ReadString();
|
||||
EffectGroupNmae = _buf.ReadString();
|
||||
MinDamage = _buf.ReadInt();
|
||||
MaxDodgeRate = _buf.ReadInt();
|
||||
MinSpawnRateScale = _buf.ReadInt();
|
||||
ProjectileLifeTime = _buf.ReadInt();
|
||||
ProjectileHeightOffset = _buf.ReadInt();
|
||||
ProjectileSpeed = _buf.ReadInt();
|
||||
ProjectileEntity = _buf.ReadString();
|
||||
ProjectileEntity_Ref = null;
|
||||
}
|
||||
|
||||
public static GlobalConfig DeserializeGlobalConfig(ByteBuf _buf)
|
||||
@@ -43,6 +59,11 @@ public sealed partial class GlobalConfig : Luban.BeanBase
|
||||
/// </summary>
|
||||
public readonly int PropMaxCount;
|
||||
/// <summary>
|
||||
/// 玩家实体
|
||||
/// </summary>
|
||||
public readonly string PlayerEntity;
|
||||
public EntityConfig PlayerEntity_Ref;
|
||||
/// <summary>
|
||||
/// 武器回收价比例
|
||||
/// </summary>
|
||||
public readonly int WeaponRecycleRate;
|
||||
@@ -67,17 +88,70 @@ public sealed partial class GlobalConfig : Luban.BeanBase
|
||||
/// </summary>
|
||||
public readonly int LevelUpRewardCount;
|
||||
/// <summary>
|
||||
/// 敌人对象池名
|
||||
/// </summary>
|
||||
public readonly string EnemyGroupName;
|
||||
/// <summary>
|
||||
/// 最大敌人数量
|
||||
/// </summary>
|
||||
public readonly int SpawnEnemyMaxCount;
|
||||
/// <summary>
|
||||
/// 敌人生成距离
|
||||
/// 敌人生成最小距离
|
||||
/// </summary>
|
||||
public readonly int SpawnDistanceFromPlayer;
|
||||
public readonly int EnemySpawnDistanceMin;
|
||||
/// <summary>
|
||||
/// 敌人生成最大距离
|
||||
/// </summary>
|
||||
public readonly int EnemySpawnDistanceMax;
|
||||
/// <summary>
|
||||
/// 武器旋转速度
|
||||
/// </summary>
|
||||
public readonly int WeaponRotateSpeed;
|
||||
/// <summary>
|
||||
/// 玩家对象组名
|
||||
/// </summary>
|
||||
public readonly string PlayerGroupName;
|
||||
/// <summary>
|
||||
/// 敌人对象组名
|
||||
/// </summary>
|
||||
public readonly string EnemyGroupName;
|
||||
/// <summary>
|
||||
/// 投射物对象组名
|
||||
/// </summary>
|
||||
public readonly string ProjectileGroupName;
|
||||
/// <summary>
|
||||
/// 掉落物对象组名
|
||||
/// </summary>
|
||||
public readonly string DropGroupName;
|
||||
/// <summary>
|
||||
/// 特效对象组名
|
||||
/// </summary>
|
||||
public readonly string EffectGroupNmae;
|
||||
/// <summary>
|
||||
/// 最小伤害
|
||||
/// </summary>
|
||||
public readonly int MinDamage;
|
||||
/// <summary>
|
||||
/// 闪避率上限
|
||||
/// </summary>
|
||||
public readonly int MaxDodgeRate;
|
||||
/// <summary>
|
||||
/// 最小刷怪速度倍数
|
||||
/// </summary>
|
||||
public readonly int MinSpawnRateScale;
|
||||
/// <summary>
|
||||
/// 投射物生命周期
|
||||
/// </summary>
|
||||
public readonly int ProjectileLifeTime;
|
||||
/// <summary>
|
||||
/// 投射物生成高度
|
||||
/// </summary>
|
||||
public readonly int ProjectileHeightOffset;
|
||||
/// <summary>
|
||||
/// 投射物移动速度
|
||||
/// </summary>
|
||||
public readonly int ProjectileSpeed;
|
||||
/// <summary>
|
||||
/// 投射物实体
|
||||
/// </summary>
|
||||
public readonly string ProjectileEntity;
|
||||
public EntityConfig ProjectileEntity_Ref;
|
||||
|
||||
public const int __ID__ = -958250779;
|
||||
public override int GetTypeId() => __ID__;
|
||||
@@ -86,6 +160,7 @@ public sealed partial class GlobalConfig : Luban.BeanBase
|
||||
{
|
||||
|
||||
|
||||
PlayerEntity_Ref = tables.TbEntityConfig.GetOrDefault(PlayerEntity);
|
||||
|
||||
|
||||
|
||||
@@ -95,6 +170,19 @@ public sealed partial class GlobalConfig : Luban.BeanBase
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ProjectileEntity_Ref = tables.TbEntityConfig.GetOrDefault(ProjectileEntity);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -102,15 +190,29 @@ public sealed partial class GlobalConfig : Luban.BeanBase
|
||||
return "{ "
|
||||
+ "weaponCapacity:" + WeaponCapacity + ","
|
||||
+ "propMaxCount:" + PropMaxCount + ","
|
||||
+ "playerEntity:" + PlayerEntity + ","
|
||||
+ "weaponRecycleRate:" + WeaponRecycleRate + ","
|
||||
+ "shopGoodsCount:" + ShopGoodsCount + ","
|
||||
+ "shopPriceRandomPercent:" + ShopPriceRandomPercent + ","
|
||||
+ "shopMinPrice:" + ShopMinPrice + ","
|
||||
+ "levelUpRefreshPriceBase:" + LevelUpRefreshPriceBase + ","
|
||||
+ "levelUpRewardCount:" + LevelUpRewardCount + ","
|
||||
+ "enemyGroupName:" + EnemyGroupName + ","
|
||||
+ "spawnEnemyMaxCount:" + SpawnEnemyMaxCount + ","
|
||||
+ "spawnDistanceFromPlayer:" + SpawnDistanceFromPlayer + ","
|
||||
+ "enemySpawnDistanceMin:" + EnemySpawnDistanceMin + ","
|
||||
+ "enemySpawnDistanceMax:" + EnemySpawnDistanceMax + ","
|
||||
+ "weaponRotateSpeed:" + WeaponRotateSpeed + ","
|
||||
+ "playerGroupName:" + PlayerGroupName + ","
|
||||
+ "enemyGroupName:" + EnemyGroupName + ","
|
||||
+ "projectileGroupName:" + ProjectileGroupName + ","
|
||||
+ "dropGroupName:" + DropGroupName + ","
|
||||
+ "effectGroupNmae:" + EffectGroupNmae + ","
|
||||
+ "minDamage:" + MinDamage + ","
|
||||
+ "maxDodgeRate:" + MaxDodgeRate + ","
|
||||
+ "minSpawnRateScale:" + MinSpawnRateScale + ","
|
||||
+ "projectileLifeTime:" + ProjectileLifeTime + ","
|
||||
+ "projectileHeightOffset:" + ProjectileHeightOffset + ","
|
||||
+ "projectileSpeed:" + ProjectileSpeed + ","
|
||||
+ "projectileEntity:" + ProjectileEntity + ","
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ public partial class TbGlobalConfig
|
||||
/// </summary>
|
||||
public int PropMaxCount => _data.PropMaxCount;
|
||||
/// <summary>
|
||||
/// 玩家实体
|
||||
/// </summary>
|
||||
public string PlayerEntity => _data.PlayerEntity;
|
||||
/// <summary>
|
||||
/// 武器回收价比例
|
||||
/// </summary>
|
||||
public int WeaponRecycleRate => _data.WeaponRecycleRate;
|
||||
@@ -63,17 +67,69 @@ public partial class TbGlobalConfig
|
||||
/// </summary>
|
||||
public int LevelUpRewardCount => _data.LevelUpRewardCount;
|
||||
/// <summary>
|
||||
/// 敌人对象池名
|
||||
/// </summary>
|
||||
public string EnemyGroupName => _data.EnemyGroupName;
|
||||
/// <summary>
|
||||
/// 最大敌人数量
|
||||
/// </summary>
|
||||
public int SpawnEnemyMaxCount => _data.SpawnEnemyMaxCount;
|
||||
/// <summary>
|
||||
/// 敌人生成距离
|
||||
/// 敌人生成最小距离
|
||||
/// </summary>
|
||||
public int SpawnDistanceFromPlayer => _data.SpawnDistanceFromPlayer;
|
||||
public int EnemySpawnDistanceMin => _data.EnemySpawnDistanceMin;
|
||||
/// <summary>
|
||||
/// 敌人生成最大距离
|
||||
/// </summary>
|
||||
public int EnemySpawnDistanceMax => _data.EnemySpawnDistanceMax;
|
||||
/// <summary>
|
||||
/// 武器旋转速度
|
||||
/// </summary>
|
||||
public int WeaponRotateSpeed => _data.WeaponRotateSpeed;
|
||||
/// <summary>
|
||||
/// 玩家对象组名
|
||||
/// </summary>
|
||||
public string PlayerGroupName => _data.PlayerGroupName;
|
||||
/// <summary>
|
||||
/// 敌人对象组名
|
||||
/// </summary>
|
||||
public string EnemyGroupName => _data.EnemyGroupName;
|
||||
/// <summary>
|
||||
/// 投射物对象组名
|
||||
/// </summary>
|
||||
public string ProjectileGroupName => _data.ProjectileGroupName;
|
||||
/// <summary>
|
||||
/// 掉落物对象组名
|
||||
/// </summary>
|
||||
public string DropGroupName => _data.DropGroupName;
|
||||
/// <summary>
|
||||
/// 特效对象组名
|
||||
/// </summary>
|
||||
public string EffectGroupNmae => _data.EffectGroupNmae;
|
||||
/// <summary>
|
||||
/// 最小伤害
|
||||
/// </summary>
|
||||
public int MinDamage => _data.MinDamage;
|
||||
/// <summary>
|
||||
/// 闪避率上限
|
||||
/// </summary>
|
||||
public int MaxDodgeRate => _data.MaxDodgeRate;
|
||||
/// <summary>
|
||||
/// 最小刷怪速度倍数
|
||||
/// </summary>
|
||||
public int MinSpawnRateScale => _data.MinSpawnRateScale;
|
||||
/// <summary>
|
||||
/// 投射物生命周期
|
||||
/// </summary>
|
||||
public int ProjectileLifeTime => _data.ProjectileLifeTime;
|
||||
/// <summary>
|
||||
/// 投射物生成高度
|
||||
/// </summary>
|
||||
public int ProjectileHeightOffset => _data.ProjectileHeightOffset;
|
||||
/// <summary>
|
||||
/// 投射物移动速度
|
||||
/// </summary>
|
||||
public int ProjectileSpeed => _data.ProjectileSpeed;
|
||||
/// <summary>
|
||||
/// 投射物实体
|
||||
/// </summary>
|
||||
public string ProjectileEntity => _data.ProjectileEntity;
|
||||
|
||||
public void ResolveRef(Tables tables)
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ public sealed partial class WeaponConfig : Luban.BeanBase
|
||||
/// </summary>
|
||||
public readonly int Cooldown;
|
||||
/// <summary>
|
||||
/// 范围
|
||||
/// 攻击范围
|
||||
/// </summary>
|
||||
public readonly int AttackRange;
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user