79 lines
2.7 KiB
C#
Executable File
79 lines
2.7 KiB
C#
Executable File
using Cal.DataTable;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace ET
|
|
{
|
|
public class AddMpBuffGoodsEffect : 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.AddMpBuff, this);
|
|
unit.GetComponent<PlayerData>().mpAutoFullCapatial = KeyValuePair.Create(GoodsBase.Capacity,(int)(GoodsBase.PercentMp*10000));
|
|
BuffState = BuffState.Finished;
|
|
return string.Empty;
|
|
}
|
|
//public override void ReInit(Unit unit, GoodsBase goodsBase,long endTime)
|
|
//{
|
|
// base.unit = unit;
|
|
// base.unitId = unit.Id;
|
|
// GoodsBase = goodsBase;
|
|
// BuffState = BuffState.Waiting;
|
|
// GoodsEffectComponent.Instance.AddGoodsBuff(unit.Id, GoodsEffectType.AddMpBuff, this);
|
|
//}
|
|
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 mp = MathHelper.RoundToInt(GoodsBase.PercentMp * num.GetAsInt(NumericType.MaxMp)) + GoodsBase.FixedMp-num.GetAsInt(NumericType.Mp);
|
|
//if (mp < 0) mp = 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 (mp > capacity)
|
|
//{
|
|
// mp = capacity;
|
|
//}
|
|
//dic[(int)GoodsBase.Id] -= mp;
|
|
////!保存
|
|
//num.AddSet(NumericType.Mp, mp);
|
|
//BuffState = BuffState.Waiting;
|
|
//await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
} |