void HandleBuyItem(BuyItem packet) { // client expects count starting at 1, and we send vendorslot+1 to client already if (packet.Muid > 0) { --packet.Muid; } else { return; // cheating } switch (packet.ItemType) { case ItemVendorType.Item: Item bagItem = GetPlayer().GetItemByGuid(packet.ContainerGUID); byte bag = ItemConst.NullBag; if (bagItem != null && bagItem.IsBag()) { bag = bagItem.GetSlot(); } else if (packet.ContainerGUID == GetPlayer().GetGUID()) // The client sends the player guid when trying to store an item in the default backpack { bag = InventorySlots.Bag0; } GetPlayer().BuyItemFromVendorSlot(packet.VendorGUID, packet.Muid, packet.Item.ItemID, (byte)packet.Quantity, bag, (byte)packet.Slot); break; case ItemVendorType.Currency: GetPlayer().BuyCurrencyFromVendorSlot(packet.VendorGUID, packet.Muid, packet.Item.ItemID, (byte)packet.Quantity); break; default: Log.outDebug(LogFilter.Network, "WORLD: received wrong itemType {0} in HandleBuyItem", packet.ItemType); break; } }
public void CreateBuyOrders() { Dictionary <int, int> ordersToCreate = new Dictionary <int, int>(); marketGrid.Invoke((MethodInvoker) delegate { foreach (DataGridViewRow row in marketGrid.Rows) { try { if (Convert.ToBoolean(row.Cells["Market_Select"].Value) == true) { int typeId = (int)row.Cells["Market_TypeId"].Value; int volume = (int)row.Cells["Market_Volume"].Value; double price = (double)row.Cells["Market_BuyPrice"].Value; volume = volume / 2; volume = Math.Max(volume, 1); if (volume * price > 100000000) { volume = (int)(10000000.0 / price); } Logging.Log("OmniEveUI:CreateBuyOrders", "Adding type to create buy order for TypeId - " + typeId + " Volume - " + volume, Logging.Debug); BuyItem buyItem = new BuyItem(typeId, volume, true); buyItem.OnBuyItemFinished += OnBuyItemFinished; _omniEve.AddAction(buyItem); } } catch (Exception ex) { Logging.Log("OmniEveUI:SellItemsInHanger", "Exception [" + ex + "]", Logging.Debug); } } }); }
public ShopMaterialInterface(BuyItem buy, int x, int y, int width, int height, SpriteFont font, int cost, GraphicsDevice graphics, Material item, int windowWidth) { this.font = font; this.buy = buy; Cost = cost; Item = item; bgImg = new Texture2D(graphics, width, height); bgImg = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray); bgRect = new Rectangle(x, y, width, height); name = Language.Translate(Item.ToString().AddSpaces()); namePos = new Vector2(x + (width / 2 - (font.MeasureString(name).X / 2)), y + SPACING); itemImg = Utilities.GetImgOfMaterial(Item); itemRect = new Rectangle(0, 0, MATERIAL_SIZE, MATERIAL_SIZE); itemRect.X = x + (width / 2 - (itemRect.Width / 2)); itemRect.Y = (int)(namePos.Y + SPACING + font.MeasureString("A").Y); buyOnceButton = new MenuButton(Buy, Language.Translate("Buy") + " (" + cost.ToString() + "c)", 0, 0, true, font, graphics); buyOnceButton.X = x + (width / 2 - (buyOnceButton.Width / 2)); buyTenButton = new MenuButton(() => Buy(10), Language.Translate("Buy") + " 10 (" + (cost * 10).ToString() + "c)", 0, 0, true, font, graphics); buyTenButton.X = x + (width / 2 - (buyTenButton.Width / 2)); buyFiftyButton = new MenuButton(() => Buy(50), Language.Translate("Buy") + " 50 (" + (cost * 50).ToString() + "c)", 0, bgRect.Bottom - buyOnceButton.Height - EDGE_SPACING, true, font, graphics); buyTenButton.Y = buyFiftyButton.Y - buyTenButton.Height - SPACING; buyOnceButton.Y = buyTenButton.Y - buyOnceButton.Height - SPACING; }
public ActionResult AddQty(BuyItem buyitem) { return(RedirectToAction("AddItemToCart", new { ItemId = buyitem.Id, qty = buyitem.QtyToOrder })); }
public async Task Buy(BuyItem buyItem) { await _buyItemService.BuyItem(buyItem.Quantity, buyItem.Id); }
public static void DoShopping(int x, int y, Shop shop, BuyItem buyMethod, SellItem sellMethod) { #region Draw list of items ActionPanel.ClearArea(); var exitFlag = false; var current = 0; if (shop.DescriptionItems != null) foreach (var item in shop.DescriptionItems) { var caption = item.Split('\t')[0]; var text = item.Split('\t')[1]; shop.Add(new ShopItem(caption, 0, true, text, true)); } if (shop.HasQuit) { shop.Add(new ShopItem(ActionPanel.Common_Quit, 0, true, null, true)); } while (!shop[current].IsActive) current++; var oldPosition = current; var goodsX = x + 3; var goodsY = y + 2; var lastIndex = shop.Count - 1; var isBBC = shop.Type == ShopType.BBC; ZFrame.DrawFrame(x, y, new ZFrame.Options{ Caption = shop.Name, Width = shop.Header.Length+6, Height = lastIndex+4, FrameType = FrameType.Double}); ZOutput.Print(goodsX, y+1, shop.Header, Color.Cyan, Color.Black); for (var i = 0; i < shop.Count; i++) PrintItem(goodsX, goodsY + i, shop, shop[i], isBBC); ZOutput.Print(x + (shop.Header.Length+6-shop.Footer.Length)/2, goodsY+shop.Count+1, shop.Footer, Color.Red, Color.Black); #endregion while (!exitFlag) { var item = shop[current]; PrintItem(goodsX, goodsY + current, shop, item, isBBC, true); var key = ZInput.ReadKey(); switch (key) { case ConsoleKey.UpArrow : do { current = (current > 0) ? current - 1 : lastIndex; } while (!shop[current].IsActive); break; case ConsoleKey.DownArrow: do { current = (current < lastIndex) ? current + 1 : 0; } while (!shop[current].IsActive); break; case ConsoleKey.Enter : case ConsoleKey.PageUp : case ConsoleKey.RightArrow: case ConsoleKey.Add: case ConsoleKey.Insert: #region Buy Item if (item.Name == ActionPanel.Common_Quit) { exitFlag = true; break; } if (item.ItemObject is string) { EventLog.Print(item.ItemObject as string); break; } if (shop.Type != ShopType.BBC) { if (Player.Credits >= item.Price) { exitFlag = buyMethod(item) ? shop.ExitAfter : exitFlag; } else { EventLog.Print("Planet_NoMoneyToBuy"); } } else { buyMethod(item); } PlayerStats.Draw_PlayerStats(); break; #endregion case ConsoleKey.PageDown: case ConsoleKey.LeftArrow: case ConsoleKey.Subtract: case ConsoleKey.Delete: #region Sell Item if (item.Name == ActionPanel.Common_Quit) { exitFlag = true; break; } if (item.ItemObject is string) { EventLog.Print(item.ItemObject as string); break; } var result = (sellMethod != null) ? sellMethod(item) : buyMethod(item); exitFlag = result && shop.ExitAfter; PlayerStats.Draw_PlayerStats(); break; #endregion case ConsoleKey.Escape: case ConsoleKey.Backspace: exitFlag = true; break; case ConsoleKey.F1 : HelpInfo.Show(); break; case ConsoleKey.F5 : PlayerInfo.Show(); break; case ConsoleKey.F6 : GalaxyInfo.Show(); break; case ConsoleKey.F10 : ZFrontier.Quit_Game(); break; } while (!shop[current].IsActive) current = (current < lastIndex) ? current + 1 : 0; if (current != oldPosition) { PrintItem(goodsX, goodsY + oldPosition, shop, shop[oldPosition], isBBC); oldPosition = current; } } ActionPanel.ClearArea(); }
public BuyItem Add(BuyItem newItem) { newItem.Id = CreateId(); _buy.Add(newItem); return(newItem); }
public void OnBuyItem(int shopId, int itemId, int shopItemId) { BuyItem?.Invoke(Bot, shopId, itemId, shopItemId); }
public static void SendSlotbars(GameSession gameSession) { var player = gameSession.Player; var gameHandler = gameSession.Client; var counterValue = 0; var categories = new List <SlotbarCategoryModule>(); var slotbarItemsTest = new List <SlotbarQuickslotItem> { new SlotbarQuickslotItem(1, "ammunition_laser_ucb-100"), new SlotbarQuickslotItem(2, "ammunition_laser_rsb-75"), new SlotbarQuickslotItem(3, "ammunition_laser_mcb-50"), new SlotbarQuickslotItem(4, "ammunition_laser_ucb-100"), new SlotbarQuickslotItem(5, "ammunition_laser_sab-50"), new SlotbarQuickslotItem(6, "ammunition_mine_smb-01"), new SlotbarQuickslotItem(7, "equipment_extra_cpu_ish-01"), new SlotbarQuickslotItem(8, "ammunition_specialammo_emp-01"), }; var premium = new List <SlotbarQuickslotItem> { new SlotbarQuickslotItem(1, "drone_formation_f-3d-rg"), new SlotbarQuickslotItem(2, "drone_formation_f-10-cr"), new SlotbarQuickslotItem(3, "drone_formation_f-09-mo") }; var slotbars = new List <SlotbarQuickslotModule> { new SlotbarQuickslotModule("standardSlotBar", slotbarItemsTest, "50,85|0,40", "0", true), new SlotbarQuickslotModule("premiumSlotBar", premium, "50,85|0,80", "0", true) }; var items = new List <SlotbarCategoryItemModule>(); //LASERS var maxCounter = 1000; foreach (var itemId in ItemStorage.LaserIds) { var item = new LaserItem( itemId, counterValue, maxCounter ); try { item.CounterValue = player.Hangar.Configurations[player.CurrentConfig].Consumables[itemId].Amount; } catch (Exception) { item.CounterValue = 0; } item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("lasers", items)); //ROCKETS items = new List <SlotbarCategoryItemModule>(); maxCounter = 200; foreach (var itemId in ItemStorage.RocketIds) { var item = new RocketItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("rockets", items)); //ROCKET LAUNCHER items = new List <SlotbarCategoryItemModule>(); maxCounter = 200; foreach (var itemId in ItemStorage.RocketLauncherIds) { var item = new RocketLauncherItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("rocket_launchers", items)); //SPECIAL ITEMS items = new List <SlotbarCategoryItemModule>(); maxCounter = 100; foreach (var itemId in ItemStorage.SpecialItemsIds) { var item = new SpecialItem( itemId, counterValue, maxCounter ); try { item.CounterValue = player.Hangar.Configurations[player.CurrentConfig].Consumables[itemId].Amount; } catch (Exception) { item.CounterValue = 0; } item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("special_items", items)); //MINES items = new List <SlotbarCategoryItemModule>(); maxCounter = 100; foreach (var itemId in ItemStorage.MinesIds) { var item = new MineItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("mines", items)); //CPUS items = new List <SlotbarCategoryItemModule>(); maxCounter = 0; foreach (var itemId in ItemStorage.CpusIds) { //TODO } categories.Add(new SlotbarCategoryModule("cpus", items)); //BUY NOW items = new List <SlotbarCategoryItemModule>(); maxCounter = 0; foreach (var itemId in ItemStorage.BuyNowIds) { var item = new BuyItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("buy_now", items)); //TECH ITEMS items = new List <SlotbarCategoryItemModule>(); maxCounter = 0; foreach (var itemId in ItemStorage.TechIds) { var item = new TechItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("tech_items", items)); //SHIP ABILITIES items = new List <SlotbarCategoryItemModule>(); maxCounter = 0; foreach (var itemId in ItemStorage.ShipAbilitiesIds) { var item = new ShipAbilityItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("ship_abilities", items)); //DRONE FORMATION items = new List <SlotbarCategoryItemModule>(); maxCounter = 0; foreach (var itemId in ItemStorage.FormationIds) { var item = new FormationItem( itemId, counterValue, maxCounter ); item.Create(); items.Add(item.Object); player.SlotbarItems[item.ClickedId] = item; } categories.Add(new SlotbarCategoryModule("drone_formations", items)); gameHandler.Send(new SlotbarsCommand(categories, "50,85", slotbars).getBytes()); }
public void BuyItem(BuyItem rpc) { money -= rpc.item.price * rpc.amount; for (int i = 0; i < rpc.amount; i++) AddItem(rpc.item); var s = new Sync(RPCType.Others, "", "money"); s.signallerID = networkID; s.sender = userName; Sync(s); }
void Start() { instance = this; }
public BuyItem Add(BuyItem newItem) { throw new NotImplementedException(); }
public ActionResult moreInfo(int buyItemId) { BuyItem selectedItem = (from b in db.BuyItems where b.buyItemID == buyItemId select b).FirstOrDefault(); return(View(selectedItem)); }
private void PurchaseManager_OnPurchaseConsumable(PurchaseEventArgs args) { //MainMenuManager _menu = FindObjectOfType<MainMenuManager>(); int add = 0; BuyItem buyFunc = null; Info infoPanel = null; switch (args.purchasedProduct.definition.id) { case "money_0": Log.WriteLog($"Purchased {moneyAdd_0} money.", Log.LevelsOfLogs.INFO, "Purchaser"); add = moneyAdd_0; buyFunc = MoneyManager.AddMoney; //infoPanel = _menu.CoinsAddInfoPanel; break; case "money_1": Log.WriteLog($"Purchased {moneyAdd_1} money.", Log.LevelsOfLogs.INFO, "Purchaser"); add = moneyAdd_1; buyFunc = MoneyManager.AddMoney; //infoPanel = _menu.CoinsAddInfoPanel; break; case "money_2": Log.WriteLog($"Purchased {moneyAdd_2} money.", Log.LevelsOfLogs.INFO, "Purchaser"); add = moneyAdd_2; buyFunc = MoneyManager.AddMoney; //infoPanel = _menu.CoinsAddInfoPanel; break; case "gems_0": Log.WriteLog($"Purchased {gemsAdd_0} gems.", Log.LevelsOfLogs.INFO, "Purchaser"); add = gemsAdd_0; buyFunc = MoneyManager.AddGems; //infoPanel = _menu.GemsAddInfoPanel; break; case "gems_1": Log.WriteLog($"Purchased {gemsAdd_1} gems.", Log.LevelsOfLogs.INFO, "Purchaser"); add = gemsAdd_1; buyFunc = MoneyManager.AddGems; // infoPanel = _menu.GemsAddInfoPanel; break; case "gems_2": Log.WriteLog($"Purchased {gemsAdd_2} gems.", Log.LevelsOfLogs.INFO, "Purchaser"); add = gemsAdd_2; buyFunc = MoneyManager.AddGems; // infoPanel = _menu.GemsAddInfoPanel; break; case "support_0": Log.WriteLog("Supoort purching.", Log.LevelsOfLogs.INFO, "Purchaser"); add = moneyAdd_2; break; default: Log.WriteLog("You try to purche item that is not in list!", Log.LevelsOfLogs.ERROR, "Purchaser"); break; } buyFunc?.Invoke(add); infoPanel?.Invoke(add); }
public Shop(Texture2D arrowImg, int windowWidth, int windowHeight, GraphicsDevice graphics, List <Material> items, Dictionary <Material, int> costs, SpriteFont mediumFont, SpriteFont smallFont, BuyItem buy, List <CannonSettings> cannons, Dictionary <CannonSettings, int> cannonCosts, Action <CannonSettings, int> buyCannon, Action <CannonSettings> selectCannon, Dictionary <GiftType, int> giftCosts, Action <GiftType, int> buyGift, Texture2D materialIcon, Texture2D cannonIcon, Texture2D giftIcon) { this.windowWidth = windowWidth; this.windowHeight = windowHeight; this.buy = buy; this.selectCannon = selectCannon; mInfoHover = new MaterialInfoHover(Material.Stone, smallFont, graphics, windowWidth); cInfoHover = new CannonInfoHover(CannonSettings.NormalCannon, smallFont, graphics, windowWidth); nextButton = new MenuButton(NextPage, SPACING, 0, true, graphics, arrowImg); nextButton.X = windowWidth - nextButton.Width - SPACING; nextButton.Y = windowHeight - nextButton.Height - SPACING; prevButton = new MenuButton(PrevPage, SPACING, nextButton.Y, true, graphics, arrowImg); for (int i = 0; i < items.Count; i++) { materialInterfaces.Add(new ShopMaterialInterface(Buy, 0, 0, SHOPINT_WIDTH, SHOPINT_HEIGHT, mediumFont, costs[items[i]], graphics, items[i], windowWidth)); } UpdatePagesToInterfaces(); X_OFFSET = windowWidth / 2 - (((SHOPINT_WIDTH * ITEMS_PER_ROW) + (SPACING * (ITEMS_PER_ROW - 1))) / 2); cannonButton = new MenuButton(new System.Action(() => state = ShopState.Cannons), 0, 0, true, graphics, cannonIcon); cannonButton.X = windowWidth / 2 - cannonButton.Width / 2; cannonButton.Y = windowHeight - cannonButton.Height - SPACING; materialButton = new MenuButton(new System.Action(() => state = ShopState.Materials), 0, cannonButton.Y, true, graphics, materialIcon); materialButton.ImgWidth = cannonButton.ImgWidth; materialButton.ImgHeight = cannonButton.ImgHeight; materialButton.X = cannonButton.X - materialButton.Width - SPACING; giftsButton = new MenuButton(new System.Action(() => state = ShopState.Gifts), cannonButton.X + cannonButton.Width + SPACING, cannonButton.Y, true, graphics, giftIcon); for (int i = 0; i < cannons.Count; i++) { cannonInterfaces.Add(new ShopCannonInterface(cannons[i], mediumFont, cannonCosts[cannons[i]], buyCannon, SelectCannon, false, graphics, 0, 0, SHOPINT_WIDTH, SHOPINT_HEIGHT)); } foreach (KeyValuePair <GiftType, int> kv in giftCosts) { giftInterfaces.Add(new ShopGiftInterface(kv.Key, graphics, mediumFont, 0, 0, SHOPINT_WIDTH, SHOPINT_HEIGHT, kv.Value, buyGift)); } UpdateGiftPositions(); }