迁移 EntityData 到 Base 中
- 新增 EntityDataFactory 工厂类,提供创建 EntityData 的统一入口 - 移出 EntityData 及派生类对 GameEntry 的依赖并移入 SepCore.Base 程序集中
This commit is contained in:
parent
91f70dd783
commit
5de3fdc795
|
|
@ -1,6 +1,3 @@
|
|||
using Components;
|
||||
using Entity;
|
||||
using Entity.EntityData;
|
||||
using SepCore.DataTable;
|
||||
|
||||
namespace SepCore.Definition
|
||||
|
|
@ -35,23 +32,5 @@ namespace SepCore.Definition
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cedb6e3c4b92edf4bbbe5fb34bb043ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class AccessoryObjectData : EntityDataBase
|
||||
{
|
||||
[SerializeField] private int _ownerId = 0;
|
||||
|
||||
[SerializeField] private CampType _ownerCamp = CampType.Unknown;
|
||||
|
||||
public AccessoryObjectData(int entityId, int typeId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
_ownerId = ownerId;
|
||||
_ownerCamp = ownerCamp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拥有者编号。
|
||||
/// </summary>
|
||||
public int OwnerId => _ownerId;
|
||||
|
||||
/// <summary>
|
||||
/// 拥有者阵营。
|
||||
/// </summary>
|
||||
public CampType OwnerCamp => _ownerCamp;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class EffectData : EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private float _keepTime = 0f;
|
||||
|
||||
public EffectData(int entityId, int typeId)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
_keepTime = 3f;
|
||||
}
|
||||
|
||||
public float KeepTime => _keepTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,31 +3,20 @@ 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;
|
||||
private DREnemy _drEnemy;
|
||||
|
||||
public EnemyData(int entityId, EnemyType enemyType, int level) : base(
|
||||
entityId, (int)enemyType, CampType.Enemy)
|
||||
public EnemyData(int entityId, DREnemy drEnemy, int level) : base(
|
||||
entityId, drEnemy.Id, 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;
|
||||
}
|
||||
|
||||
_drEnemy = drEnemy;
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
MaxHealthBase = enemyRow.MaxHealth + enemyRow.HpAddPerLevel * (effectiveLevel - 1);
|
||||
MaxHealthBase = _drEnemy.MaxHealth + _drEnemy.HpAddPerLevel * (effectiveLevel - 1);
|
||||
}
|
||||
|
||||
public EnemyType EnemyType => (EnemyType)_drEnemy.Id;
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class EntityDataBase
|
||||
{
|
||||
[SerializeField] private int _id = 0;
|
||||
|
||||
[SerializeField] private int _typeId = 0;
|
||||
|
||||
[SerializeField] private Vector3 _position = Vector3.zero;
|
||||
|
||||
[SerializeField] private Quaternion _rotation = Quaternion.identity;
|
||||
|
||||
public EntityDataBase(int entityId, int typeId)
|
||||
{
|
||||
_id = entityId;
|
||||
_typeId = typeId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体编号。
|
||||
/// </summary>
|
||||
public int Id => _id;
|
||||
|
||||
/// <summary>
|
||||
/// 实体类型编号。
|
||||
/// </summary>
|
||||
public int TypeId => _typeId;
|
||||
|
||||
/// <summary>
|
||||
/// 实体位置。
|
||||
/// </summary>
|
||||
public Vector3 Position
|
||||
{
|
||||
get => _position;
|
||||
set => _position = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体朝向。
|
||||
/// </summary>
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get => _rotation;
|
||||
set => _rotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class TargetableObjectData : EntityDataBase
|
||||
{
|
||||
private CampType _camp;
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -13,17 +13,11 @@ namespace Entity.EntityData
|
|||
|
||||
private int _entityTypeId = 0;
|
||||
|
||||
public WeaponData(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, (int)weaponType, ownerId, ownerCamp)
|
||||
public WeaponData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon.Id, 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;
|
||||
_drWeapon = drWeapon;
|
||||
_entityTypeId = drWeapon.EntityTypeId;
|
||||
}
|
||||
|
||||
public WeaponType WeaponType => (WeaponType)_drWeapon.Id;
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
|
|
@ -12,8 +13,8 @@ namespace Entity.EntityData
|
|||
{
|
||||
public WeaponHandgunParamsData ParamsData { get; }
|
||||
|
||||
public WeaponHandgunData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponHandgun, ownerId, ownerCamp)
|
||||
public WeaponHandgunData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponHandgunParamsData>();
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
|
|
@ -13,8 +14,8 @@ namespace Entity.EntityData
|
|||
{
|
||||
public WeaponKnifeParamsData ParamsData { get; }
|
||||
|
||||
public WeaponKnifeData(int entityId, int ownerId, CampType ownerCamp) : base(entityId, WeaponType.WeaponKnife,
|
||||
ownerId, ownerCamp)
|
||||
public WeaponKnifeData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponKnifeParamsData>();
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
|
|
@ -62,8 +63,8 @@ namespace Entity.EntityData
|
|||
{
|
||||
public WeaponLanceParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLanceData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponLance, ownerId, ownerCamp)
|
||||
public WeaponLanceData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLanceParamsData>();
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
|
|
@ -14,8 +15,8 @@ namespace Entity.EntityData
|
|||
{
|
||||
public WeaponLightningParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLightningData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponLightning, ownerId, ownerCamp)
|
||||
public WeaponLightningData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLightningParamsData>();
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace Entity.EntityData
|
||||
|
|
@ -13,8 +14,8 @@ namespace Entity.EntityData
|
|||
{
|
||||
public WeaponSlashParamsData ParamsData { get; }
|
||||
|
||||
public WeaponSlashData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponSlash, ownerId, ownerCamp)
|
||||
public WeaponSlashData(int entityId, DRWeapon drWeapon, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, drWeapon, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponSlashParamsData>();
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using GameFramework;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Editor;
|
||||
using UnityGameFramework.Editor.ResourceTools;
|
||||
|
|
@ -8,16 +7,20 @@ namespace SepCore.Editor
|
|||
{
|
||||
public static class GameFrameworkConfigs
|
||||
{
|
||||
[BuildSettingsConfigPath]
|
||||
public static string BuildSettingsConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/BuildSettings.xml"));
|
||||
[BuildSettingsConfigPath] public static string BuildSettingsConfig =
|
||||
GameFramework.Utility.Path.GetRegularPath(Path.Combine(Application.dataPath,
|
||||
"GameMain/Configs/BuildSettings.xml"));
|
||||
|
||||
[ResourceCollectionConfigPath]
|
||||
public static string ResourceCollectionConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceCollection.xml"));
|
||||
[ResourceCollectionConfigPath] public static string ResourceCollectionConfig =
|
||||
GameFramework.Utility.Path.GetRegularPath(Path.Combine(Application.dataPath,
|
||||
"GameMain/Configs/ResourceCollection.xml"));
|
||||
|
||||
[ResourceEditorConfigPath]
|
||||
public static string ResourceEditorConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceEditor.xml"));
|
||||
[ResourceEditorConfigPath] public static string ResourceEditorConfig =
|
||||
GameFramework.Utility.Path.GetRegularPath(Path.Combine(Application.dataPath,
|
||||
"GameMain/Configs/ResourceEditor.xml"));
|
||||
|
||||
[ResourceBuilderConfigPath]
|
||||
public static string ResourceBuilderConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceBuilder.xml"));
|
||||
[ResourceBuilderConfigPath] public static string ResourceBuilderConfig =
|
||||
GameFramework.Utility.Path.GetRegularPath(Path.Combine(Application.dataPath,
|
||||
"GameMain/Configs/ResourceBuilder.xml"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,19 @@ namespace SepCore.Editor
|
|||
{
|
||||
public bool ContinueOnFailure
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public void OnPreprocessAllPlatforms(string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath)
|
||||
public void OnPreprocessAllPlatforms(string productName, string companyName, string gameIdentifier,
|
||||
string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName,
|
||||
bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName,
|
||||
string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected,
|
||||
string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath)
|
||||
{
|
||||
string streamingAssetsPath = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "StreamingAssets"));
|
||||
string streamingAssetsPath =
|
||||
GameFramework.Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "StreamingAssets"));
|
||||
string[] fileNames = Directory.GetFiles(streamingAssetsPath, "*", SearchOption.AllDirectories);
|
||||
foreach (string fileName in fileNames)
|
||||
{
|
||||
|
|
@ -32,28 +34,39 @@ namespace SepCore.Editor
|
|||
File.Delete(fileName);
|
||||
}
|
||||
|
||||
Utility.Path.RemoveEmptyDirectory(streamingAssetsPath);
|
||||
GameFramework.Utility.Path.RemoveEmptyDirectory(streamingAssetsPath);
|
||||
}
|
||||
|
||||
public void OnPostprocessAllPlatforms(string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath)
|
||||
public void OnPostprocessAllPlatforms(string productName, string companyName, string gameIdentifier,
|
||||
string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName,
|
||||
bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName,
|
||||
string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected,
|
||||
string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPreprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath)
|
||||
public void OnPreprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected,
|
||||
string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected,
|
||||
string outputPackedPath)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnBuildAssetBundlesComplete(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, AssetBundleManifest assetBundleManifest)
|
||||
public void OnBuildAssetBundlesComplete(Platform platform, string workingPath, bool outputPackageSelected,
|
||||
string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected,
|
||||
string outputPackedPath, AssetBundleManifest assetBundleManifest)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnOutputUpdatableVersionListData(Platform platform, string versionListPath, int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode)
|
||||
public void OnOutputUpdatableVersionListData(Platform platform, string versionListPath, int versionListLength,
|
||||
int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPostprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, bool isSuccess)
|
||||
public void OnPostprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected,
|
||||
string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected,
|
||||
string outputPackedPath, bool isSuccess)
|
||||
{
|
||||
if (!outputPackageSelected)
|
||||
{
|
||||
|
|
@ -65,11 +78,13 @@ namespace SepCore.Editor
|
|||
return;
|
||||
}
|
||||
|
||||
string streamingAssetsPath = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "StreamingAssets"));
|
||||
string streamingAssetsPath =
|
||||
GameFramework.Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "StreamingAssets"));
|
||||
string[] fileNames = Directory.GetFiles(outputPackagePath, "*", SearchOption.AllDirectories);
|
||||
foreach (string fileName in fileNames)
|
||||
{
|
||||
string destFileName = Utility.Path.GetRegularPath(Path.Combine(streamingAssetsPath, fileName.Substring(outputPackagePath.Length)));
|
||||
string destFileName = GameFramework.Utility.Path.GetRegularPath(Path.Combine(streamingAssetsPath,
|
||||
fileName.Substring(outputPackagePath.Length)));
|
||||
FileInfo destFileInfo = new FileInfo(destFileName);
|
||||
if (!destFileInfo.Directory.Exists)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,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;
|
||||
|
|
@ -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,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,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,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,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d562d735e382c1e4388ff5f7d3b57bd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue