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

42 lines
1.1 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using Cal.DataTable;
using System;
using System.Collections.Generic;
using System.Text;
namespace ET
{
public class AddEnergyGoodsEffect : GoodsEffect
{
private const int Energy_Limit = 2000;
public override string Init(Unit unit, GoodsBase goodsBase,bool isLock =false)
{
base.unit = unit;
GoodsBase = goodsBase;
return Run();
}
private string Run()
{
2021-04-11 19:50:39 +08:00
PlayerData data = unit.GetComponent<PlayerData>();
NumericComponent num = unit.GetComponent<NumericComponent>();
2021-04-08 20:09:59 +08:00
int energy = num.GetAsInt(NumericType.Energy);
energy += GoodsBase.CommonIncrease;
if (energy > Energy_Limit)
{
energy = Energy_Limit;
return $"行动值达到上限{Energy_Limit}";
}
num.Set(NumericType.Energy, energy);
data.ForbidExp = energy <= 0;
2021-06-29 11:28:15 +08:00
UnitHelper.SaveComponenet(data);
2021-04-08 20:09:59 +08:00
return string.Empty;
}
public override async ETVoid Execute()
{
await ETTask.CompletedTask;
}
}
}