public Point InventoryPosition(int slotId) { string slotID = "slot" + slotId; List <UIWidget> slots = guiReader.GetInventorySlotsUIWidgets(); foreach (UIWidget slot in slots) { if (slot.Id.Equals(slotID)) { return(ClientGuiHelper.GetRandomCenterPos(slot.Rect)); } } return(new Point(-1, -1)); }
public Point GetGroundPosition(Location location) { Rect gameMapRect = guiReader.GetGameMapRect(); Location center = player.Location(); int xDif = location.X - center.X; int yDif = location.Y - center.Y; if (isOutOFRange(xDif, yDif, location.Z, center.Z)) { return(new Point(-1, -1)); } Rect sqm = getSqmRect(xDif, yDif, gameMapRect); Rect sqmClient = convertRelativeToClient(sqm, gameMapRect); return(ClientGuiHelper.GetRandomCenterPos(sqmClient)); }
public Point GetInventoryPosition(int slot, int containerIndex) { //try scroll 10 times for (int i = 0; i < 10; i++) { //Console.WriteLine("Tries: " + (i + 1)); string containerId = "container" + containerIndex; UIWidget container = getContainerByID(containerId, guiReader.GetContainerUIWidgets()); if (container == null) { Console.WriteLine("Container with id: " + containerId + " not found"); return(new Point(-1, -1)); } List <UIWidget> slots = container.Childrens; UIWidget item = slots[slot]; int isVisible = slotIsVisible(item.Rect, container.Rect); Rect containerRect = container.Rect; //remove toolbar height for wheel containerRect.Top = containerRect.Top + 22; Point wheelPos = ClientGuiHelper.GetRandomCenterPos(container.Rect); if (isVisible == -1) { inputSender.SendScrollUp(wheelPos); Thread.Sleep(20); } else if (isVisible == 0) { return(ClientGuiHelper.GetRandomCenterPos(item.Rect)); } else if (isVisible == 1) { inputSender.SendScrollDown(wheelPos); Thread.Sleep(20); } } Console.WriteLine("Could not get the item slot"); return(new Point(-1, -1)); }