public override void init() { NearEntity targ = Entity.Map.getNearestEntity(Entity, Entity.EBounds.Center); // Too close, run if (targ.Distance < MinDist) { targetX = (int)targ.Entity.Location.X; if (targetX > Entity.EBounds.Center.X) { targetX += ScreenManager.Rand.Next(MinDist - MaxDist) + MinDist; if (targetX > Entity.Map.Width) { targetX = Entity.Map.Width - MaxDist; } Entity.setXSpeedPerMs(0.05f); } else { targetX -= ScreenManager.Rand.Next(MinDist - MaxDist) + MinDist; if (targetX < 0) { targetX = MaxDist; } Entity.setXSpeedPerMs(-0.05f); } } }
public override void init() { target = Entity.Map.getNearestEntity(Entity, Entity.Bounds.Center); }