整理武器配置和重构
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user