/// <summary> /// Return a list of all selected facilities present in the hotel. /// </summary> /// <param name="facility">Facility type</param> /// <returns></returns> private List <HSegment> Select_Segment(FACILITIES facility) { List <HSegment> segments; switch (facility) { case FACILITIES.CINEMA: segments = (from entity in _myHotel._nodes where (entity.MySegment is Cinema) select entity.MySegment).ToList(); return(segments); case FACILITIES.FITNESS: segments = (from entity in _myHotel._nodes where (entity.MySegment is Fitness) select entity.MySegment).ToList(); return(segments); case FACILITIES.RESTAURANT: segments = (from entity in _myHotel._nodes where (entity.MySegment is Restaurant) select entity.MySegment).ToList(); return(segments); default: segments = new List <HSegment>(); return(segments); } }
/// <summary> /// Sets the path to the nearest facility on the given entities. /// </summary> /// <param name="unit">Moving entity</param> /// <param name="facility">Target Facility</param> private void Find_Facility(Entity unit, FACILITIES facility) { List <Node.DIRECTIONS> route = new List <Node.DIRECTIONS>(); List <HSegment> found_segs = Select_Segment(facility); foreach (HSegment item in found_segs) { List <Node.DIRECTIONS> temp_route = unit.MyNode.Pathfinding(unit.MyNode, item, Building.ID_List.Elevator); if (route.Count() == 0) { route = temp_route; } else if (temp_route.Count() < route.Count()) { route = temp_route; } } unit.Path = route; unit.Destination_reached(); }