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

63 lines
2.3 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.Data;
using System.Text;
namespace ET
{
public class AddBattleExpSpeedGoodsEffect : GoodsEffect
{
public override string Init(Unit unit, GoodsBase goodsBase,bool isLock =false)
{
base.unit = unit;
base.unitId = unit.Id;
GoodsBase = goodsBase;
2021-04-11 19:50:39 +08:00
long now = TimeHelper.ClientNow();
2021-04-08 20:09:59 +08:00
BuffEndTime = now + GoodsBase.ContinuedSeconds;
GoodsEffectComponent.Instance.AddGoodsBuff(unit.Id,GoodsEffectType.AddBattleExpSpeed,this);
2021-04-11 19:50:39 +08:00
PlayerData data = unit.GetComponent<PlayerData>();
2021-04-08 20:09:59 +08:00
data.BattleExpSpeed = GoodsBase.ExpRange;
data.battleExpSpeedLeastTime = now + GoodsBase.ContinuedSeconds;
BuffState = BuffState.Running;
2021-06-29 11:28:15 +08:00
UnitHelper.SaveComponenet(data);
2021-04-08 20:09:59 +08:00
return string.Empty;
}
public override void ReInit(Unit unit, GoodsBase goodsBase,long endTime)
{
//base.unit = unit;
//base.unitId = unit.Id;
//GoodsBase = goodsBase;
//BuffEndTime = endTime;
//GoodsEffectComponent.Instance.AddGoodsBuff(unit.Id, GoodsEffectType.AddBattleExpSpeed, this);
//BuffState = BuffState.Running;
}
public override async ETVoid Execute()
{
//try
//{
// if (BuffEndTime > TimeHelper.ClientNow()) return;
// if (!unit)
// {
// using Unit _unitInLib = await UnitHelper.Query(Game.Scene, unitId);
// if (_unitInLib != null)
// {
// _unitInLib.GetComponent<PlayerData>().BattleExpSpeed = 1;
// BuffState = BuffState.Finished;
// await DBComponent.Instance.Save(_unitInLib);
// return;
// }
// Log.Error($"玩家Id=【{unitId}】 在数据库中不存在");
// }
// unit.GetComponent<PlayerData>().BattleExpSpeed = 1;
// BuffState = BuffState.Finished;
//}
//catch (Exception e)
//{
// Log.Error(e);
//}
await ETTask.CompletedTask;
}
}
}