迁移 EntityData 到 Base 中
- 新增 EntityDataFactory 工厂类,提供创建 EntityData 的统一入口 - 移出 EntityData 及派生类对 GameEntry 的依赖并移入 SepCore.Base 程序集中
This commit is contained in:
@@ -81,14 +81,21 @@ namespace Components
|
||||
public bool AttachProp(PropItem prop)
|
||||
{
|
||||
_props.Add(prop);
|
||||
prop.OnAttach(_statComponent);
|
||||
foreach (var modifier in prop.Modifiers)
|
||||
{
|
||||
_statComponent.AddModifier(modifier);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DetachProp(PropItem prop)
|
||||
{
|
||||
_props.Remove(prop);
|
||||
prop.OnDetach(_statComponent);
|
||||
foreach (var modifier in prop.Modifiers)
|
||||
{
|
||||
_statComponent.RemoveModifier(modifier);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -4,6 +4,7 @@ using SepCore.Definition;
|
||||
using Entity;
|
||||
using Entity.EntityData;
|
||||
using GameFramework.Event;
|
||||
using SepCore.Utility;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Random = UnityEngine.Random;
|
||||
@@ -124,7 +125,7 @@ namespace CustomComponent
|
||||
_nextSpawnTimes = null;
|
||||
|
||||
ClearEnemies();
|
||||
|
||||
|
||||
_currentEnemyCount = 0;
|
||||
}
|
||||
|
||||
@@ -136,10 +137,8 @@ namespace CustomComponent
|
||||
|
||||
if (_currentEnemyCount >= _spawnEnemyMaxCount) return;
|
||||
int entityPoolId = _currentSpawnEnemyId % _spawnEnemyMaxCount;
|
||||
var enemyData = new EnemyData(entityPoolId, enemyType, _currentLevel)
|
||||
{
|
||||
Position = GetRandomPosition()
|
||||
};
|
||||
var enemyData = EntityDataFactory.Create(entityPoolId, enemyType, _currentLevel);
|
||||
enemyData.Position = GetRandomPosition();
|
||||
_entity.ShowEnemy(enemyData);
|
||||
_currentSpawnEnemyId++;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58efe0589d7e90f498c8bcbbf94c6be4
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026151
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,53 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class AccessoryObjectData : EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_OwnerId = 0;
|
||||
|
||||
[SerializeField]
|
||||
private CampType m_OwnerCamp = CampType.Unknown;
|
||||
|
||||
public AccessoryObjectData(int entityId, int typeId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
m_OwnerId = ownerId;
|
||||
m_OwnerCamp = ownerCamp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拥有者编号。
|
||||
/// </summary>
|
||||
public int OwnerId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OwnerId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拥有者阵营。
|
||||
/// </summary>
|
||||
public CampType OwnerCamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OwnerCamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83cb841b7411a844581691d5547bf866
|
||||
timeCreated: 1528026151
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
public class CoinData : EntityDataBase
|
||||
{
|
||||
private int _value;
|
||||
|
||||
public CoinData(int value, int entityId, int typeId) : base(entityId, typeId)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => _value;
|
||||
set => _value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9caee22d67a42018113acc77155d6ba
|
||||
timeCreated: 1770292597
|
||||
@@ -1,33 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class EffectData : EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private float m_KeepTime = 0f;
|
||||
|
||||
public EffectData(int entityId, int typeId)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
m_KeepTime = 3f;
|
||||
}
|
||||
|
||||
public float KeepTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_KeepTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5b93dcbe30421a429c196bda0af31ed
|
||||
timeCreated: 1528026152
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 611437bd292819b439512f684e13c7e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class EnemyData : TargetableObjectData
|
||||
{
|
||||
[SerializeField] private DREnemy _drEnemy;
|
||||
|
||||
public EnemyData(int entityId, EnemyType enemyType, int level) : base(
|
||||
entityId, (int)enemyType, CampType.Enemy)
|
||||
{
|
||||
DREnemy enemyRow = GameEntry.DataTable.GetDataTableRow<DREnemy>((int)enemyType);
|
||||
|
||||
if (enemyRow == null)
|
||||
{
|
||||
throw new Exception($"Enemy data table row is missing, EnemyType='{enemyType}'.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_drEnemy = enemyRow;
|
||||
}
|
||||
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
MaxHealthBase = enemyRow.MaxHealth + enemyRow.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 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,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b802c30cc274e04929b8659ec631e84
|
||||
timeCreated: 1768890974
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class EnemyProjectileData : EntityDataBase
|
||||
{
|
||||
public EnemyProjectileData(int entityId, int ownerEntityId, CampType ownerCamp, int attackDamage,
|
||||
float speed, float lifeTime, Vector3 direction)
|
||||
: base(entityId, 0)
|
||||
{
|
||||
OwnerEntityId = ownerEntityId;
|
||||
OwnerCamp = ownerCamp;
|
||||
AttackDamage = attackDamage;
|
||||
Speed = speed;
|
||||
LifeTime = lifeTime;
|
||||
Direction = direction;
|
||||
}
|
||||
|
||||
public int OwnerEntityId { get; }
|
||||
public CampType OwnerCamp { get; }
|
||||
public int AttackDamage { get; }
|
||||
public float Speed { get; }
|
||||
public float LifeTime { get; }
|
||||
public Vector3 Direction { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52b38f83ab6c4029803d40c189db47c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,62 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_Id = 0;
|
||||
|
||||
[SerializeField]
|
||||
private int m_TypeId = 0;
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 m_Position = Vector3.zero;
|
||||
|
||||
[SerializeField]
|
||||
private Quaternion m_Rotation = Quaternion.identity;
|
||||
|
||||
public EntityDataBase(int entityId, int typeId)
|
||||
{
|
||||
m_Id = entityId;
|
||||
m_TypeId = typeId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体编号。
|
||||
/// </summary>
|
||||
public int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 实体类型编号。
|
||||
/// </summary>
|
||||
public int TypeId => m_TypeId;
|
||||
|
||||
/// <summary>
|
||||
/// 实体位置。
|
||||
/// </summary>
|
||||
public Vector3 Position
|
||||
{
|
||||
get => m_Position;
|
||||
set => m_Position = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体朝向。
|
||||
/// </summary>
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get => m_Rotation;
|
||||
set => m_Rotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afb91fe3ed8105e4a96b7bd5917ecc2b
|
||||
timeCreated: 1528026152
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
public class ExpData : EntityDataBase
|
||||
{
|
||||
private int _value;
|
||||
|
||||
public ExpData(int value, int entityId, int typeId) : base(entityId, typeId)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => _value;
|
||||
set => _value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0f6c8e117da49f1ad04fd8810882043
|
||||
timeCreated: 1770292932
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class PlayerData : TargetableObjectData
|
||||
{
|
||||
private int _maxExp;
|
||||
|
||||
public PlayerData(int entityId, int typeId) : base(entityId, typeId, CampType.Player)
|
||||
{
|
||||
MaxHealthBase = MaxHealthBase;
|
||||
}
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b69d3168ac4f442994f8dc4d906daa60
|
||||
timeCreated: 1768890638
|
||||
@@ -1,40 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class TargetableObjectData : EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private CampType _camp = CampType.Unknown;
|
||||
|
||||
public TargetableObjectData(int entityId, int typeId, CampType camp)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
_camp = camp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色阵营。
|
||||
/// </summary>
|
||||
public CampType Camp => _camp;
|
||||
|
||||
/// <summary>
|
||||
/// 最大生命。
|
||||
/// </summary>
|
||||
public abstract int MaxHealthBase
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f866c15cf3f2a45429251d4a66f70c77
|
||||
timeCreated: 1528026152
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b2591453b7f0841940c8e45528f465
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,110 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using GameFramework;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class WeaponData : AccessoryObjectData
|
||||
{
|
||||
private DRWeapon _drWeapon;
|
||||
|
||||
private int _entityTypeId = 0;
|
||||
|
||||
public WeaponData(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, (int)weaponType, ownerId, ownerCamp)
|
||||
{
|
||||
_drWeapon = GameEntry.DataTable.GetDataTableRow<DRWeapon>((int)weaponType);
|
||||
|
||||
if (_drWeapon == null)
|
||||
{
|
||||
throw new Exception($"Weapon data table row is missing, WeaponType='{weaponType}'.");
|
||||
}
|
||||
|
||||
_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;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e813e3219579f834d8e619c17a8083d4
|
||||
timeCreated: 1528026153
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponHandgunParamsData
|
||||
{
|
||||
}
|
||||
|
||||
public class WeaponHandgunData : WeaponData
|
||||
{
|
||||
public WeaponHandgunParamsData ParamsData { get; }
|
||||
|
||||
public WeaponHandgunData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponHandgun, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponHandgunParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponKnifeParamsData
|
||||
{
|
||||
public float HitRadius { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponKnifeData : WeaponData
|
||||
{
|
||||
public WeaponKnifeParamsData ParamsData { get; }
|
||||
|
||||
public WeaponKnifeData(int entityId, int ownerId, CampType ownerCamp) : base(entityId, WeaponType.WeaponKnife,
|
||||
ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponKnifeParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da25d8e0669f0194d8f56f4283c67b38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,71 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponLanceParamsData
|
||||
{
|
||||
/// <summary>
|
||||
/// 横向半宽,表示前戳矩形判定的一半宽度。
|
||||
/// </summary>
|
||||
public float HitHalfWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 旧字段兼容,未配置 HitHalfWidth 时回退使用。
|
||||
/// </summary>
|
||||
public float HitRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 前戳判定盒体的总高度。
|
||||
/// </summary>
|
||||
public float HitHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 判定盒体中心相对战斗平面的高度偏移。
|
||||
/// </summary>
|
||||
public float HitCenterYOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 前刺距离,同时驱动武器位移和命中长度。
|
||||
/// </summary>
|
||||
public float PierceLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 旧字段兼容,未配置 PierceLength 时回退使用。
|
||||
/// </summary>
|
||||
public float ThrustDistance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 判定起点相对武器当前位置的前置偏移。
|
||||
/// </summary>
|
||||
public float ForwardOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 追踪目标时的转向速度。
|
||||
/// </summary>
|
||||
public float RotateSpeed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 向前突刺阶段耗时。
|
||||
/// </summary>
|
||||
public float AttackDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收枪返回阶段耗时。
|
||||
/// </summary>
|
||||
public float ReturnDuration { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class WeaponLanceData : WeaponData
|
||||
{
|
||||
public WeaponLanceParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLanceData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponLance, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLanceParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d1a821e8ee1a9a4b912b70b0a1616eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponLightningParamsData
|
||||
{
|
||||
public float HitRadius { get; set; }
|
||||
public float HoverHeight { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponLightningData : WeaponData
|
||||
{
|
||||
public WeaponLightningParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLightningData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponLightning, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLightningParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25b0006918fd46959c7f6b8ec1bbc8ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponSlashParamsData
|
||||
{
|
||||
public float SectorAngle { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponSlashData : WeaponData
|
||||
{
|
||||
public WeaponSlashParamsData ParamsData { get; }
|
||||
|
||||
public WeaponSlashData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponSlash, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponSlashParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4aa6473525dc4c62aeee02ff562ec453
|
||||
timeCreated: 1771484661
|
||||
@@ -7,6 +7,7 @@ using Entity.EntityData;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Entity.Weapon;
|
||||
using SepCore.Utility;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
@@ -140,7 +141,8 @@ namespace Entity
|
||||
// BackpackComponent
|
||||
Coin = role.Coin;
|
||||
_backpackComponent.OnInit(this, role.WeaponCapacity);
|
||||
GameEntry.Entity.ShowWeapon(new WeaponKnifeData(GameEntry.Entity.GenerateSerialId(), Id, _playerData.Camp));
|
||||
GameEntry.Entity.ShowWeapon(EntityDataFactory.Create(GameEntry.Entity.GenerateSerialId(),
|
||||
WeaponType.WeaponKnife, Id, _playerData.Camp));
|
||||
|
||||
// StatComponent
|
||||
foreach (var modifier in role.InitialProperties)
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
using Components;
|
||||
using Entity;
|
||||
using Entity.EntityData;
|
||||
using SepCore.DataTable;
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
public class PropItem
|
||||
{
|
||||
private readonly StatModifier[] _modifiers;
|
||||
public string Title { get; private set; }
|
||||
public string IconAssetName { get; private set; }
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
public StatModifier[] Modifiers => _modifiers;
|
||||
|
||||
public PropItem(DRProp prop)
|
||||
{
|
||||
if (prop == null) return;
|
||||
|
||||
_modifiers = prop.Modifiers;
|
||||
Title = prop.Title;
|
||||
Rarity = prop.Rarity;
|
||||
IconAssetName = prop.IconAssetName;
|
||||
}
|
||||
|
||||
public PropItem(StatModifier[] modifiers)
|
||||
{
|
||||
_modifiers = modifiers;
|
||||
}
|
||||
|
||||
public PropItem(StatModifier[] modifiers, ItemRarity rarity, string title, string iconAssetName)
|
||||
{
|
||||
_modifiers = modifiers;
|
||||
Title = title;
|
||||
Rarity = rarity;
|
||||
IconAssetName = iconAssetName;
|
||||
}
|
||||
|
||||
public void OnAttach(StatComponent statComponent)
|
||||
{
|
||||
if (_modifiers == null || statComponent == null) return;
|
||||
foreach (var modifier in _modifiers)
|
||||
{
|
||||
statComponent.AddModifier(modifier);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDetach(StatComponent statComponent)
|
||||
{
|
||||
if (_modifiers == null || statComponent == null) return;
|
||||
foreach (var modifier in _modifiers)
|
||||
{
|
||||
statComponent.RemoveModifier(modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 135b5ab1b6f5491989f080cf8b949201
|
||||
timeCreated: 1770212750
|
||||
@@ -7,6 +7,7 @@ using Entity;
|
||||
using Entity.EntityData;
|
||||
using CustomUtility;
|
||||
using GameFramework.DataTable;
|
||||
using SepCore.Utility;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Random = UnityEngine.Random;
|
||||
@@ -352,14 +353,10 @@ namespace SepCore.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
DRWeapon drWeapon = _weaponDataTable != null ? _weaponDataTable.GetDataRow(goods.GoodsTypeId) : null;
|
||||
if (drWeapon == null)
|
||||
{
|
||||
Log.Warning($"ShopFormUseCase::ApplyGoodsPurchase: Missing DRWeapon, id = {goods.GoodsTypeId}");
|
||||
return null;
|
||||
}
|
||||
DRWeapon drWeapon = _weaponDataTable.GetDataRow(goods.GoodsTypeId);
|
||||
|
||||
var weaponData = CreateWeaponData(goods.GoodsTypeId);
|
||||
var weaponData = EntityDataFactory.Create(GameEntry.Entity.GenerateSerialId(), drWeapon, Player.Id,
|
||||
CampType.Player);
|
||||
if (weaponData == null)
|
||||
{
|
||||
Log.Warning(
|
||||
@@ -380,30 +377,6 @@ namespace SepCore.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
private WeaponData CreateWeaponData(int weaponTypeId)
|
||||
{
|
||||
int entityId = GameEntry.Entity.GenerateSerialId();
|
||||
int ownerId = Player.Id;
|
||||
CampType ownerCamp = CampType.Player;
|
||||
|
||||
WeaponType weaponType = (WeaponType)weaponTypeId;
|
||||
switch (weaponType)
|
||||
{
|
||||
case WeaponType.WeaponKnife:
|
||||
return new WeaponKnifeData(entityId, ownerId, ownerCamp);
|
||||
case WeaponType.WeaponHandgun:
|
||||
return new WeaponHandgunData(entityId, ownerId, ownerCamp);
|
||||
case WeaponType.WeaponSlash:
|
||||
return new WeaponSlashData(entityId, ownerId, ownerCamp);
|
||||
case WeaponType.WeaponLightning:
|
||||
return new WeaponLightningData(entityId, ownerId, ownerCamp);
|
||||
case WeaponType.WeaponLance:
|
||||
return new WeaponLanceData(entityId, ownerId, ownerCamp);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryRecycleWeapon(int argsIndex, int argsPrice)
|
||||
{
|
||||
Player player = Player;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using SepCore.DataTable;
|
||||
using Entity.EntityData;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Utility
|
||||
{
|
||||
public static class EntityDataFactory
|
||||
{
|
||||
public static EnemyData Create(int entityId, EnemyType enemyType, int level)
|
||||
{
|
||||
var dr = GameEntry.DataTable.GetDataTableRow<DREnemy>((int)enemyType);
|
||||
return new EnemyData(entityId, dr, level);
|
||||
}
|
||||
|
||||
public static WeaponData Create(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
|
||||
{
|
||||
var dr = GameEntry.DataTable.GetDataTableRow<DRWeapon>((int)weaponType);
|
||||
return weaponType switch
|
||||
{
|
||||
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponSlash => new WeaponSlashData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponLightning => new WeaponLightningData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponLance => new WeaponLanceData(entityId, dr, ownerId, ownerCamp),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
|
||||
public static WeaponData Create(int entityId, DRWeapon dr, int ownerId, CampType ownerCamp)
|
||||
{
|
||||
WeaponType type = (WeaponType)dr.Id;
|
||||
return type switch
|
||||
{
|
||||
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponSlash => new WeaponSlashData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponLightning => new WeaponLightningData(entityId, dr, ownerId, ownerCamp),
|
||||
WeaponType.WeaponLance => new WeaponLanceData(entityId, dr, ownerId, ownerCamp),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 574d105bf89bf7546a682ed407708034
|
||||
guid: d562d735e382c1e4388ff5f7d3b57bd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
Reference in New Issue
Block a user