public void affect(IBuffContext context) { BuffPrototype buffPrototype = context.getBuffPrototype(); IPerformer performer = context.getPerformer(); // 间隔时间到,进行掉血处理 int changeValue = 0; if (buffPrototype.getValueType() == ValueTypeEnum.Value_Num.value()) { // 数值 changeValue = buffPrototype.getDamageAmountList().get(0); } else { // 百分比 changeValue = (int) (performer .getAttrMgr() .getAttrValue( AttrSourceTypeEnum.AS_Base.value(), AttrTypeEnum.Attr_Energy.value()) * buffPrototype.getDamageAmountList().get(0) / 100.0f); } if (buffPrototype.getBuffOrDebuff() == BuffBeneficialTypeEnum.Beneficial_Bad.value()) { // 减益 changeValue = -changeValue; } performer.getAttrMgr().changeConsumeValue(AttrTypeEnum.Attr_Energy.value(), changeValue); }
@Override public void update(IBuffContext context) { BuffPrototype buffPrototype = context.getBuffPrototype(); IPerformer performer = context.getPerformer(); affect(context); long differTime = context .getPerformer() .getGlobalContext() .getClock() .differByCurrentTime(context.getStartTime()); if (differTime >= buffPrototype.getEffectiveTime()) { // 效果时间到 performer.getBuffManager().exit(context); } }