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

45 lines
1.6 KiB
C#
Executable File

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 "禁用药水";
}
NumericComponent 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;
}
}
}