TH1/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/KaguyaFrenchForeverBuffSkill.cs
2026-04-20 22:57:40 +08:00

104 lines
3.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: 白哉
* @Description:
* @Date: 2025年09月12日 星期四 17:09:18
* @Modify:
*/
using RuntimeData;
using System;
using MemoryPack;
using TH1_Anim.Fragments;
using TH1_Core.Managers;
using TH1_Logic.Core;
using TH1Renderer;
namespace Logic.Skill
{
public partial class KaguyaFrenchForeverBuffSkill : SkillBase
{
public KaguyaFrenchForeverBuffSkill()
{
IsLevelSkill = true;
IsPermanent = false;
TurnsLimit = 1;
Score = 4;
_levelLimit = 999;
}
public override SkillType GetSkillType()
{
return SkillType.KAGUYAFRENCHFOREVERBUFF;
}
// public override bool IsCanBeKill(UnitData self, MapData mapData)
// {
// return _level <= 0;
// }
//
// public override void OnDamaged(MapData mapData, SettlementInfo info)
// {
// if (_level == 0) return;
// if (info.DamageTarget == null || info.DamageTarget.Health > 0) return;
// info.DamageTarget.Health = 1;
// _level--;
// if (_level > 0) return;
// info.DamageTarget.RemoveSkill(GetSkillType(), mapData);
// }
public override void BeforeDamagedTransformStage(MapData mapData, SettlementInfo info)
{
if (_level <= 0) return;
if (info.DamageTarget == null) return;
if (info.DamageType == DamageType.KillSelf) return;
// 保存原始伤害值将伤害设为0本次不会因伤害失去生命
int dmg = info.DamageValue;
info.DamageValue = 0;
// 失去1层
_level--;
if (_level <= 0)
info.DamageTarget.RemoveSkill(GetSkillType(), mapData);
// 将伤害量转化为对应层数的CrescentMoon持续0回合
if (dmg > 0)
{
info.DamageTarget.AddSkill_Legacy(SkillType.KaguyaFrenchCrescentMoon, mapData, false, 0, true, dmg, true, SpecialAddSkillType.AddLevel, info.DamageTarget.Id);
if (mapData != Main.MapData) return;
if (!mapData.GetGridDataByUnitId(info.DamageTarget.Id, out var targetGrid)) return;
int phase = info.DamageType == DamageType.ActiveAttack
? AnimPhase.AttackImpact + 50
: AnimPhase.CounterImpact + 50;
var scope = PresentationManager.CurrentScope;
if (scope != null)
{
scope.Add(new FragmentStep
{
Phase = phase,
Duration = 0.1f,
Execute = () =>
{
targetGrid.Renderer(mapData)?.PlayVFXInSight(
new GridVFXParams(GridVFXType.SkillIcon, SkillType.KAGUYAFRENCHFOREVERBUFF, info.DamageTarget.UnitFullType));
}
});
}
else
{
targetGrid.Renderer(mapData)?.PlayVFXInSight(
new GridVFXParams(GridVFXType.SkillIcon, SkillType.KAGUYAFRENCHFOREVERBUFF, info.DamageTarget.UnitFullType));
}
}
}
public override bool ReservedOnTransform(UnitData self, UnitFullType fullType)
{
return true;
}
}
}