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; long now = TimeHelper.ClientNow(); BuffEndTime = now + GoodsBase.ContinuedSeconds; GoodsEffectComponent.Instance.AddGoodsBuff(unit.Id,GoodsEffectType.AddBattleExpSpeed,this); PlayerData data = unit.GetComponent(); data.BattleExpSpeed = GoodsBase.ExpRange; data.battleExpSpeedLeastTime = now + GoodsBase.ContinuedSeconds; BuffState = BuffState.Running; UnitHelper.SaveComponenet(data).Coroutine(); 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().BattleExpSpeed = 1; // BuffState = BuffState.Finished; // await DBComponent.Instance.Save(_unitInLib); // return; // } // Log.Error($"玩家Id=【{unitId}】 在数据库中不存在"); // } // unit.GetComponent().BattleExpSpeed = 1; // BuffState = BuffState.Finished; //} //catch (Exception e) //{ // Log.Error(e); //} await ETTask.CompletedTask; } } }