private void MouseMoveEntities(bool mouseDown) { EntityLayer entities = layers[currentLayer].Layer as EntityLayer; if (!mouseDown) { List <Entity> all = entities.GetEntitiesAt(mousePosition); hoveringEntity = null; for (int i = all.Count - 1; i >= 0; i--) { if (!all[i].Destroyed && all[i].Properties.GetInt("isTile", 0) == 0) { hoveringEntity = all[i]; break; } } } else { if (selectedEntity != null) { selectedEntity.Position = mousePosition + mouseOffset; selectedEntity.Integrate(0); } } }
public override void Update(float elapsed) { if (!selecting) { base.Update(elapsed); } else { previous = current; current = Mouse.GetState(); mousePosition = new Vector2(current.X, current.Y); } if (Hover == null) { //not hovering over anything if (current.LeftButton == ButtonState.Pressed && previous.LeftButton != ButtonState.Pressed) { if (Command == "Select") { ClearSelected(); List <Entity> entities = entityLayer.GetEntitiesAt(mousePosition); bool selected = false; for (int i = 0; i < entities.Count; i++) { if (AddSelected(entities[i])) { selected = true; break; } } if (!selected) { mouseDownPosition = mousePosition; selecting = true; } } else { InstructSelected(new MouseCommand(Command, mousePosition, entityLayer.GetEntityAt(mousePosition))); } } if (current.RightButton == ButtonState.Pressed && previous.RightButton != ButtonState.Pressed) { InstructSelected(new MouseCommand("Right", mousePosition, entityLayer.GetEntityAt(mousePosition))); } } if (selecting) { if (current.LeftButton != ButtonState.Pressed && previous.LeftButton == ButtonState.Pressed) { SelectAll(mouseDownPosition, mousePosition); selecting = false; } } }