zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Server/Hotfix/Game/Common/Bag/AddHpGoodsEffect.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using Cal;
using Cal.DataTable;
using System;
using System.Collections.Generic;
using System.Text;
namespace ET
{
public class AddHpGoodsEffect : 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 "禁用药水";
}
2021-04-11 19:50:39 +08:00
NumericComponent num = unit.GetComponent<NumericComponent>();
2021-04-08 20:09:59 +08:00
if (num.GetAsInt(NumericType.Hp) >= num.GetAsInt(NumericType.MaxHp))
{
return "Hp已满,无法使用!";
}
int hp = MathHelper.RoundToInt(GoodsBase.PercentHp * num.GetAsInt(NumericType.MaxHp)) + GoodsBase.FixedHp;
num.AddSet(NumericType.Hp, hp);
Game.EventSystem.Publish(new EventType.ChangeUnitCharacter { unit = unit }).Coroutine();
return string.Empty;
}
public override async ETVoid Execute()
{
await ETTask.CompletedTask;
}
}
}