public WayPoint FindNearestPoint(Vector2 aPosition) { AntSorter <WayPoint> sorter = new AntSorter <WayPoint>(); WayPoint point; float dist; for (int i = 0, n = points.Count; i < n; i++) { point = points[i]; dist = AntMath.Distance(aPosition, point.position); if (dist <= linkRadius) { sorter.Add(point, dist); } } if (sorter.Count > 0) { sorter.Sort(AntSorterOrder.ASC); return(sorter[0]); } return(null); }
private void UpdateSorting(AntEmitter aEmitter) { if (!aEmitter.IsAllowSorting) { return; } IParticle particle; var actor = aEmitter.Actor.Preset.actor; switch (actor.sortingMode) { case ESortingMode.None: for (int i = 0, n = _particles.Count; i < n; i++) { particle = _particles[i]; if (particle != null) { if (particle.IsActive) { if (particle != null && particle.EffectID == aEmitter.ID) { particle.SortingLayer = actor.sortingLayer; particle.SortingOrder = actor.sortingOrder; } } else { _particles[i] = null; } } } break; case ESortingMode.OldestInFront: case ESortingMode.YoungestInFront: _sorter.Clear(); for (int i = 0, n = _particles.Count; i < n; i++) { particle = _particles[i]; if (particle != null) { if (particle.IsActive) { if (particle.EffectID == aEmitter.ID) { _sorter.Add(particle, particle.BirthTime); } } else { _particles[i] = null; } } } _sorter.Sort((actor.sortingMode == ESortingMode.OldestInFront) ? AntSorterOrder.DESC : AntSorterOrder.ASC ); for (int i = 0, n = _sorter.Count; i < n; i++) { _sorter[i].SortingLayer = actor.sortingLayer; _sorter[i].SortingOrder = actor.sortingOrder + i; } break; } }