迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
+8
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,6 +11,13 @@ namespace SepCore.Entity
|
||||
|
||||
[SerializeField] private CampType _ownerCamp = CampType.Unknown;
|
||||
|
||||
public AccessoryObjectData(string assetName, int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(assetName, entityId)
|
||||
{
|
||||
_ownerId = ownerId;
|
||||
_ownerCamp = ownerCamp;
|
||||
}
|
||||
|
||||
public AccessoryObjectData(int entityId, int typeId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
+5
-1
@@ -4,11 +4,15 @@ namespace SepCore.Entity
|
||||
{
|
||||
private int _value;
|
||||
|
||||
public CoinData(int value, int entityId, int typeId) : base(entityId, typeId)
|
||||
public CoinData(int value, int entityId, string assetName = "CoinEntity") : base(assetName, entityId)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public CoinData(int value, int entityId, int typeId) : this(value, entityId, "CoinEntity")
|
||||
{
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => _value;
|
||||
+8
-3
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -9,12 +9,17 @@ namespace SepCore.Entity
|
||||
[SerializeField]
|
||||
private float _keepTime = 0f;
|
||||
|
||||
public EffectData(int entityId, int typeId)
|
||||
: base(entityId, typeId)
|
||||
public EffectData(int entityId, string assetName = "Effect")
|
||||
: base(assetName, entityId)
|
||||
{
|
||||
_keepTime = 3f;
|
||||
}
|
||||
|
||||
public EffectData(int entityId, int typeId)
|
||||
: this(entityId, typeId.ToString())
|
||||
{
|
||||
}
|
||||
|
||||
public float KeepTime => _keepTime;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -8,8 +8,8 @@ namespace SepCore.Entity
|
||||
public class EnemyProjectileData : EntityDataBase
|
||||
{
|
||||
public EnemyProjectileData(int entityId, int ownerEntityId, CampType ownerCamp, int attackDamage,
|
||||
float speed, float lifeTime, Vector3 direction)
|
||||
: base(entityId, 0)
|
||||
float speed, float lifeTime, Vector3 direction, string assetName = "BulletHandgun")
|
||||
: base(assetName, entityId)
|
||||
{
|
||||
OwnerEntityId = ownerEntityId;
|
||||
OwnerCamp = ownerCamp;
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58efe0589d7e90f498c8bcbbf94c6be4
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026151
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public class EnemyData : TargetableObjectData
|
||||
{
|
||||
private DREnemy _drEnemy;
|
||||
|
||||
public EnemyData(int entityId, DREnemy drEnemy, int level) : base(
|
||||
entityId, drEnemy.Id, CampType.Enemy)
|
||||
{
|
||||
_drEnemy = drEnemy;
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
MaxHealthBase = _drEnemy.MaxHealth + _drEnemy.HpAddPerLevel * (effectiveLevel - 1);
|
||||
}
|
||||
|
||||
public EnemyType EnemyType => (EnemyType)_drEnemy.Id;
|
||||
|
||||
public int EntityTypeId => _drEnemy.EntityTypeId;
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
|
||||
public int AttackDamage => _drEnemy.AttackDamage;
|
||||
|
||||
public float AttackCooldown => _drEnemy.AttackCooldown;
|
||||
|
||||
public float AttackRange => _drEnemy.AttackRange;
|
||||
|
||||
public float SpeedBase => _drEnemy.Speed;
|
||||
|
||||
public int DropCoin => _drEnemy.DropCoin;
|
||||
|
||||
public int DropExp => _drEnemy.DropExp;
|
||||
|
||||
public float DropPercent => _drEnemy.DropPercent;
|
||||
|
||||
public float Scale => _drEnemy.Scale;
|
||||
|
||||
public Color Color => _drEnemy.Color;
|
||||
|
||||
public IReadOnlyDictionary<string, string> Params => _drEnemy.Params;
|
||||
|
||||
public bool TryGetParam(string key, out string value)
|
||||
{
|
||||
value = null;
|
||||
if (string.IsNullOrEmpty(key) || _drEnemy?.Params == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _drEnemy.Params.TryGetValue(key, out value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using GameFramework;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public class WeaponData : AccessoryObjectData
|
||||
{
|
||||
private DRWeapon _drWeapon;
|
||||
|
||||
private int _entityTypeId = 0;
|
||||
|
||||
public WeaponData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon.Id, ownerId, ownerCamp)
|
||||
{
|
||||
_drWeapon = drWeapon;
|
||||
_entityTypeId = drWeapon.EntityTypeId;
|
||||
}
|
||||
|
||||
public WeaponType WeaponType => (WeaponType)_drWeapon.Id;
|
||||
|
||||
public bool TryGetParam(string key, out string value)
|
||||
{
|
||||
value = null;
|
||||
if (string.IsNullOrEmpty(key) || Params == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Params.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
protected TParams ParseParams<TParams>() where TParams : new()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_drWeapon.ParamsJson))
|
||||
{
|
||||
return new TParams();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
TParams parsed = Utility.Json.ToObject<TParams>(_drWeapon.ParamsJson);
|
||||
return parsed ?? new TParams();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Failed to parse weapon params, WeaponType='{WeaponType}', Json='{_drWeapon.ParamsJson}'.",
|
||||
exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 攻击力。
|
||||
/// </summary>
|
||||
public int Attack => _drWeapon.Attack;
|
||||
|
||||
public int EntityTypeId => _entityTypeId;
|
||||
|
||||
/// <summary>
|
||||
/// 武器名称。
|
||||
/// </summary>
|
||||
public string Title => _drWeapon.Title;
|
||||
|
||||
/// <summary>
|
||||
/// 图标资源名称。
|
||||
/// </summary>
|
||||
public string IconAssetName => _drWeapon.IconAssetName;
|
||||
|
||||
public ItemRarity Rarity => _drWeapon.Rarity;
|
||||
|
||||
public int Price => _drWeapon.Price;
|
||||
|
||||
/// <summary>
|
||||
/// 攻击间隔。
|
||||
/// </summary>
|
||||
public float Cooldown => _drWeapon.Cooldown;
|
||||
|
||||
/// <summary>
|
||||
/// 攻击范围。
|
||||
/// </summary>
|
||||
public float AttackRange => _drWeapon.AttackRange;
|
||||
|
||||
/// <summary>
|
||||
/// 攻击音效。
|
||||
/// </summary>
|
||||
public int AttackSoundId => _drWeapon.AttackSoundId;
|
||||
|
||||
/// <summary>
|
||||
/// 额外参数。
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Params => _drWeapon.Pramas;
|
||||
|
||||
public string ParamsJson => _drWeapon.ParamsJson;
|
||||
|
||||
/// <summary>
|
||||
/// 额外属性。
|
||||
/// </summary>
|
||||
public StatModifier[] Modifiers => _drWeapon.Modifiers;
|
||||
}
|
||||
}
|
||||
+16
-2
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -6,6 +6,8 @@ namespace SepCore.Entity
|
||||
[Serializable]
|
||||
public abstract class EntityDataBase
|
||||
{
|
||||
[SerializeField] private string m_AssetName = string.Empty;
|
||||
|
||||
[SerializeField] private int _id = 0;
|
||||
|
||||
[SerializeField] private int _typeId = 0;
|
||||
@@ -14,19 +16,31 @@ namespace SepCore.Entity
|
||||
|
||||
[SerializeField] private Quaternion _rotation = Quaternion.identity;
|
||||
|
||||
public EntityDataBase(string assetName, int entityId)
|
||||
{
|
||||
m_AssetName = assetName;
|
||||
_id = entityId;
|
||||
}
|
||||
|
||||
public EntityDataBase(int entityId, int typeId)
|
||||
{
|
||||
m_AssetName = typeId.ToString();
|
||||
_id = entityId;
|
||||
_typeId = typeId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体资源名称。
|
||||
/// </summary>
|
||||
public string AssetName => m_AssetName;
|
||||
|
||||
/// <summary>
|
||||
/// 实体编号。
|
||||
/// </summary>
|
||||
public int Id => _id;
|
||||
|
||||
/// <summary>
|
||||
/// 实体类型编号。
|
||||
/// 实体类型编号(向后兼容)。
|
||||
/// </summary>
|
||||
public int TypeId => _typeId;
|
||||
|
||||
+5
-1
@@ -4,11 +4,15 @@ namespace SepCore.Entity
|
||||
{
|
||||
private int _value;
|
||||
|
||||
public ExpData(int value, int entityId, int typeId) : base(entityId, typeId)
|
||||
public ExpData(int value, int entityId, string assetName = "ExpEntity") : base(assetName, entityId)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public ExpData(int value, int entityId, int typeId) : this(value, entityId, "ExpEntity")
|
||||
{
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => _value;
|
||||
+6
-2
@@ -8,9 +8,13 @@ namespace SepCore.Entity
|
||||
{
|
||||
private int _maxExp;
|
||||
|
||||
public PlayerData(int entityId, int typeId) : base(entityId, typeId, CampType.Player)
|
||||
public PlayerData(int entityId, string assetName = "Player") : base(assetName, entityId, CampType.Player)
|
||||
{
|
||||
MaxHealthBase = 100;
|
||||
}
|
||||
|
||||
public PlayerData(int entityId, int typeId) : this(entityId, "Player")
|
||||
{
|
||||
MaxHealthBase = MaxHealthBase;
|
||||
}
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
+7
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -8,6 +8,12 @@ namespace SepCore.Entity
|
||||
{
|
||||
private CampType _camp;
|
||||
|
||||
public TargetableObjectData(string assetName, int entityId, CampType camp)
|
||||
: base(assetName, entityId)
|
||||
{
|
||||
_camp = camp;
|
||||
}
|
||||
|
||||
public TargetableObjectData(int entityId, int typeId, CampType camp)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public class WeaponData : AccessoryObjectData
|
||||
{
|
||||
private readonly WeaponConfig _weaponConfig;
|
||||
|
||||
public WeaponData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(weaponConfig.Prefab, entityId, ownerId, ownerCamp)
|
||||
{
|
||||
_weaponConfig = weaponConfig;
|
||||
}
|
||||
|
||||
public WeaponConfig Config => _weaponConfig;
|
||||
|
||||
public WeaponType WeaponType => (WeaponType)_weaponConfig.Id;
|
||||
|
||||
public int Attack => _weaponConfig.Attack;
|
||||
|
||||
public string Title => _weaponConfig.Name;
|
||||
|
||||
public string IconAssetName => _weaponConfig.IconAssetName;
|
||||
|
||||
public Rarity Rarity => _weaponConfig.Rarity;
|
||||
|
||||
public int Price => _weaponConfig.Price;
|
||||
|
||||
public float Cooldown => _weaponConfig.Cooldown / 1000f;
|
||||
|
||||
public float AttackRange => _weaponConfig.AttackRange / 1000f;
|
||||
|
||||
public int AttackSoundId => _weaponConfig.AttackSoundId;
|
||||
|
||||
public IReadOnlyDictionary<ParamType, int> Parameters => _weaponConfig.Parameters;
|
||||
|
||||
public IReadOnlyList<modifier> Modifiers => _weaponConfig.Modifiers;
|
||||
|
||||
public int GetParam(ParamType paramType, int defaultValue = 0)
|
||||
{
|
||||
return _weaponConfig.Parameters.TryGetValue(paramType, out int value) ? value : defaultValue;
|
||||
}
|
||||
|
||||
public float GetParamFloat(ParamType paramType, float defaultValue = 0f)
|
||||
{
|
||||
if (_weaponConfig.Parameters.TryGetValue(paramType, out int val))
|
||||
{
|
||||
return paramType == ParamType.SectorAngle ? val : val / 1000f;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -13,10 +12,10 @@ namespace SepCore.Entity
|
||||
{
|
||||
public WeaponHandgunParamsData ParamsData { get; }
|
||||
|
||||
public WeaponHandgunData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
public WeaponHandgunData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponHandgunParamsData>();
|
||||
ParamsData = new WeaponHandgunParamsData();
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -14,10 +13,13 @@ namespace SepCore.Entity
|
||||
{
|
||||
public WeaponKnifeParamsData ParamsData { get; }
|
||||
|
||||
public WeaponKnifeData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
public WeaponKnifeData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponKnifeParamsData>();
|
||||
ParamsData = new WeaponKnifeParamsData
|
||||
{
|
||||
HitRadius = GetParamFloat(ParamType.HitRadius)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -63,10 +62,15 @@ namespace SepCore.Entity
|
||||
{
|
||||
public WeaponLanceParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLanceData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
public WeaponLanceData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLanceParamsData>();
|
||||
ParamsData = new WeaponLanceParamsData
|
||||
{
|
||||
HitHalfWidth = GetParamFloat(ParamType.HitHalfWidth),
|
||||
PierceLength = GetParamFloat(ParamType.PierceLength),
|
||||
HitHeight = GetParamFloat(ParamType.HitHeight)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -15,10 +14,14 @@ namespace SepCore.Entity
|
||||
{
|
||||
public WeaponLightningParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLightningData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
public WeaponLightningData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLightningParamsData>();
|
||||
ParamsData = new WeaponLightningParamsData
|
||||
{
|
||||
HitRadius = GetParamFloat(ParamType.HitRadius),
|
||||
HoverHeight = 0f
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
@@ -14,10 +13,13 @@ namespace SepCore.Entity
|
||||
{
|
||||
public WeaponSlashParamsData ParamsData { get; }
|
||||
|
||||
public WeaponSlashData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
public WeaponSlashData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponSlashParamsData>();
|
||||
ParamsData = new WeaponSlashParamsData
|
||||
{
|
||||
SectorAngle = GetParamFloat(ParamType.SectorAngle)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user