public static MapSimulator CreateMapSimulator(Board mapBoard) { if (mapBoard.MiniMap == null) { mapBoard.RegenerateMinimap(); } MapSimulator result = new MapSimulator(mapBoard); List <WzObject> usedProps = new List <WzObject>(); WzDirectory MapFile = Program.WzManager["map"]; WzDirectory tileDir = (WzDirectory)MapFile["Tile"]; GraphicsDevice device = result.DxDevice; foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) { result.mapObjects[tileObj.LayerNumber].Add(CreateMapItemFromProperty((WzImageProperty)tileObj.BaseInfo.ParentObject, tileObj.X, tileObj.Y, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false)); } foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds) { result.backgrounds.Add(CreateBackgroundFromProperty((WzImageProperty)background.BaseInfo.ParentObject, background.BaseX, background.BaseY, background.rx, background.ry, background.cx, background.cy, background.a, background.type, background.front, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, background.Flip)); } foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds) { result.backgrounds.Add(CreateBackgroundFromProperty((WzImageProperty)background.BaseInfo.ParentObject, background.BaseX, background.BaseY, background.rx, background.ry, background.cx, background.cy, background.a, background.type, background.front, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, background.Flip)); } foreach (WzObject obj in usedProps) { obj.MSTag = null; } usedProps.Clear(); GC.Collect(); GC.WaitForPendingFinalizers(); return(result); }
/// <summary> /// Create map simulator board /// </summary> /// <param name="mapBoard"></param> /// <param name="titleName"></param> /// <returns></returns> public static MapSimulator CreateAndShowMapSimulator(Board mapBoard, string titleName) { if (mapBoard.MiniMap == null) { mapBoard.RegenerateMinimap(); } MapSimulator mapSimulator = null; Thread thread = new Thread(() => { mapSimulator = new MapSimulator(mapBoard, titleName); mapSimulator.Run(); }); thread.Priority = ThreadPriority.Highest; thread.Start(); thread.Join(); return(mapSimulator); }
public static MapSimulator CreateMapSimulator(Board mapBoard) { if (mapBoard.MiniMap == null) mapBoard.RegenerateMinimap(); MapSimulator result = new MapSimulator(mapBoard); List<WzObject> usedProps = new List<WzObject>(); WzDirectory MapFile = Program.WzManager["map"]; WzDirectory tileDir = (WzDirectory)MapFile["Tile"]; GraphicsDevice device = result.DxDevice; foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) result.mapObjects[tileObj.LayerNumber].Add(CreateMapItemFromProperty((WzImageProperty)tileObj.BaseInfo.ParentObject, tileObj.X, tileObj.Y, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false)); foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds) result.backgrounds.Add(CreateBackgroundFromProperty((WzImageProperty)background.BaseInfo.ParentObject, background.BaseX, background.BaseY, background.rx, background.ry, background.cx, background.cy, background.a, background.type, background.front, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, background.Flip)); foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds) result.backgrounds.Add(CreateBackgroundFromProperty((WzImageProperty)background.BaseInfo.ParentObject, background.BaseX, background.BaseY, background.rx, background.ry, background.cx, background.cy, background.a, background.type, background.front, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, background.Flip)); foreach (WzObject obj in usedProps) obj.MSTag = null; usedProps.Clear(); GC.Collect(); GC.WaitForPendingFinalizers(); return result; }