/// <summary> /// Constructor for the level editor /// </summary> public EditScreen(Game game, SpriteBatch spriteBatch) : base(game, spriteBatch) { screenManager = (ScreenManager)game.Services.GetService(typeof(ScreenManager)); this.spriteBatch = spriteBatch; brownTemplate = new DataTypes.TileData(0, 0, "Textures/brownBlock", DataTypes.CollisionType.Impassable); redTemplate = new DataTypes.TileData(0, 0, "Textures/redBlock", DataTypes.CollisionType.Impassable); greenTemplate = new DataTypes.TileData(0, 0, "Textures/greenBlock", DataTypes.CollisionType.Impassable); blueTemplate = new DataTypes.TileData(0, 0, "Textures/blueBlock", DataTypes.CollisionType.Impassable); tileTemplate = brownTemplate; tilemap = new List<DataTypes.TileData>(); }
/// <summary> /// Maps number keys to selection between the tile templates, and the 'S' key to requesting a save\ /// Escapes to start screen if espace key is pressed /// </summary> private void handleKey() { keyboardState = Keyboard.GetState(); if (CheckKey(Keys.D1)) { tileTemplate = brownTemplate; } if (CheckKey(Keys.D2)) { tileTemplate = redTemplate; } if (CheckKey(Keys.D3)) { tileTemplate = blueTemplate; } if (CheckKey(Keys.D4)) { tileTemplate = greenTemplate; } if (CheckKey(Keys.Back) || CheckKey(Keys.Delete)) { tilemap.Clear(); } if (CheckKey(Keys.S) && savingState == SavingState.NotSaving) { savingState = SavingState.ReadyToOpenStorageContainer; } if (CheckKey(Keys.Escape)) { this.Hide(); screenManager.activeScreen = screenManager.startScreen; screenManager.activeScreen.Show(); } oldKeyboardState = keyboardState; }