public void Update(ToolMap toolmap, GameTime gameTime) { Tool selectedTool = toolmap.getSelected(); MouseState mouseState = Mouse.GetState(); int mousex = mouseState.X; int mousey = mouseState.Y; //if mouse is within the map, do mouse over... if ((mousex > 10 && mousex < totalmapsize + 10) && (mousey > 10 && mousey < totalmapsize + 10)) { double tempx = (mousex - 10) / pixelsperside; int tilex = (int)Math.Floor(tempx); double tempy = (mousey - 10) / pixelsperside; int tiley = (int)Math.Floor(tempy); if (mouseState.LeftButton == ButtonState.Pressed && selectedTool != null) { WorldTile selectedType = selectedTool.getType(); if (selectedType == WorldTile.PLAYER) { Tile cur = map[tilex][tiley]; if (cur.getType() != WorldTile.WALL) { if (playertile == null) playertile = new Tile(tilex, tiley, cur.getX(), cur.getY(), cur.getLength(), selectedTool); else { playerx = tilex; playery = tiley; playertile.setMapX(tilex); playertile.setMapY(tiley); } } } else if (selectedType == WorldTile.MONSTER) { Tile cur = map[tilex][tiley]; if (cur.getType() != WorldTile.WALL) { monstertiles.Add(new Tile(tilex, tiley, cur.getX(), cur.getY(), cur.getLength(), selectedTool)); } } else { if (selectedTool.getType() == WorldTile.SELECT) { //if (selectedtile != null && selectedtile != map[curxtilemin + tilex][curytilemin + tiley]) // selectedtile.setColor(Color.White); toolmap.setSelectedTile(map[curxtilemin + tilex][curytilemin + tiley]); //selectedtile.setColor(Color.DarkGray); } else { map[curxtilemin + tilex][curytilemin + tiley].applyTool(selectedTool, toolmap); } } } if (highlighted != null) highlighted.unhighlight(); highlighted = map[curxtilemin + tilex][curytilemin + tiley]; highlighted.highlight(); } }