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 IActionContext handler(IActionContext ac) { MessageActionContext mac = (MessageActionContext) ac; IPerformer source = mac.getPerformer(); IClientSimuiation clientSimuiation = mac.getClientSimuiation(); if (source.getControler() != clientSimuiation) { // 控制者不是该用户 return null; } IActionContext context = source.getGlobalContext().getActionContextFactory().createIdleContext(source); return context; }
@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); } }