45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
|
using Cal;
|
|||
|
using Cal.DataTable;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class AddHpOrMpGoodsEffect : GoodsEffect
|
|||
|
{
|
|||
|
public override string Init(Unit unit, GoodsBase goodsBase,bool isLock =false)
|
|||
|
{
|
|||
|
base.unit = unit;
|
|||
|
GoodsBase = goodsBase;
|
|||
|
return Run();
|
|||
|
}
|
|||
|
|
|||
|
private string Run()
|
|||
|
{
|
|||
|
ModifierContainerComponent modifierContainerComponent = unit.GetComponent<ModifierContainerComponent>();
|
|||
|
if (modifierContainerComponent.HasState(ModifierStateType.禁用药水))
|
|||
|
{
|
|||
|
return "禁用药水";
|
|||
|
}
|
|||
|
var num = unit.GetComponent<NumericComponent>();
|
|||
|
if (num.GetAsInt(NumericType.Hp) >= num.GetAsInt(NumericType.MaxHp) &&
|
|||
|
num.GetAsInt(NumericType.Mp) >= num.GetAsInt(NumericType.MaxMp))
|
|||
|
{
|
|||
|
return "Hp和Mp已满,无法使用!";
|
|||
|
}
|
|||
|
int hp = MathHelper.RoundToInt(GoodsBase.PercentHp * num.GetAsInt(NumericType.MaxHp)) + GoodsBase.FixedHp;
|
|||
|
int mp = MathHelper.RoundToInt(GoodsBase.PercentMp * num.GetAsInt(NumericType.MaxMp)) + GoodsBase.FixedMp;
|
|||
|
num.AddSet(NumericType.Hp, hp);
|
|||
|
num.AddSet(NumericType.Mp, mp);
|
|||
|
Game.EventSystem.Publish(new EventType.ChangeUnitCharacter { unit = unit }).Coroutine();
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
public override async ETVoid Execute()
|
|||
|
{
|
|||
|
await ETTask.CompletedTask;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|