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

81 lines
2.4 KiB
C#
Raw Normal View History

2023-12-28 13:49:45 +08:00
using System.Collections.Generic;
using Framework;
2023-12-13 16:20:41 +08:00
using Gameplay.Unit;
2023-08-22 19:08:45 +08:00
namespace Gameplay.Skill
{
using cfg.SkillCfg;
2024-10-16 20:47:56 +08:00
using Gameplay.Guide;
using Gameplay.Level;
2023-08-22 19:08:45 +08:00
2023-10-19 15:00:19 +08:00
public class SkillHandle
2023-08-22 19:08:45 +08:00
{
2023-10-19 15:00:19 +08:00
public readonly GameUnit owner;
public List<uint> cacheHitUnitIds = new List<uint>();
2023-08-22 19:08:45 +08:00
2023-10-19 15:00:19 +08:00
public readonly SkillRuntimeData runtimeData;
2023-08-22 19:08:45 +08:00
public bool canRelease
{
get
{
if (!owner.isReady) return false;
if (owner.statusData.isDead) return false;
2023-08-22 19:08:45 +08:00
return runtimeData.remainCDTime <= 0;
}
}
2023-10-19 15:00:19 +08:00
public SkillHandle(GameUnit owner, DataSkill configData)
2023-08-22 19:08:45 +08:00
{
this.owner = owner;
2023-10-19 15:00:19 +08:00
runtimeData = new SkillRuntimeData(configData);
2023-08-22 19:08:45 +08:00
2024-10-16 20:47:56 +08:00
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;
2023-08-22 19:08:45 +08:00
}
public void LogicUpdate(float dt)
{
var scale = owner.fightData.skillCdReduceScale;
runtimeData.remainCDTime -= dt * scale;
}
public void ReduceSkillCd(float reduceTime)
{
runtimeData.remainCDTime -= reduceTime;
2023-08-22 19:08:45 +08:00
}
public void Use(int targetCellIndex)
{
if (!canRelease)
{
DebugUtil.LogError("技能未准备好或者CD未冷却");
return;
}
2024-05-17 15:37:56 +08:00
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);
}
2023-08-22 19:08:45 +08:00
}
public void TriggerSkillEnd()
{
// 技能结束时触发,重置技能CD
}
2023-08-22 19:08:45 +08:00
}
}