63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
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;
|
|
var now = TimeHelper.ClientNow();
|
|
BuffEndTime = now + GoodsBase.ContinuedSeconds;
|
|
GoodsEffectComponent.Instance.AddGoodsBuff(unit.Id,GoodsEffectType.AddBattleExpSpeed,this);
|
|
var data = unit.GetComponent<PlayerData>();
|
|
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<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;
|
|
}
|
|
}
|
|
} |