/// <summary> /// Attempt at loading dynamic textures based on an input name /// </summary> /// <param name="name"></param> /// <returns></returns> public LevelArt LoadTexture(string name, Vector2 location, bool physical) { LevelArt texture; console.Write("Attempting to Load Texture " + name); texture = new LevelArt(Game, location, @"LevelArt\" + name, physical); // textures.Add(name, texture); Art.Add(texture); console.Write("Texture Loaded."); return(texture); }
/// <summary> /// Completely clears out all level data. /// </summary> public void ClearLevel() { Art.Clear(); selectedArt = null; }
public override void Update(GameTime gameTime) { base.Update(gameTime); foreach (DynamicLevelObject dlo in DynamicObjects) { dlo.Update(); } if (editing) { //Save the level if (input.IsKeyPressed(this, Keys.S)) { } if (input.IsKeyPressed(this, Keys.L)) { LoadTexture("WallTest01", camera.MouseToWorld(), false); } Vector2 mousePos = camera.MouseToWorld(); //show the grid if (selectedArt != null && input.IsKeyDown(this, Keys.M)) { showGrid = true; } else { showGrid = false; } // Remove if Del is pressed if (selectedArt != null && input.IsKeyPressed(this, Keys.Delete)) { removeTexture(selectedArt); selectedArt = null; } //move the selected piece around if (selectedArt != null && input.IsMouseMoving() && input.IsKeyDown(this, Keys.M)) { selectedArt.EditorMove(selectionOffset, gridSize); console.Write(camera.MouseToWorld().ToString()); console.Write("Moving : " + selectedArt.WorldPosition.ToString()); } else if (selectedArt != null && input.IsMouseMoving() && input.IsKeyDown(this, Microsoft.Xna.Framework.Input.Keys.R)) { // Rotation if (mousePos.Y < previousY) { selectedArt.EditorRotate(selectionOffset, -0.1f); } else { selectedArt.EditorRotate(selectionOffset, 0.1f); } previousY = mousePos.Y; } else { foreach (LevelArt la in Art) { //check each level art for mouse collision and click if (la.BoundingBox.Contains(Convert.ToInt32(mousePos.X), Convert.ToInt32(mousePos.Y)) && input.IsMouseButtonPressed("left") && !la.CheckTrans(input.MousePosition - la.GetScreenPosition())) { //deselect the current selected levelart (if there was one) //before selecting the newly clicked piece if (selectedArt != null && selectedArt != la) { selectedArt.EditorSelect(false); } //tell the piece that it's been selected la.EditorSelect(true); selectedArt = la; if ((GUITexureManager)guimanager.GetComponent("texturemanager") != null) { ((GUIManager)Game.Services.GetService(typeof(IGUIManager))).RemoveComponent("texturemanager"); } EditorDisplayTextureInformation(); //calculate an offset based on where the mouse was when it was clicked //so we don't snap the level art origin to the mouse position selectionOffset = camera.MouseToWorld() - la.WorldPosition; } else if (input.IsKeyPressed(this, Microsoft.Xna.Framework.Input.Keys.D)) { // If nothing is selected, and the D key is pressed, deselect if (selectedArt != null) { selectedArt.EditorSelect(false); if ((GUITexureManager)guimanager.GetComponent("texturemanager") != null) { ((GUIManager)Game.Services.GetService(typeof(IGUIManager))).RemoveComponent("texturemanager"); } } selectedArt = null; } } } } }
/// <summary> /// Attempt at removing textures /// </summary> /// <param name="sprite"></param> public void removeTexture(LevelArt sprite) { Art.Remove(sprite); }
public void initTextureInformation(LevelArt levelArt) { Art = levelArt; }