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

70 lines
2.4 KiB
C#
Executable File

using Cal.DataTable;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace ET
{
public class AddHpBuffGoodsEffect : GoodsEffect
{
public override string Init(Unit unit, GoodsBase goodsBase, bool isLock = false)
{
base.unit = unit;
base.unitId = unit.Id;
GoodsBase = goodsBase;
BuffState = BuffState.Waiting;
GoodsEffectComponent.Instance.AddGoodsBuff(unit.Id, GoodsEffectType.AddHpBuff, this);
unit.GetComponent<PlayerData>().hpAutoFullCapatial = KeyValuePair.Create(GoodsBase.Capacity,(int)(GoodsBase.PercentHp*10000));
BuffState = BuffState.Finished;
return string.Empty;
}
public override void RunOnce()
{
base.RunOnce();
Execute().Coroutine();
}
public override async ETVoid Execute()
{
await ETTask.CompletedTask;
//if (GoodsBase == null)
//{
// Log.Error($"goodsBase == null id =【{unitId}】 name = 【{ UserComponent.Instance.Get(unit.Id)?.NickName}】");
// return;
//}
//if (!unit)
//{
// BuffState = BuffState.Waiting;
// return;
//}
//var num = unit.GetComponent<NumericComponent>();
//int hp = MathHelper.RoundToInt(GoodsBase.PercentHp * num.GetAsInt(NumericType.MaxHp)) + GoodsBase.FixedHp - num.GetAsInt(NumericType.Hp);
//if (hp < 0) hp = 0;
//var data = unit.GetComponent<PlayerData>();
//if (data == null)
//{
// Log.Error($"data == null where id = {unit.Id} id = {unitId}");
// return;
//}
//var dic = data.GoodsCapacityDic;
//if (!dic.TryGetValue((int)GoodsBase.Id, out var capacity))
//{
// return;
//}
//if (capacity <= 0)
//{
// BuffState = BuffState.Finished;
// return;
//}
//if (hp > capacity)
//{
// hp = capacity;
//}
//dic[(int)GoodsBase.Id] -= hp;
////!保存
//num.AddSet(NumericType.Hp, hp);
//BuffState = BuffState.Waiting;
//await ETTask.CompletedTask;
}
}
}