public override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (ContentSelectable()) { if (e.Button == MouseButton.Left || e.Button == MouseButton.Right) { Vector2 mouse = GetLocalMousePosition(); int slotSize = GetContentWidth() / 5; mouse.X /= slotSize; mouse.Y /= slotSize; int itemIndex = (int)mouse.X + ((int)mouse.Y * 5); if (itemIndex >= 0 && itemIndex < _shopData.ShopItems.Count) { if (e.Button == MouseButton.Left) { ClientCommand command = new ClientCommand(ClientCommand.CommandType.BuyShopItem); command.SetParameter("ItemIndex", itemIndex); command.SetParameter("Count", 1); RpgClientConnection.Instance.AddClientCommand(command); } else if (e.Button == MouseButton.Right) { Vector2 mousePos = StateWindow.Instance.GetMousePosition(); ItemClickOptionsPanel.OptionType optionType = ItemClickOptionsPanel.OptionType.Buy; int itemID = _shopData.ShopItems[itemIndex].ItemID; ItemClickOptionsPanel optionPanel = new ItemClickOptionsPanel((int)mousePos.X, (int)mousePos.Y, optionType, itemIndex, itemID, -1, _gameState); GameState.Instance.AddControl(optionPanel); } } } } }
public override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (ContentSelectable()) { if (e.Button == MouseButton.Left || e.Button == MouseButton.Right) { Vector2 mouse = GetLocalMousePosition(); int width = (GetContentWidth() / 2) - 8; int slotSize = width / ItemsPerRow; Rectangle selectionRect = new Rectangle(4, 4, width, GetContentHeight() - 58); if (selectionRect.Contains((int)mouse.X, (int)mouse.Y)) { mouse.X -= 4; mouse.Y -= 4; mouse.X /= slotSize; mouse.Y /= slotSize; int itemIndex = (int)mouse.X + ((int)mouse.Y * ItemsPerRow); if (itemIndex >= 0 && itemIndex < this.TradeRequest.TradeOffer1.NumItems()) { if (e.Button == MouseButton.Left) { if (this.TradeRequest.TradeOffer1.GetItem(itemIndex) != null) { int removed = this.TradeRequest.TradeOffer1.RemoveItem(itemIndex, 1); if (removed > 0) { ClientCommand command = new ClientCommand(ClientCommand.CommandType.RemoveTradeItem); command.SetParameter("ItemIndex", itemIndex); command.SetParameter("Count", 1); RpgClientConnection.Instance.AddClientCommand(command); } } } else if (e.Button == MouseButton.Right) { Vector2 mousePos = StateWindow.Instance.GetMousePosition(); ItemClickOptionsPanel.OptionType optionType = ItemClickOptionsPanel.OptionType.RemoveTrade; int itemID = this.TradeRequest.TradeOffer1.GetItem(itemIndex).Item1; int max = this.TradeRequest.TradeOffer1.GetItem(itemIndex).Item2; ItemClickOptionsPanel optionPanel = new ItemClickOptionsPanel((int)mousePos.X, (int)mousePos.Y, optionType, itemIndex, itemID, max, _gameState); GameState.Instance.AddControl(optionPanel); } } } } } }
public override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (ContentSelectable()) { if (e.Button == MouseButton.Left || e.Button == MouseButton.Right) { ClientCommand command = null; Vector2 mouse = GetLocalMousePosition(); int slotSize = GetContentWidth() / 5; mouse.X /= slotSize; if (mouse.Y >= 30) { mouse.Y -= 30; mouse.Y /= slotSize; int itemIndex = (int)mouse.X + ((int)mouse.Y * 5); Tuple <int, int> itemInfo = MapComponent.Instance.GetLocalPlayerPacket().Data.GetInventoryItem(itemIndex); if (itemInfo != null) { if (e.Button == MouseButton.Left) { if (ShopPanel.Instance != null) { command = new ClientCommand(ClientCommand.CommandType.SellShopItem); command.SetParameter("Count", 1); } else if (TradePanel.Instance != null) { int added = TradePanel.Instance.TradeRequest.TradeOffer1.AddItem(itemInfo.Item1, 1); if (added > 0) { command = new ClientCommand(ClientCommand.CommandType.AddTradeItem); command.SetParameter("Count", 1); TradePanel.Instance.TradeRequest.TradeOffer1.Accepted = false; TradePanel.Instance.TradeRequest.TradeOffer2.Accepted = false; } } else if (BankPanel.Instance != null) { command = new ClientCommand(ClientCommand.CommandType.AddBankItem); command.SetParameter("Count", 1); } else if (WorkbenchPanel.Instance == null) { command = new ClientCommand(ClientCommand.CommandType.SelectItem); } } else if (e.Button == MouseButton.Right) { ItemClickOptionsPanel.OptionType optionType = ItemClickOptionsPanel.OptionType.None; if (ShopPanel.Instance != null) { optionType = ItemClickOptionsPanel.OptionType.Sell; } else if (TradePanel.Instance != null) { optionType = ItemClickOptionsPanel.OptionType.AddTrade; } else if (BankPanel.Instance != null) { optionType = ItemClickOptionsPanel.OptionType.AddBank; } else if ((WorkbenchPanel.Instance == null)) { optionType = ItemClickOptionsPanel.OptionType.Drop; } if (optionType != ItemClickOptionsPanel.OptionType.None) { Vector2 mousePos = StateWindow.Instance.GetMousePosition(); ItemClickOptionsPanel optionPanel = new ItemClickOptionsPanel((int)mousePos.X, (int)mousePos.Y, optionType, itemIndex, itemInfo.Item1, itemInfo.Item2, _gameState); GameState.Instance.AddControl(optionPanel); } } } if (command != null) { command.SetParameter("ItemIndex", itemIndex); RpgClientConnection.Instance.AddClientCommand(command); } } } } }