NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Skill/SkillHandle.cs

81 lines
2.4 KiB
C#

using System.Collections.Generic;
using Framework;
using Gameplay.Unit;
namespace Gameplay.Skill
{
using cfg.SkillCfg;
using Gameplay.Guide;
using Gameplay.Level;
public class SkillHandle
{
public readonly GameUnit owner;
public List<uint> cacheHitUnitIds = new List<uint>();
public readonly SkillRuntimeData runtimeData;
public bool canRelease
{
get
{
if (!owner.isReady) return false;
if (owner.statusData.isDead) return false;
return runtimeData.remainCDTime <= 0;
}
}
public SkillHandle(GameUnit owner, DataSkill configData)
{
this.owner = owner;
runtimeData = new SkillRuntimeData(configData);
if (GuideManager.Instance.IsGuiding && // 新手引导特殊处理
null != LevelManager.Instance.CurrentLevel &&
100002 == LevelManager.Instance.CurrLevel.Cfg.Id &&
owner is Character.Character character &&
100003 == character.ConfigId) // 克劳迪亚
runtimeData.remainCDTime = 0f;
else
// 一开始处于不可释放状态
runtimeData.remainCDTime = runtimeData.maxCdTime;
}
public void LogicUpdate(float dt)
{
var scale = owner.fightData.skillCdReduceScale;
runtimeData.remainCDTime -= dt * scale;
}
public void ReduceSkillCd(float reduceTime)
{
runtimeData.remainCDTime -= reduceTime;
}
public void Use(int targetCellIndex)
{
if (!canRelease)
{
DebugUtil.LogError("技能未准备好或者CD未冷却");
return;
}
DebugUtil.LogG($"owner:{owner.GetUnitDesc()} 释放技能:{runtimeData.configData.ID} {runtimeData.configData.NameRead} 目标:{targetCellIndex}");
runtimeData.remainCDTime = runtimeData.maxCdTime;
owner._UseSkill(targetCellIndex, this);
if (owner.debugShowInfo.cacheConfigId != 0)
{
EventManager.Instance.Send(EventManager.EventName.INFIGHT_AUDIO_USE_SKILL, owner.debugShowInfo.cacheConfigId);
}
}
public void TriggerSkillEnd()
{
// 技能结束时触发,重置技能CD
}
}
}