2026-02-14 22:57:12 +08:00

72 lines
2.7 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年04月23日 星期三 21:04:18
* @Modify:
*/
using System;
using System.Collections.Generic;
using MemoryPack;
using RuntimeData;
using TH1_Logic.Core;
using TH1Renderer;
namespace Logic.Skill
{
public partial class AllYCounterSkill : SkillBase
{
public AllYCounterSkill()
{
IsPermanent = true;
TurnsLimit = 0;
Score = 4;
}
public override SkillType GetSkillType()
{
return SkillType.ALLYCOUNTER;
}
public override void OnUnitDamaged(UnitData self, MapData mapData, SettlementInfo info)
{
if (info == null) return;
//必须是主动攻击
if (info.DamageType != DamageType.ActiveAttack) return;
if (info.DamageOrigin == null || info.DamageTarget == null) return;
//不能打的是我,要打的别人
if (!mapData.GetGridDataByUnitId(self.Id, out var selfGrid)) return;
if (!mapData.GetPlayerIdByUnitId(info.DamageOrigin.Id, out var originPlayer)) return;
if (!mapData.GetPlayerIdByUnitId(info.DamageTarget.Id, out var targetPlayer)) return;
if (!mapData.GetPlayerDataByUnitId( self.Id, out var selfPlayer)) return;
//来源是友军就返回
if (mapData.SameUnion(originPlayer,selfPlayer.Id)) return;
//目标不是友军就返回
if (!mapData.SameUnion(targetPlayer,selfPlayer.Id)) return;
if (!mapData.GetGridDataByUnitId(info.DamageOrigin.Id, out var originGrid)) return;
if (!mapData.GetGridDataByUnitId(info.DamageTarget.Id, out var targetGrid)) return;
//必须受伤在2格内攻击者在3格内
if (Table.Instance.CalcDistance(selfGrid, targetGrid) > 2 ||
Table.Instance.CalcDistance(selfGrid, originGrid) > 3) return;
//攻击者在视野内
if (!selfPlayer.Sight.CheckIsInSight(originGrid.Id)) return;
//判定成功,开始增加追加伤害
Main.UnitLogic.DamageSettlement(mapData, self, info.DamageOrigin, 5, DamageType.FollowAttack);
var additionAttackDuration = 1f;
//TODO 表现缺失
Timer.Instance.TimerRegister(this,() =>
{
originGrid.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Damage,5));
originGrid.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Hurt));
},Table.Instance.AnimDataAssets.AttackArrowTime + additionAttackDuration,"OnUnitDamaged Skill Attack Hurt");
}
}
}