93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
/*
|
||
* @Author: 白哉
|
||
* @Description:
|
||
* @Date: 2025年10月12日 星期六 10:10:12
|
||
* @Modify:
|
||
*/
|
||
|
||
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using Logic.Pool;
|
||
using MemoryPack;
|
||
using RuntimeData;
|
||
using UnityEngine;
|
||
|
||
|
||
namespace Logic.Skill
|
||
{
|
||
public partial class SakuyaFlySkill : SkillBase
|
||
{
|
||
public SakuyaFlySkill()
|
||
{
|
||
IsPermanent = true;
|
||
TurnsLimit = 0;
|
||
Score = 2;
|
||
IsLevelSkill = true;
|
||
_levelLimit = int.MaxValue;
|
||
// 咲夜飞行需要在0层时继续保留,用于每回合重新从0开始累计疲劳。
|
||
_autoDisappear = false;
|
||
}
|
||
|
||
public override SkillType GetSkillType()
|
||
{
|
||
return SkillType.SAKUYAFLY;
|
||
}
|
||
|
||
public override void OnTurnStart(IdentifierBase identifier, MapData mapData)
|
||
{
|
||
// 持有者回合开始时重置为0层;_autoDisappear=false保证0层不会被回收。
|
||
_level = 0;
|
||
}
|
||
|
||
public override bool IsCanMoveGiantNearbyGrid(UnitData unit, MapData map)
|
||
{
|
||
return true;
|
||
}
|
||
public override bool IsCanTransport()
|
||
{
|
||
return true;
|
||
}
|
||
|
||
public override void OnMove(UnitData self, GridData grid, MapData mapData, MoveType moveType, List<Vector2Int> path = null)
|
||
{
|
||
if (moveType != MoveType.SkillMove) return;
|
||
var player = self.Player(mapData);
|
||
if (player == null) return;
|
||
using var pooledSelfUnitList = THCollectionPool.GetHashSetHandle<UnitData>(out var selfUnitList);
|
||
mapData.GetUnitDataListByPlayerId(player.Id, selfUnitList);
|
||
|
||
if (!mapData.GetGridDataByUnitId(self.Id, out var targetGrid)) return;
|
||
var aroundBuf = RentAroundBuf();
|
||
mapData.GridMap.GetAroundGridData(1, 1, targetGrid, aroundBuf);
|
||
bool isExcute = false;
|
||
foreach (var gridData in aroundBuf)
|
||
{
|
||
if (targetGrid == gridData) continue;
|
||
gridData.VisibleUnit(mapData,player,out var unit);
|
||
if (unit == null || unit == self) continue;
|
||
if (!unit.TreatedAsHero(mapData,self)) continue;
|
||
if (!selfUnitList.Contains(unit)) continue;
|
||
unit.AddSkill_Legacy(SkillType.SAKUYAGUARD, mapData,false,1,false, -1,false,SpecialAddSkillType.Force,0);
|
||
isExcute = true;
|
||
}
|
||
ReturnAroundBuf();
|
||
|
||
if (isExcute)
|
||
{
|
||
// 效果实际触发时,先按当前层数添加疲劳,再让自身层数+1。
|
||
// 第一次触发为0层,不添加无意义的SakuyaTired记录。
|
||
var tiredLevel = Level;
|
||
if (tiredLevel > 0)
|
||
{
|
||
self.AddSkill_Legacy(SkillType.SAKUYATIRED, mapData, true, 0, true, tiredLevel, true,
|
||
SpecialAddSkillType.AddLevel, self.Id);
|
||
}
|
||
|
||
AddLevel(mapData, self, self, 1);
|
||
self.AddActionPoint(ActionPointType.Attack);
|
||
}
|
||
}
|
||
}
|
||
}
|