public static PointOfInterrest GetByName(string name) { IEnumerable <PointOfInterrest> applicablePoints = points.Where(p => p.description == name); PointOfInterrest point = applicablePoints.FirstOrDefault(); if (point == null) { Debug.LogWarning("point of interrest " + name + "coudn't be found"); } return(point); }
void Start() { appointments.Add( new Appointment( TimeManager.worldTime.HourMinuteToTime(9, 10), "confess", player, confession)); appointments.Add(new Appointment( TimeManager.worldTime.HourMinuteToTime(9, 20), "dance" , () => PointOfInterrest.GetClosestByName("Well", transform.position).transform)); OnPositionChange += UpdateDistance; if (appointments.GetNext().conversationPartner != null) { appointments.GetNext().conversationPartner.OnPositionChange += UpdateDistance; } UpdateDistance(transform.position); }
public static PointOfInterrest GetClosestByName(string name, Vector3 position) { IEnumerable <PointOfInterrest> applicablePoints = points.Where(p => p.description == name); PointOfInterrest closest = null; float closestSqrDistance = float.PositiveInfinity; foreach (PointOfInterrest p in applicablePoints) { float sqrDist = Vector3.SqrMagnitude(p.transform.position - position); if (sqrDist < closestSqrDistance) { closest = p; closestSqrDistance = sqrDist; } } return(closest); }