public virtual void Update(ContentManager Content, bool isActive) { switch (State) { case "Loading": break; case "Rendering": if (isActive) { hud.Update(ref leftTool, ref rightTool); // Updates tools via HUD //input.Update(ref planetLevel, ref planetChanged, ref layoutCam, Content, ref exit, ref State); render.Update(); } break; case "Transitional": throw new Exception("Oh god Jesus Christ Free"); //_gameStateManager.SetState(GameStates.testLevel); publicLevel = planetLevel; break; } }
/// <summary> /// Gets tile to change value of. /// </summary> /// <param name="spriteBatch">A spritebatch</param> /// <param name="mouse"></param> /// <param name="cameraPosition"></param> /// <param name="TileSize"></param> /// <param name="zoom"></param> /// <returns></returns> public Boolean setTileFromClick(SpriteBatch spriteBatch, int TileSize, Camera2D layoutCam, ref PlanetLevel level, int leftTool, int rightTool, bool hudUp) { if (MouseManager.LeftButtonDown || MouseManager.RightButtonDown) { int width = (int)(TileSize * layoutCam.Zoom), height = (int)(TileSize * layoutCam.Zoom); // Calculate size of tile. renderMouseLocation.X = MouseManager.CurrentPosition.X // Get X tile. + (int) Math.Floor(((layoutCam.Pos.X * layoutCam.Zoom) - spriteBatch.GraphicsDevice.Viewport.Width / 2)); renderMouseLocation.Y = MouseManager.CurrentPosition.Y // Get Y tile. + (int) Math.Floor(((layoutCam.Pos.Y * layoutCam.Zoom) - spriteBatch.GraphicsDevice.Viewport.Height / 2)); if (renderMouseLocation.X < 0 || renderMouseLocation.Y < 0) // If out of map { return(false); } if (renderMouseLocation.X >= level.PlanetMap.GetLength(0) * TileSize || // If out of map renderMouseLocation.Y >= level.PlanetMap.GetLength(1) * TileSize) { return(false); } var tileMouse = new Vector2( // Current Tile Selected, compensating for Zoom. (int)(Math.Floor((renderMouseLocation.X + (TileSize / 2) * layoutCam.Zoom) / (TileSize * layoutCam.Zoom))), (int)(Math.Floor((renderMouseLocation.Y + (TileSize / 2) * layoutCam.Zoom) / (TileSize * layoutCam.Zoom)))); if (tileMouse.X >= level.PlanetMap.GetLength(0)) // Check if out of map { return(false); } if (tileMouse.Y >= level.PlanetMap.GetLength(1)) // Check if out of map { return(false); } if (!hudUp) { /* * if (MouseManager.currentState.LeftButton == ButtonState.Pressed) // Set based on left tool * level.PlanetMap[(int)tileMouse.X, (int)tileMouse.Y].tileType = leftTool; * else if (MouseManager.RightButtonPressed) // Set based on right tool * level.PlanetMap[(int)tileMouse.X, (int)tileMouse.Y].tileType = rightTool; * */ } } return(true); }
public void LoadPlanetLevel( PlanetTypes planetType, IEnumerable <IEnumerable <Vector2> > islands, int height, int width, bool[] layoutArray) { level = new PlanetLevel(_spriteBatch, _textureManager, _physicsManager, planetType, islands, height, width, layoutArray); }
public TileEditorManager(ContentManager Content, PlanetLevel inputLevel, GameWindow gameWindow) { State = "Loading"; var baseSize = Content.Load <Texture2D>(@"Tileset/Earth/Tile_Earth_Wall"); this.baseSize = baseSize.Width; hud = new SelectionHUD(Content); layoutCam = new Camera2D(gameWindow); //input = new EditorInput(baseSize.Width); render = new RenderLevel(_textureManager); select = new SelectTile(this.baseSize); planetLevel = inputLevel; State = "Rendering"; }