58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年04月23日 星期三 21:04:18
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using RuntimeData;
|
|
using System;
|
|
using MemoryPack;
|
|
|
|
|
|
namespace Logic.Skill
|
|
{
|
|
public partial class PoorHealthSkill : SkillBase
|
|
{
|
|
public PoorHealthSkill()
|
|
{
|
|
IsPermanent = true;
|
|
TurnsLimit = 0;
|
|
Score = -10;
|
|
}
|
|
|
|
public override SkillType GetSkillType()
|
|
{
|
|
return SkillType.POORHEALTH;
|
|
}
|
|
|
|
//在友方学院或者城市中心时,回合结束+2生命
|
|
public override void OnMove(UnitData self, GridData grid, MapData mapData, MoveType moveType)
|
|
{
|
|
if (moveType == MoveType.ActiveMove)
|
|
{
|
|
self.Health -= 2;
|
|
if (self.Health <= 0)
|
|
self.Health = 1;
|
|
}
|
|
}
|
|
|
|
public override void OnTurnEnd(UnitData self, MapData mapData)
|
|
{
|
|
|
|
if (!mapData.GetGridDataByUnitId(self.Id, out var grid)) return;
|
|
//如果不是citycenter或者academy
|
|
if (!(grid.Resource is ResourceType.Academy or ResourceType.CityCenter)) return;
|
|
//中立领土则return
|
|
if (!mapData.GetPlayerDataByTerritoryGridId(grid.Id, out var gridPlayer)) return;
|
|
if (!mapData.GetPlayerDataByUnitId(self.Id, out var unitPlayer)) return;
|
|
//如果不是在友方领土上
|
|
if (!mapData.SameUnion(gridPlayer.Id, unitPlayer.Id)) return;
|
|
self.Health += 2;
|
|
if (self.Health > self.GetMaxHealth())
|
|
self.Health = self.GetMaxHealth();
|
|
self.RenderMark = true;
|
|
}
|
|
}
|
|
} |