整理武器配置和重构
This commit is contained in:
@@ -1,59 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public class WeaponData : AccessoryObjectData
|
||||
{
|
||||
private readonly WeaponConfig _weaponConfig;
|
||||
public WeaponConfig Config { get; }
|
||||
|
||||
public WeaponData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(weaponConfig.Prefab, entityId, ownerId, ownerCamp)
|
||||
{
|
||||
_weaponConfig = weaponConfig;
|
||||
Config = weaponConfig;
|
||||
}
|
||||
|
||||
public WeaponConfig Config => _weaponConfig;
|
||||
public WeaponType WeaponType => Config.WeaponType;
|
||||
|
||||
public WeaponType WeaponType => _weaponConfig.WeaponType;
|
||||
public string LogicType => Config.LogicType;
|
||||
|
||||
public string LogicType => _weaponConfig.LogicType;
|
||||
public int Attack => Config.Attack;
|
||||
|
||||
public int Attack => _weaponConfig.Attack;
|
||||
public string Title => Config.WeaponType.ToString();
|
||||
|
||||
public string Title => _weaponConfig.WeaponType.ToString();
|
||||
public string Sprite => Config.Sprite;
|
||||
|
||||
public string IconAssetName => _weaponConfig.Sprite;
|
||||
public Rarity Rarity => Config.Rarity;
|
||||
|
||||
public Rarity Rarity => _weaponConfig.Rarity;
|
||||
public int Price => Config.Price;
|
||||
|
||||
public int Price => _weaponConfig.Price;
|
||||
public float Cooldown => Config.Cooldown / 1000f;
|
||||
|
||||
public float Cooldown => _weaponConfig.Cooldown / 1000f;
|
||||
public float AttackRange => Config.AttackRange / 1000f;
|
||||
|
||||
public float AttackRange => _weaponConfig.AttackRange / 1000f;
|
||||
public int AttackSoundId => Config.AttackSoundId;
|
||||
|
||||
public int AttackSoundId => _weaponConfig.AttackSoundId;
|
||||
public IReadOnlyDictionary<ParamType, int> Parameters => Config.Parameters;
|
||||
|
||||
public IReadOnlyDictionary<ParamType, int> Parameters => _weaponConfig.Parameters;
|
||||
public IReadOnlyList<modifier> Modifiers => Config.Modifiers;
|
||||
|
||||
public IReadOnlyList<modifier> Modifiers => _weaponConfig.Modifiers;
|
||||
|
||||
public int GetParam(ParamType paramType, int defaultValue = 0)
|
||||
public int GetParam(ParamType paramType)
|
||||
{
|
||||
return _weaponConfig.Parameters.TryGetValue(paramType, out int value) ? value : defaultValue;
|
||||
if (Config.Parameters.TryGetValue(paramType, out int value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
Log.Error("Weapon parameter '{0}' not found for weapon '{1}'.", paramType, Config.WeaponType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float GetParamFloat(ParamType paramType, float defaultValue = 0f)
|
||||
public float GetParamFloat(ParamType paramType)
|
||||
{
|
||||
if (_weaponConfig.Parameters.TryGetValue(paramType, out int val))
|
||||
if (Config.Parameters.TryGetValue(paramType, out int val))
|
||||
{
|
||||
return paramType == ParamType.SectorAngle ? val : val / 1000f;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
Log.Error("Weapon parameter '{0}' not found for weapon '{1}'.", paramType, Config.WeaponType);
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponHandgunParamsData
|
||||
{
|
||||
}
|
||||
|
||||
public class WeaponHandgunData : WeaponData
|
||||
{
|
||||
public WeaponHandgunParamsData ParamsData { get; }
|
||||
|
||||
public WeaponHandgunData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = new WeaponHandgunParamsData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 574d105bf89bf7546a682ed407708034
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponKnifeParamsData
|
||||
{
|
||||
public float HitRadius { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponKnifeData : WeaponData
|
||||
{
|
||||
public WeaponKnifeParamsData ParamsData { get; }
|
||||
|
||||
public WeaponKnifeData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = new WeaponKnifeParamsData
|
||||
{
|
||||
HitRadius = GetParamFloat(ParamType.HitRadius)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da25d8e0669f0194d8f56f4283c67b38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[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, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = new WeaponLanceParamsData
|
||||
{
|
||||
HitHalfWidth = GetParamFloat(ParamType.HitHalfWidth),
|
||||
PierceLength = GetParamFloat(ParamType.PierceLength),
|
||||
HitHeight = GetParamFloat(ParamType.HitHeight)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d1a821e8ee1a9a4b912b70b0a1616eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[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, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = new WeaponLightningParamsData
|
||||
{
|
||||
HitRadius = GetParamFloat(ParamType.HitRadius),
|
||||
HoverHeight = 0f
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25b0006918fd46959c7f6b8ec1bbc8ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponSlashParamsData
|
||||
{
|
||||
public float SectorAngle { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponSlashData : WeaponData
|
||||
{
|
||||
public WeaponSlashParamsData ParamsData { get; }
|
||||
|
||||
public WeaponSlashData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, weaponConfig, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = new WeaponSlashParamsData
|
||||
{
|
||||
SectorAngle = GetParamFloat(ParamType.SectorAngle)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4aa6473525dc4c62aeee02ff562ec453
|
||||
timeCreated: 1771484661
|
||||
Reference in New Issue
Block a user