87 lines
3.5 KiB
C#
87 lines
3.5 KiB
C#
/*
|
||
* @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(IdentifierBase identifier, MapData mapData, SettlementInfo info)
|
||
{
|
||
if (info == null) return;
|
||
//必须是主动攻击
|
||
if (info.DamageType != DamageType.ActiveAttack) return;
|
||
if (info.DamageOrigin == null || info.DamageTarget == null) return;
|
||
//不能打的是我,要打的别人
|
||
if (identifier is not UnitData self) 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;
|
||
Timer.Instance.TimerRegister(this,() =>
|
||
{
|
||
self.AttackRenderMark = true;
|
||
self.AttackRenderMarkAttackAnimType = self.GetAttackRange() switch
|
||
{
|
||
1 => AttackAnimType.Melee, 2 => AttackAnimType.Arrow, 3 => AttackAnimType.Bomb,
|
||
_ => AttackAnimType.None
|
||
};
|
||
if (self.GiantType == GiantType.EgyptianRemilia)
|
||
self.AttackRenderMarkAttackAnimType = AttackAnimType.RemiliaAttack;
|
||
self.AttackRenderMarkTargetPos = Table.Instance.GridToWorld(originGrid,"isUnit");
|
||
self.AttackRenderMarkNeedBack = false;
|
||
},additionAttackDuration,"OnUnitDamaged Skill Attack");
|
||
Timer.Instance.TimerRegister(this,() =>
|
||
{
|
||
var t = new GridVFXRenderMark(GridVFXType.Damage);
|
||
t.Damage = 5;
|
||
originGrid.SetGridVFXRenderMark(t);
|
||
originGrid.VFXRenderMarkHurt = true;
|
||
},Table.Instance.AnimDataAssets.AttackArrowTime + additionAttackDuration,"OnUnitDamaged Skill Attack Hurt");
|
||
|
||
}
|
||
}
|
||
} |