public Attack getNearestAttack(Entity thisEntity, Point tPoint) { Attack nAttack = Attacks[0]; double dist = HMath.Distance(tPoint, thisEntity.Bounds.Center); foreach (Attack a in Attacks) { if (a.Owner == thisEntity) { continue; } double d = HMath.Distance(tPoint, a.Rectangle.Center); if (d < dist) { dist = d; nAttack = a; } } return(nAttack); }
public NearEntity getNearestEntity(Entity thisEntity, Point tPoint) { Entity nEntity = GScreen.Player; double dist = HMath.Distance(tPoint, nEntity.Bounds.Center); foreach (Entity e in Entities) { if (!e.Alive || e == thisEntity) { continue; } double d = HMath.Distance(tPoint, e.Bounds.Center); if (d < dist) { dist = d; nEntity = e; } } return(new NearEntity(nEntity, dist)); }