private void ExecuteBuffRemove(BuffObj buffObj) { if (buffObj.model.onRemovedFunc == null) { return; } for (int i = 0; i < buffObj.model.onRemovedFunc.Count; i++) { BuffLifeCycleFunc func = buffObj.model.onRemovedFunc[i]; func.Execute(buffObj); } }
private void ExecuteKilledFunc(AddDamageInfo damageInfo) { if (damageInfo.attacker == null) { return; } //执行攻击者的Buff,OnHit函数 for (int i = 0; i < damageInfo.attacker.Buffs.Count; i++) { BuffObj killBuff = damageInfo.attacker.Buffs[i]; if (killBuff.model.onKilledFunc != null) { for (int j = 0; j < killBuff.model.onKilledFunc.Count; j++) { BuffKilledFunc func = killBuff.model.onKilledFunc[j]; func.Execute(killBuff, damageInfo, damageInfo.target); } } } }
private void ExecuteHurtFunc(AddDamageInfo damageInfo) { if (damageInfo.attacker == null) { return; } //执行攻击者的Buff,OnHit函数 for (int i = 0; i < damageInfo.attacker.Buffs.Count; i++) { BuffObj hitBuff = damageInfo.attacker.Buffs[i]; if (hitBuff.model.onHurtFunc != null) { for (int j = 0; j < hitBuff.model.onHurtFunc.Count; j++) { BuffHurtFunc func = hitBuff.model.onHurtFunc[j]; func.Execute(hitBuff, ref damageInfo, damageInfo.target); } } } }
private void UpdateBuff(SkillCom skillCom) { float deltaTime = SkillLocate.DeltaTime; //技能冷却 for (int i = 0; i < skillCom.Skills.Count; i++) { SkillObj skillObj = skillCom.Skills[i]; skillObj.coldDown -= deltaTime; } //更新Buff for (int i = 0; i < skillCom.Buffs.Count; i++) { BuffObj buffObj = skillCom.Buffs[i]; //持续时间 if (buffObj.isPermanent == false) buffObj.duration -= deltaTime; //存在时间 buffObj.timeElapsed += deltaTime; //检测OnTick if (buffObj.model.tickTime > 0) { //为了精度*1000 if (Mathf.RoundToInt(buffObj.timeElapsed * 1000) % Mathf.RoundToInt(buffObj.model.tickTime * 1000) == 0) { ExecuteBuffTick(buffObj); buffObj.tickCnt += 1; } } //检测移除 if (buffObj.duration <= 0 || buffObj.stack <= 0) { ExecuteBuffRemove(buffObj); skillCom.RemoveBuff(buffObj); } } }
/// <summary> /// 执行函数 /// </summary> /// <param name="buff">buff对象</param> /// <param name="damageInfo">伤害信息</param> /// <param name="attacker">攻击者</param> public abstract void Execute(BuffObj buff, AddDamageInfo damageInfo, SkillCom attacker);
/// <summary> /// 执行函数 /// </summary> /// <param name="buff">Buff对象</param> /// <param name="damageInfo">伤害信息</param> /// <param name="target">被击杀目标</param> public abstract void Execute(BuffObj buff, AddDamageInfo damageInfo, SkillCom target);
/// <summary> /// 执行函数 /// </summary> /// <param name="buff">Buff对象</param> /// <param name="modifyStack">改变的层数</param> public abstract void Execute(BuffObj buff, int modifyStack = 0);
/// <summary> /// 执行函数 /// </summary> /// <param name="buff">buff对象</param> /// <param name="skill">技能对象</param> /// <param name="timeline">技能表现</param> public abstract TimelineObj Execute(BuffObj buff, SkillObj skill, TimelineObj timeline);
public override void Execute(BuffObj buff, int modifyStack = 0) { SkillLocate.Skill.CreateBullet(buff.ower, addBullet); }