public void Update(GameTime gameTime, MouseController mouse) { /*TODO: DO NOT ASSUME STARING POSITION IS 0,0 (IMAGINE POSSIBILITY OF OFFSET) */ int xTileOver = (int)(mouse.Position.X / Configuration.DefaultTileWidth); int yTileOver = (int)(mouse.Position.Y / Configuration.DefaultTileHeight); bool validXTile = xTileOver < TileXCount && xTileOver > -1; bool validYTile = yTileOver < TileYCount && yTileOver > -1; CurrentOver = null; if (validXTile && validYTile) { CurrentOver = Tiles[xTileOver, yTileOver]; } //Clear current Tile if (mouse.RightMouseAction == MouseAction.MouseDown) { if(CurrentOver != null) CurrentOver.Reset(); } //Draw selected Tile if(mouse.LeftMouseAction == MouseAction.MouseDown) { if (CurrentOver != null) { CurrentOver.SetTile(SpriteSheetManager.Instance.GetSelectedSpriteSheet()); } } }
public void Update(Vector2 camPosition) { MouseController mouse = MapManager.Instance.MouseObject; int xTileOver = (int)((mouse.Position.X - camPosition.X) / Configuration.DefaultTileWidth); int yTileOver = (int)((mouse.Position.Y - camPosition.Y) / Configuration.DefaultTileHeight); bool validXTile = xTileOver < TileXCount && xTileOver > -1; bool validYTile = yTileOver < TileYCount && yTileOver > -1; CurrentOver = null; if (validXTile && validYTile) { CurrentOver = Tiles[xTileOver, yTileOver]; } if (mouse.LeftMouseAction == MouseAction.MouseDown && validXTile && validYTile) { //set Selected Selected = Tiles[xTileOver, yTileOver]; } }
internal void Setup(ContentManager Content) { Texture = Content.Load<Texture2D>(ImageFile); ContentConfiguration.Instance.SaveGlobalTexture(Texture, ImageFile); TileXCount = Texture.Width / TileHeight; TileYCount = Texture.Height / TileWidth; Tiles = new Tile[TileXCount, TileYCount]; for(int x = 0; x < TileXCount; x++) { for (int y = 0; y < TileYCount; y++) { Tiles[x, y] = new Tile(x, y, TileWidth, TileHeight); } } }
/// <summary> /// Creates an empty map of tiles with the width and height of the current TileSet /// </summary> /// <returns></returns> private Tile[,] NewTileSet() { Tile[,] tileSet = new Tile[this.TileXCount, this.TileYCount]; for(int x = 0; x < TileXCount; x++) { for (int y = 0; y < TileYCount; y++) { tileSet[x, y] = new Tile(x, y,Configuration.DefaultTileWidth, Configuration.DefaultTileHeight); } } return tileSet; }
internal void SetTile(SpriteSheet spriteSheet) { if (spriteSheet != null) { connectedSheet = spriteSheet; this.SelectedTile = connectedSheet.SelectedTile(); this.type = SelectedTile.GetTileType(); } }
public void Reset() { this.type = TileType.Default; this.connectedSheet = null; this.SelectedTile = null; }