MoodSwingGame.MSMap.GetNearestVolunteerCenter C# (CSharp) Method

GetNearestVolunteerCenter() public method

Gets the nearest volunteer center with respect to a specific tile.
public GetNearestVolunteerCenter ( MS3DTile reference ) : MSVolunteerCenter
reference MS3DTile Tile used as a reference point to find the nearest volunteer center
return MSVolunteerCenter
        public MSVolunteerCenter GetNearestVolunteerCenter(MS3DTile reference)
        {
            float? minDist = null;
            MSVolunteerCenter center = null;
            foreach (MS3DTile tile in MapArray)
            {
                if (tile is MSVolunteerCenter)
                {
                    MSVolunteerCenter vc = tile as MSVolunteerCenter;
                    float distance = Vector3.Distance(vc.Position, reference.Position);
                    if (minDist == null || minDist > distance)
                    {
                        minDist = distance;
                        center = vc;
                    }
                }
            }
            return center;
        }

Same methods

MSMap::GetNearestVolunteerCenter ( Vector2 coord ) : MSVolunteerCenter

Usage Example

Example #1
0
 public void VolunteerCitizen(MSMap map)
 {
     MS3DTile bldg = map.GetRandomCitizenSource();
     MS3DTile center = map.GetNearestVolunteerCenter(bldg);
     Node path = map.GetPath(bldg.TileCoordinate, center.TileCoordinate);
     MSVolunteeringCitizen v = new MSVolunteeringCitizen(bldg.Position + MSUnit.UNITZ_POSITION, path, map, 0);
     units.Add(v);
 }
All Usage Examples Of MoodSwingGame.MSMap::GetNearestVolunteerCenter