Ejemplo n.º 1
0
        public static void ConfigureBusiness(Business bus)
        {
            switch (bus.SubType)
            {
            case BusinessType.Shop:
                if (bus.Interior > 0)
                {
                    bus.InteractionPoint = API.shared.createCylinderColShape(Business.InteriorInteractPos[bus.Interior], 1f, 1f);
                }
                break;

            case BusinessType.Mechanic:
                bus.InteractionPoint = API.shared.createCylinderColShape(bus.EnterPosition, 1f, 1f);
                break;
            }
            bus.BusinessItems = ShopItemRepository.GetShopItemsByBusinessId(bus.Id);
        }
Ejemplo n.º 2
0
        public static void ShopPaymentCash(Player p, Inventory inv)
        {
            if (p.ShoppingCart != null)
            {
                int total = p.ShoppingCart.Sum(sc => sc.Price * sc.Quantity);
                if (long.Parse(inv.Value) >= total)
                {
                    inv.Value = (long.Parse(inv.Value) - total).ToString();

                    foreach (ShopItem item in p.ShoppingCart)
                    {
                        for (int i = 0; i < item.Quantity; i++)
                        {
                            p.GiveInventoryItmeOfType(item.Type);
                        }

                        ShopItem shopItem = p.BusinessInteractingWith.BusinessItems.Single(bi => bi.Id == item.Id);
                        shopItem.ReservedStock -= item.Quantity;
                        shopItem.Quantity      -= item.Quantity;
                        ShopItemRepository.UpdateAsync(shopItem);
                    }
                    if (inv.Value == "0")
                    {
                        p.Inventory.Remove(inv);
                        InventoryRepository.RemoveInventoryItem(inv);
                    }
                    else
                    {
                        InventoryRepository.UpdateAsync(inv);
                    }
                }
                else
                {
                    API.shared.SendErrorNotification(p.Client, "Insufficient funds.");
                    API.shared.SendInfoNotification(p.Client, "Select new payment method:");
                    InventoryManager.UpdatePlayerInventory(p);
                }
            }
        }