整理武器配置和重构
This commit is contained in:
@@ -18,12 +18,55 @@ namespace SepCore.Definition
|
||||
{
|
||||
public const string DefaultLayerName = "Default";
|
||||
public static readonly int DefaultLayerId = LayerMask.NameToLayer(DefaultLayerName);
|
||||
public static readonly LayerMask DefaultLayerMask = 1 << DefaultLayerId;
|
||||
|
||||
public const string TransparentFXLayerName = "TransparentFX";
|
||||
public static readonly int TransparentLayerId = LayerMask.NameToLayer(TransparentFXLayerName);
|
||||
public static readonly LayerMask TransparentLayerMask = 1 << TransparentLayerId;
|
||||
|
||||
public const string IgnoreRaycastLayerName = "Ignore Raycast";
|
||||
public static readonly int IgnoreLayerId = LayerMask.NameToLayer(IgnoreRaycastLayerName);
|
||||
public static readonly LayerMask IgnoreLayerMask = 1 << IgnoreLayerId;
|
||||
|
||||
public const string WaterLayerName = "Water";
|
||||
public static readonly int WaterLayerId = LayerMask.NameToLayer(WaterLayerName);
|
||||
public static readonly LayerMask WaterLayerMask = 1 << WaterLayerId;
|
||||
|
||||
public const string UILayerName = "UI";
|
||||
public static readonly int UILayerId = LayerMask.NameToLayer(UILayerName);
|
||||
public static readonly LayerMask UILayerMask = 1 << UILayerId;
|
||||
|
||||
public const string TargetableObjectLayerName = "Targetable Object";
|
||||
public static readonly int TargetableObjectLayerId = LayerMask.NameToLayer(TargetableObjectLayerName);
|
||||
public static readonly LayerMask TargetableObjectLayerMask = 1 << TargetableObjectLayerId;
|
||||
|
||||
public const string PlayerLayerName = "Player";
|
||||
public static readonly int PlayerLayerId = LayerMask.NameToLayer(PlayerLayerName);
|
||||
public static readonly LayerMask PlayerLayerMask = 1 << PlayerLayerId;
|
||||
|
||||
public const string EnemyLayerName = "Enemy";
|
||||
public static readonly int EnemyLayerId = LayerMask.NameToLayer(EnemyLayerName);
|
||||
public static readonly LayerMask EnemyLayerMask = 1 << EnemyLayerId;
|
||||
|
||||
public const string PlayerBulletLayerName = "PlayerBullet";
|
||||
public static readonly int PlayerBulletLayerId = LayerMask.NameToLayer(PlayerBulletLayerName);
|
||||
public static readonly LayerMask PlayerBulletLayerMask = 1 << PlayerBulletLayerId;
|
||||
|
||||
public const string EnemyBulletLayerName = "EnemyBullet";
|
||||
public static readonly int EnemyBulletLayerId = LayerMask.NameToLayer(EnemyBulletLayerName);
|
||||
public static readonly LayerMask EnemyBulletLayerMask = 1 << EnemyBulletLayerId;
|
||||
|
||||
public const string PlayerWeaponLayerName = "PlayerWeapon";
|
||||
public static readonly int PlayerWeaponLayerId = LayerMask.NameToLayer(PlayerWeaponLayerName);
|
||||
public static readonly LayerMask PlayerWeaponLayerMask = 1 << PlayerWeaponLayerId;
|
||||
|
||||
public const string EnemyWeaponLayerName = "EnemyWeapon";
|
||||
public static readonly int EnemyWeaponLayerId = LayerMask.NameToLayer(EnemyWeaponLayerName);
|
||||
public static readonly LayerMask EnemyWeaponLayerMask = 1 << EnemyWeaponLayerId;
|
||||
|
||||
public const string DropLayerName = "Drop";
|
||||
public static readonly int DropLayerId = LayerMask.NameToLayer(DropLayerName);
|
||||
public static readonly LayerMask DropLayerMask = 1 << DropLayerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <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 WeaponStateType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 无
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 攻击
|
||||
/// </summary>
|
||||
Attack = 1,
|
||||
/// <summary>
|
||||
/// 待机
|
||||
/// </summary>
|
||||
Idle = 2,
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
Seek = 3,
|
||||
/// <summary>
|
||||
/// 瞄准
|
||||
/// </summary>
|
||||
Aim = 4,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d1a821e8ee1a9a4b912b70b0a1616eb
|
||||
guid: 1065e2570786f184c9553db06202a6a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
Reference in New Issue
Block a user