public override bool Update(float dt) { if (Movement.Update(dt)) { //普攻伤害 if (damage > 0) { if (isAttack) { Target.removeExpectedDamage(damage); } Target.LostHP(damage, Shooter, damageType, isAttack); } //给目标上buff if (buffs != null) { for (int i = 0; i < buffs.Length; ++i) { Target.AddBuff(buffs[i], Shooter); } } //AOE if (aoeRadius > 0) { AoeRegion region = new CircleRegion(BattleInterface.Instance.world, position.x, position.y, aoeRadius); AoeField aoe = new AoeField(Shooter, region, duration, interval, emitters); BattleInterface.Instance.AddAoeField(aoe); } return(true); } return(false); }
public override bool Update(float dt) { float x = position.x; float y = position.y; if (Movement.Update(dt)) { //AOE if (aoeRadius > 0) { AoeRegion region = new CircleRegion(BattleInterface.Instance.world, position.x, position.y, aoeRadius); AoeField aoe = new AoeField(Shooter, region, duration, interval, emitters); BattleInterface.Instance.AddAoeField(aoe); } return(true); } else { var shift = speed * dt; BattleInterface.Instance.world.SelectRect(x, y, Movement.shift.x, Movement.shift.y, this.radius * 2, shift, res, (obj) => obj.CampID != Shooter.CampID); if (res.Count > 0) { UnitBase unit = null; float sqr_dis = 0; for (int i = 0; i < res.Count; ++i) { float dx = res[i].position.x - x; float dy = res[i].position.y - y; var _sqr_dis = dx * dx + dy * dy; if (unit == null || _sqr_dis < sqr_dis) { unit = res[i]; sqr_dis = _sqr_dis; } } //普攻伤害 if (damage > 0) { unit.LostHP(damage, Shooter, damageType, isAttack); } //给目标上buff if (buffs != null) { for (int i = 0; i < buffs.Length; ++i) { unit.AddBuff(buffs[i], Shooter); } } //AOE if (aoeRadius > 0) { AoeRegion region = new CircleRegion(BattleInterface.Instance.world, position.x, position.y, aoeRadius); AoeField aoe = new AoeField(Shooter, region, duration, interval, emitters); BattleInterface.Instance.AddAoeField(aoe); } return(true); } } return(false); }