108 lines
2.4 KiB
C#
108 lines
2.4 KiB
C#
using cfg.SkillCfg;
|
|
using UnityEngine;
|
|
namespace Gameplay.Skill.Charge
|
|
{
|
|
public abstract class BaseSkillCharge : ISkillCharge
|
|
{
|
|
|
|
public readonly SkillHandle skillHandle;
|
|
|
|
public float chargeProgress
|
|
{
|
|
get;
|
|
protected set;
|
|
} = 0f;
|
|
|
|
public EChargeType chargeType
|
|
{
|
|
get;
|
|
}
|
|
public int nowStoreCount
|
|
{
|
|
get;
|
|
protected set;
|
|
} = 0;
|
|
|
|
protected readonly int _maxUseCount;
|
|
protected int _nowUseCount { get; private set; } = 0;
|
|
|
|
protected int _maxStoreCount
|
|
{
|
|
get
|
|
{
|
|
if (_maxUseCount >= 0)
|
|
{
|
|
// 有使用次数限制
|
|
var remainUseCount = _maxUseCount - _nowUseCount;
|
|
return Mathf.Min(remainUseCount, _cfgMaxStoreCount);
|
|
}
|
|
return _cfgMaxStoreCount;
|
|
}
|
|
}
|
|
protected int _cfgMaxStoreCount;
|
|
|
|
public DataSkill rawConfig;
|
|
|
|
public BaseSkillCharge(SkillHandle skillHandle)
|
|
{
|
|
this.skillHandle = skillHandle;
|
|
rawConfig = skillHandle.runtimeData.configData;
|
|
chargeType = skillHandle.runtimeData.configData.ChargeType;
|
|
|
|
_maxUseCount = rawConfig.MaxUseCount;
|
|
_cfgMaxStoreCount = rawConfig.MaxStoreCount;
|
|
}
|
|
|
|
public void TriggerUse()
|
|
{
|
|
_nowUseCount++;
|
|
nowStoreCount--;
|
|
_OnUse();
|
|
}
|
|
|
|
protected virtual void _OnUse()
|
|
{
|
|
|
|
}
|
|
|
|
public void TriggerTimeChange(float dt)
|
|
{
|
|
_OnTimeChange(dt);
|
|
}
|
|
|
|
protected virtual void _OnTimeChange(float dt)
|
|
{
|
|
}
|
|
|
|
public void TriggerNormalAttack()
|
|
{
|
|
_OnNormalAttack();
|
|
}
|
|
|
|
protected virtual void _OnNormalAttack()
|
|
{
|
|
|
|
}
|
|
|
|
public void TriggerBeAttack()
|
|
{
|
|
_OnBeAttack();
|
|
}
|
|
|
|
protected virtual void _OnBeAttack()
|
|
{
|
|
|
|
}
|
|
|
|
public void AddStoreCount(int count)
|
|
{
|
|
nowStoreCount += count;
|
|
if (nowStoreCount > _maxStoreCount)
|
|
{
|
|
nowStoreCount = _maxStoreCount;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|