public bool Update(TiledMap map) { X = Mouse.GetState().X; Y = Mouse.GetState().Y; //Debug.WriteLine(X + ":" + Y); timer += TimeSpan.FromMilliseconds(1); for (int i = 0; i < map.Count; i++) { if (Collisions.pointInRectangle(X, Y, map[i].bounds.X, map[i].bounds.X + map[i].bounds.Width, map[i].bounds.Y, map[i].bounds.Y + map[i].bounds.Height)) { mousedTile = map[i]; mouseOverTile = true; //Debug.WriteLine("OverTile"); break; } else { mousedTile = null; mouseOverTile = false; } } return(HandleClick(map)); }
private bool HandleClick(TiledMap map) { if (mouseOverTile && timer.TotalMilliseconds > 10) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { if (mousedTile.id == 0) { mousedTile.ChangeTile(17); return(map.isPath()); } } else if (Mouse.GetState().RightButton == ButtonState.Pressed) { if (mousedTile.id == 17) { mousedTile.ChangeTile(0); } } timer = new TimeSpan(0); } return(false); }