public void AddTile(TileGraphic tile) { if (_tiles.Any(t => t.XPos == tile.XPos && t.YPos == tile.YPos)) { //Remove the old one var oldTile = _tiles.FirstOrDefault(t => t.XPos == tile.XPos && t.YPos == tile.YPos); _tiles.Remove(oldTile); } _tiles.Add(tile); }
public void Update(double gameTime) { _mouseState = Mouse.GetState(); if (_mouseState.LeftButton == ButtonState.Pressed && _managerCamera.MouseInsideWindow()) { var x = (int)(_managerCamera.Position.X + _mouseState.X)/16; var y = (int)(_managerCamera.Position.Y + _mouseState.Y)/16; //Just for test if (_mainForm.CurrentLayer == CurrentLayer.LayerOne) { foreach (var tilePoint in _mainForm.TilePoints) { var realX = x + (_mainForm.TilePoints[0].X - tilePoint.X)*-1; var realY = y + (_mainForm.TilePoints[0].Y - tilePoint.Y)*-1; var tile = new TileGraphic { ManagerCamera = _managerCamera, XPos = (int)realX, YPos = (int)realY, AnimationSpeed = 0, TextureName = "overworld_tiles", TileFrames = new List<TileFrame> { new TileFrame { TextureXPos = (int)tilePoint.X, TextureYPos = (int)tilePoint.Y } }, ZPos = 0 }; tile.LoadContent(); _tiles.AddTile(tile); } } else { var tileCollision = new TileCollision(true) { ManagerCamera = _managerCamera, XPos = x, YPos = y }; _tiles.AddCollisionTile(tileCollision); } } }