private WorldButtonWrapper CreateWorldButton() { World world = new World(Game) { Enabled = false, Height = 752, Width = 1330, X = 0, Y = 0 }; Dictionary <ButtonState, Rectangle> sourceRectangles = new Dictionary <ButtonState, Rectangle> { [ButtonState.Normal] = new Rectangle(0, 0, 151, 152), [ButtonState.Hover] = new Rectangle(166, 0, 151, 152), [ButtonState.Pressed] = new Rectangle(332, 0, 151, 152), [ButtonState.Disabled] = new Rectangle(498, 0, 151, 152) }; WorldButtonWrapper worldButton = new WorldButtonWrapper(world) { LayerDepth = 0.42F, Texture = Game.Content.Load <Texture2D>("FantasyGameGUI\\WorldButton"), SourceRectangles = sourceRectangles }; return(worldButton); }
private void LoadLevels() { try { if (Directory.Exists(LevelDirectory)) { string[] fileName = Directory.GetFiles(LevelDirectory, '*' + LevelExtension); for (int i = 0; i < fileName.Length; i++) { GameObject[] gameObjects = FileHandler.ReadFromBinaryFile <GameObject[]>(fileName[i]); gameObjects.ToList().ForEach(o => o.LoadContent(Game)); WorldButtonWrapper worldButton = CreateWorldButton(); worldButton.Click += WorldButton_Click; worldButton.World.Items = gameObjects.ToList(); _bottomToolbox.Add(worldButton); _worldButtons.Add(worldButton); } } } catch (Exception e) { Debug.WriteLine(e.Message); } }
private void AddButton_Click(object sender, EventArgs e) { WorldButtonWrapper worldButton = CreateWorldButton(); worldButton.Click += WorldButton_Click; _bottomToolbox.Add(worldButton); _worldButtons.Add(worldButton); }
private void DeleteButton_Click(object sender, EventArgs e) { if (_activeWorld != null) { WorldButtonWrapper worldButton = _worldButtons.Find(b => b.World == _activeWorld); _worldButtons.Remove(worldButton); _bottomToolbox.Remove(worldButton); _activeWorld = null; } }
private void WorldButton_Click(object sender, EventArgs e) { if (_activeWorld != null) { _activeWorld.Enabled = false; } WorldButtonWrapper worldButton = sender as WorldButtonWrapper; _activeWorld = worldButton.World; _activeWorld.Enabled = true; _activeWorld.ActiveLayerDepth = _activeLayerDepth; Camera.Position = Vector2.Zero; Camera.ViewportWidth = _activeWorld.Width; Camera.ViewportHeight = _activeWorld.Height; }