/// <summary> /// Clears the Current map's Lists from memory, Loads New TiledMap into memory, /// positions and faces the Player accordingly, snaps the MapCamera into place, /// then signals the MapTransition object to continue it's transition /// </summary> private void UnloadMap() { MapObjects.Clear(); CollisionObjects.Clear(); Areas.Clear(); AdjacentMaps.Clear(); LoadMap("maps/" + MapTransition.DestinationMapName); MainPlayer.SetPosition(MapTransition.DestinationPosition); MainPlayer.SetFacing(MapTransition.DestinationFacing); SetAreaBoundaries(MapTransition.DestinationAreaName); MapCamera.Position = MainPlayer.Position - new Vector2(MapCamera.BoundingRectangle.Width / 2, MapCamera.BoundingRectangle.Height / 2); UpdateCameraPosition(ActiveArea); MapTransition.MapChangeComplete((Rectangle)MapCamera.BoundingRectangle); }
/// <summary> /// Cleans the dynamic map up for players. [Teleports them to lastmap] /// </summary> public void Cleanup() { foreach (IMapObject MapObject in MapObjects.Values) { try { MapObject.DynamicMap = null; if (MapObject is Entities.GameClient) { if (!(MapObject as Entities.GameClient).LeaveDynamicMap()) { (MapObject as Entities.GameClient).NetworkClient.Disconnect("Failed to teleport out of dynamic map."); } } } catch { } } MapObjects.Clear(); Core.Kernel.DynamicMaps.TryRemove(DynamicID); }
private void SortTranslucents() { var opaques = new List <MapObject>(); var translucents = new List <MapObject>(); foreach (MapObject mo in MapObjects) { bool translucent = mo.UpdateTranslucency(Textures.Translucents); if (translucent) { translucents.Add(mo); } else { opaques.Add(mo); } } MapObjects.Clear(); MapObjects.AddRange(opaques); MapObjects.AddRange(translucents); }
public void Clear() { MapObjects.Clear(); }