Exemplo n.º 1
0
 public void UpdateItemsInMenu(ISaleable _item)
 {
     foreach (IItemsMenu _itemsMenu in InventoryPanel.AllItemsMenu)
     {
         _itemsMenu.UpdateItems(_item);
     }
 }
Exemplo n.º 2
0
 public void Setup(ISaleable _item)
 {
     Item                = _item;
     IconImage.sprite    = _item.Icon;
     NameTxt.text        = _item.Name;
     DescriptionTxt.text = _item.Description();
 }
        private ISaleable SaleItem(string id, string purchaseDate)
        {
            string[] splitDate = purchaseDate.Split('-');
            DateTime saleDate  = new DateTime(int.Parse(splitDate[2]), int.Parse(splitDate[1]), int.Parse(splitDate[0]));

            ISaleable sale = null;

            foreach (KeyValuePair <IItem, int> item in supplies)
            {
                if (item.Key.ID == id)
                {
                    if (item.Value > 0)
                    {
                        supplies[item.Key] = supplies[item.Key] - 1;
                        sale = new Sale(item.Key, saleDate);
                    }
                    else
                    {
                        throw new InsufficientSuppliesException("Item is not in supply");
                    }
                    break;
                }
            }

            return(sale);
        }
Exemplo n.º 4
0
 public void SetupButtonData(ShopBase _shop, ISaleable _item, MyBuyButton3D _buyButton)
 {
     m_shop        = _shop;
     Item          = _item;
     myBuyButton3D = _buyButton;
     ActionsSub();
     DelegatesSub();
     SetOnClickAction();
 }
Exemplo n.º 5
0
 public void Setup(ISaleable _item, ShopBase _shop)
 {
     Item                = _item;
     IconImage.sprite    = _item.Icon;
     NameTxt.text        = _item.Name;
     DescriptionTxt.text = _item.Description();
     PriceTxt.text       = _item.Price.ToString();
     BuyButtonData.GetComponent <MyBuyButton3DData>().SetupButtonData(_shop, _item, BuyButton);
 }
        public static ISaleable <T> OfCurrency <T>(this ISaleable <T> entity, Currency currency)
            where T : ISaleablePrice
        {
            if (entity.Prices.Count > 0)
            {
                entity.Price = entity.Prices.FirstOrDefault(x => x.Currency.Key == currency.Key) ??
                               entity.Prices.FirstOrDefault(x => x.Currency.Key == Currency.Default.Key);
            }

            return(entity);
        }
        private void ExtractSupplyInformation(string command)
        {
            string[] splitCommand = command.Split(' ');
            if (splitCommand[0] == "supply")
            {
                IItem createdItem = CreateSuppliedItem(splitCommand[1], splitCommand[3]);
                ShopEngine.supplies.Add(createdItem, int.Parse(splitCommand[2]));
            }
            else if (splitCommand[0] == "sell")
            {
                ISaleable newSale = SaleItem(splitCommand[1], splitCommand[2]);
                Sale.AddSale(newSale);
            }
            else if (splitCommand[0] == "rent")
            {
                IRentable newRent = RentItem(splitCommand[1], splitCommand[2], splitCommand[3]);
                Rent.AddRent(newRent);
            }
            else if (splitCommand[0] == "report")
            {
                if (splitCommand[1] == "rents")
                {
                    var rents = Rent.Rents
                                .Where(rent => rent.RentState == RentStatus.Overdue)
                                .OrderBy(rent => rent.RentFine)
                                .ThenBy(rent => rent.Item.Title);
                    foreach (var report in rents)
                    {
                        Console.WriteLine(report);
                    }
                }
                else if (splitCommand[1] == "sales")
                {
                    string[] splitData    = splitCommand[2].Split('-');
                    DateTime lastSaleDate = new DateTime(int.Parse(splitData[2]), int.Parse(splitData[1]), int.Parse(splitData[0]));
                    decimal  sum          = Sale.Sales
                                            .Where(sale => sale.SaleDate >= lastSaleDate)
                                            .Sum(sale => sale.Item.Price);

                    Console.WriteLine("{0:N2}", sum);
                }
            }
        }
Exemplo n.º 8
0
        public void UpdateItems(ISaleable _item)
        {
            m_items.Clear();
            switch (MenuItemsType)
            {
            case ItemsType.MotorBikes:
                if (_item is BikesConfigData)
                {
                    GameObject            _newItemInfo = Instantiate(ItemPrefab, Content.transform);
                    ItemInventoryInfoData InfoData     = _newItemInfo.GetComponent <ItemInventoryInfoData>();
                    InfoData.Setup(_item);
                    m_items.Add(_newItemInfo.GetComponent <ISaleable>());
                }
                break;

            case ItemsType.Clothes:
                if (_item is ClothesConfigData)
                {
                    GameObject            _newItemInfo = Instantiate(ItemPrefab, Content.transform);
                    ItemInventoryInfoData InfoData     = _newItemInfo.GetComponent <ItemInventoryInfoData>();
                    InfoData.Setup(_item);
                    m_items.Add(_newItemInfo.GetComponent <ISaleable>());
                }
                break;

            case ItemsType.Cigarettes:
                if (_item is CigarettesConfigData)
                {
                    GameObject            _newItemInfo = Instantiate(ItemPrefab, Content.transform);
                    ItemInventoryInfoData InfoData     = _newItemInfo.GetComponent <ItemInventoryInfoData>();
                    InfoData.Setup(_item);
                    m_items.Add(_newItemInfo.GetComponent <ISaleable>());
                }
                break;

            case ItemsType.Gasha:
                break;

            default:
                break;
            }
        }
Exemplo n.º 9
0
 public void Buy(ISaleable item)
 {
     this.PurchasedItems.Add(item);
 }
Exemplo n.º 10
0
 public static void AddSaleableItem(ISaleable item)
 {
     PurchasedItems.Add(item);
 }
Exemplo n.º 11
0
 public void Buy(ISaleable item)
 {
     this.PurchasedItems.Add(item);
 }
 public static void AddSale(ISaleable sale)
 {
     Sale.sales.Add(sale);
 }
Exemplo n.º 13
0
 public static void AddSaleableItem(ISaleable item)
 {
     PurchasedItems.Add(item);
 }