public MainScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont) : base(game, spriteBatch) { int height = 20; uiComponent = new UIComponent_Toolbar(game, spriteBatch, spriteFont, new Rectangle(0, game.Window.ClientBounds.Height - height, game.Window.ClientBounds.Width, height)); mapComponent = new MapComponent(game, spriteBatch, spriteFont); Components.Add(uiComponent); }
public bool Save(MapComponent mapComponent) { if (saveButton.IsPressed && file.Length > 0) { if (overwriteCheckbox.IsChecked || !File.Exists(@"Content\saves\" + file + ".aStar")) { if (fileExists) File.Delete(@"Content\saves\" + file + ".aStar"); // Write data to file BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream fileStream; fileStream = new FileStream(@"Content\saves\" + file + ".aStar", FileMode.Create); binaryFormatter.Serialize(fileStream, mapComponent); fileStream.Close(); return true; } } return false; }