Esempio n. 1
0
    /// <summary>
    /// Creates new store component and attach it to a target object
    /// </summary>
    /// <param name="target">Target object to attach store component to</param>
    /// <param name="storeCatalog"></param>
    /// <param name="storePanel"></param>
    /// <param name="storeItemPrefab"></param>
    /// <param name="categoryButtonPrefab"></param>
    /// <param name="storeCategoriesPanel"></param>
    /// <param name="storeGridPanel"></param>
    /// <returns></returns>
    public static Store CreateStoreComponent(GameObject target, StoreCatalog storeCatalog, GameObject storePanel, GameObject storeItemPrefab, GameObject categoryButtonPrefab, GameObject storeCategoriesPanel, GameObject storeGridPanel)
    {
        Store store = target.AddComponent <Store>();

        store.storeCatalog         = storeCatalog;
        store.storePanel           = storePanel;
        store.storeItemPrefab      = storeItemPrefab;
        store.categoryButtonPrefab = categoryButtonPrefab;
        store.storeCategoriesPanel = storeCategoriesPanel;
        store.storeGridPanel       = storeGridPanel;

        return(store);
    }
 public override void Load(Action <bool> callback)
 {
     StoreService.Instance.GetStickersStoreCatalog((Action <BackendResult <StoreCatalog, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
     {
         StoreCatalog resultData = result.ResultData;
         bool flag = result.ResultCode == ResultCode.Succeeded && resultData != null;
         if (flag)
         {
             List <StoreBanner> banners = resultData.banners;
             if (banners != null)
             {
                 this.Banners = banners.Select <StoreBanner, StoreBannerHeader>((Func <StoreBanner, StoreBannerHeader>)(banner => new StoreBannerHeader(banner))).ToList <StoreBannerHeader>();
             }
             this.NotifyPropertyChanged <List <StoreBannerHeader> >((System.Linq.Expressions.Expression <Func <List <StoreBannerHeader> > >)(() => this.Banners));
             this.NotifyPropertyChanged <Visibility>((System.Linq.Expressions.Expression <Func <Visibility> >)(() => this.BannersVisibility));
             this.NotifyPropertyChanged <bool>((System.Linq.Expressions.Expression <Func <bool> >)(() => this.IsSlideViewCycled));
             this._stickersPacks.Clear();
             List <StoreSection> sections = resultData.sections;
             if (sections != null)
             {
                 foreach (StoreSection storeSection in sections)
                 {
                     List <StockItem> stockItemList;
                     if (storeSection == null)
                     {
                         stockItemList = (List <StockItem>)null;
                     }
                     else
                     {
                         VKList <StockItem> stickers = storeSection.stickers;
                         stockItemList = stickers != null ? stickers.items : (List <StockItem>)null;
                     }
                     List <StockItem> source = stockItemList;
                     if (source != null)
                     {
                         this._stickersPacks.Add(source.Select <StockItem, StockItemHeader>((Func <StockItem, StockItemHeader>)(stockItem => new StockItemHeader(stockItem, false))).ToList <StockItemHeader>());
                     }
                 }
             }
             this.ReloadItems();
             StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)result.ResultData);
             AppGlobalStateManager.Current.GlobalState.NewStoreItemsCount = 0;
             EventAggregator.Current.Publish((object)new NewStoreItemsCountChangedEvent());
         }
         callback(flag);
     }))));
 }
Esempio n. 3
0
        private void ProfileArrangement()
        {
            _buyers   = new BuyerCatalog();
            _bringers = new BringerCatalog();
            _stores   = new StoreCatalog();

            _buyers.Create(new Buyer("Bob", "*****@*****.**", "38383260", "Kærlighedsvej 7777, Intetsted", "B0b", "Langelænder"));
            _buyers.Create(new Buyer("Eugene", "*****@*****.**", "34-237-957-362", "Austin Delaware street 802, Texas", "XXB1gD1ck69XX", "LoveuMom"));
            //_buyers.Create(new Buyer());

            _bringers.Create(new Bringer("Dillon", "*****@*****.**", "11111111111", 2.3d, new List <Order>(), "Do1l0r", "$$$$$$$$$$"));
            _bringers.Create(new Bringer("Raily", "*****@*****.**", "123456789", 5.0, new List <Order>(), "420BlazeIt", "ILikeBigBlocks&IJustCan'tLie"));
            //_bringers.Create(new Bringer());

            _stores.Create(new Store("Fætter BR", "*****@*****.**", "Your backyard", "18:00-7:00", 10 / 10, "BRBehindYou", "You'llNeverGuessThis"));
            _stores.Create(new Store("Fakta", "*****@*****.**", "Everywhere", "All the frigging time", 1.3d, "DetFakta", "Faktuelt"));
            //_stores.Create(new Store());
        }
Esempio n. 4
0
        static void Main()
        {
            StoreCatalog catalog = new StoreCatalog();

            do
            {
                CheckOut checkout = new CheckOut(new List <IOffer>()
                {
                    // assumption -- data will be retrieved from db/external source
                    // assumption -- each offer will go as separate dll & injected at runtime

                    new BuyAndGetManyOffer("Buy 2 Get 3 Apple TV offer", "Buy 2 Get 3 Apple TV offer", "atv", 2, 3)
                    , new BuyOneGetOtherOffer("Buy MacBook Pro get HDMI Adapter free", "Buy MacBook Pro get HDMI Adapter free", "mbp", "hdm")
                    , new FlatDiscountOffer("Buy 4 or more Nexus 9 and get discounted price of 499.99", "Buy 4 or more Nexus 9 and get discounted price of 499.99", "nx9", 4, 499.99)
                });

                Console.WriteLine("Please enter product name to buy ( nx9, mbp, atv, hdm)");
                Console.WriteLine("Press Enter to get total");
                bool cartEnd = false;
                while (!cartEnd)
                {
                    string str = Console.ReadLine();
                    if (string.IsNullOrEmpty(str))
                    {
                        cartEnd = true;
                    }
                    var product = catalog.Products.FirstOrDefault(x => x.SKU == str);
                    if (product != null)
                    {
                        checkout.Scan(product);
                    }
                    else if (!string.IsNullOrEmpty(str))
                    {
                        Console.WriteLine("--" + str + "-- not valid product");
                    }
                }

                Console.WriteLine("Actual Price =" + checkout.ActualPrice());
                Console.WriteLine("Discounted Price =" + checkout.Total());
                Console.WriteLine("\nESC to exit / any key to continue\n");
            }while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
Esempio n. 5
0
    // Start is called before the first frame update
    void Start()
    {
        gameManager      = GameManager.Instance;
        gameDataManager  = GameDataManager.Instance;
        homeStoreCatalog = Instantiate(homeStoreCatalog) as StoreCatalog;
        homeStoreCatalog.Init();
        // Create store (can be multiple) components
        homeStoreComponent = StoreComponentFactory.CreateStoreComponent(this.transform.gameObject, homeStoreCatalog, homeStorePanel, homeStoreItemPrefab, homeStoreCategoryButtonPrefab, homeStoreCategoriesPanel, homeStoreGridPanel);
        homeStoreComponent.OnInventoryItemClicked += HomeStoreItemClick;
        GameManager.OnStoreButtonPress            += homeStoreComponent.Toggle;

        gameDataManager.Money = gameManager.GameMode.money;
        gameDataManager.Mood  = gameManager.GameMode.mood;
        gameDataManager.Age   = gameManager.GameMode.age;

        foreach (ItemType type in Enum.GetValues(typeof(ItemType)))
        {
            //TODO: Add selectable items to list
        }

        Init();
    }
 public ViewMainDepartmentsInTheStore(StoreCatalog store_catalog, ResponseEngine viewer)
 {
     this.store_catalog = store_catalog;
     this.viewer = viewer;
 }
 public StoreCatalogController(StoreCatalog catalog)
 {
     this.catalog = catalog;
 }
Esempio n. 8
0
 public ViewTheProductsInADepartment(RenderingGateway rendering_gateway, StoreCatalog product_repository)
 {
     this.product_repository = product_repository;
     this.rendering_gateway  = rendering_gateway;
 }
Esempio n. 9
0
 public ViewTheDepartmentsInADepartment(RenderingGateway rendering_gateway,
                                        StoreCatalog department_repository)
 {
     this.rendering_gateway     = rendering_gateway;
     this.department_repository = department_repository;
 }
 public GetDepartmentsInDepartment(StoreCatalog catalog)
 {
     this.catalog = catalog;
 }
 public ViewTheMainDepartmentsInTheStore(StoreCatalog store_catalog, ResponseEngine response_engine)
 {
     this.store_catalog = store_catalog;
     this.response_engine = response_engine;
 }
 public ViewTheMainDepartmentsInTheStore(RenderingGateway rendering_gateway,
                                         StoreCatalog department_repository)
 {
     this.rendering_gateway = rendering_gateway;
     this.department_repository = department_repository;
 }
        public override void Load(Action <ResultCode> callback)
        {
            StoreService.Instance.GetStickersStoreCatalog(this._isChat ? 0L : this._userOrChatId, (Action <BackendResult <StoreCatalog, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                StoreCatalog resultData = result.ResultData;
                if ((result.ResultCode != ResultCode.Succeeded ? false : (resultData != null ? true : false)) != false)
                {
                    List <StoreBanner> banners = resultData.banners;
                    if (banners != null)
                    {
                        this.Banners = banners.Select <StoreBanner, StoreBannerHeader>((Func <StoreBanner, StoreBannerHeader>)(banner => new StoreBannerHeader(banner))).ToList <StoreBannerHeader>();
                    }
                    this.NotifyPropertyChanged <List <StoreBannerHeader> >(() => this.Banners);
                    this.NotifyPropertyChanged <Visibility>(() => this.BannersVisibility);
                    this.NotifyPropertyChanged <bool>(() => this.IsSlideViewCycled);
                    this._stickersPacks.Clear();
                    List <StoreSection> sections = resultData.sections;
                    if (sections != null)
                    {
                        foreach (StoreSection storeSection in sections)
                        {/*
                          * List<StockItem> stockItemList1;
                          * if (storeSection == null)
                          * {
                          *     stockItemList1 = null;
                          * }
                          * else
                          * {
                          *     VKList<StockItem> stickers = storeSection.stickers;
                          *     stockItemList1 = stickers != null ? stickers.items : null;
                          * }*/
                         //List<StockItem> stockItemList2 = stockItemList1;//todo:bug?

                            //
                            //  if (stockItemList2 != null)
                            //  {

                            List <StockItemHeader> stockItemHeaderList = new List <StockItemHeader>();
                            List <StockItem> stockItems = storeSection.stickers.items;
                            //List<StockItem> source = stockItems != null ? stockItems.items : null;
                            if (stockItems != null)
                            {
                                foreach (StockItem stockItem1 in stockItems)
                                {
                                    StockItemHeader stockItemHeader = new StockItemHeader(stockItem1, false, this._userOrChatId, this._isChat);
                                    stockItemHeaderList.Add(stockItemHeader);
                                    StoreProduct product = stockItemHeader.StockItem.product;
                                    //
                                    if (((IAccountStickersData)resultData).Products == null)
                                    {
                                        ((IAccountStickersData)resultData).Products = new VKList <StoreProduct>();
                                    }
                                    if (((IAccountStickersData)resultData).StockItems == null)
                                    {
                                        ((IAccountStickersData)resultData).StockItems = new VKList <StockItem>();
                                    }
                                    ((IAccountStickersData)resultData).Products.items.Add(product);
                                    ((IAccountStickersData)resultData).StockItems.items.Add(stockItem1);
                                    //
                                    if (product != null)
                                    {
                                        StockItem stockItem2 = stockItems.FirstOrDefault <StockItem>((Func <StockItem, bool>)(item =>
                                        {
                                            int?nullable = item.product != null ? new int?(item.product.id) : new int?();
                                            if (nullable.GetValueOrDefault() != product.id)
                                            {
                                                return(false);
                                            }
                                            return(nullable.HasValue);
                                        }));
                                        if (stockItem2 != null)
                                        {
                                            stockItemHeader.StockItem.CanPurchaseFor = stockItem2.CanPurchaseFor;
                                        }
                                    }
                                }
                            }
                            this._stickersPacks.Add(stockItemHeaderList);
                            //  }
                            //

                            /*
                             * if (stockItemList2 != null)
                             * {
                             *
                             *  List<StockItemHeader> stockItemHeaderList = new List<StockItemHeader>();
                             *  VKList<StockItem> stockItems = resultData.StockItems;
                             *  List<StockItem> source = stockItems != null ? stockItems.items : null;
                             *  if (source != null)
                             *  {
                             *      foreach (StockItem stockItem1 in stockItemList2)
                             *      {
                             *          StockItemHeader stockItemHeader = new StockItemHeader(stockItem1, false, this._userOrChatId, this._isChat);
                             *          stockItemHeaderList.Add(stockItemHeader);
                             *          StoreProduct product = stockItemHeader.StockItem.product;
                             *          if (product != null)
                             *          {
                             *              StockItem stockItem2 = source.FirstOrDefault<StockItem>((Func<StockItem, bool>)(item =>
                             *              {
                             *                  int? nullable = item.product != null ? new int?(item.product.id) : new int?();
                             *                  if (nullable.GetValueOrDefault() != product.id)
                             *                      return false;
                             *                  return nullable.HasValue;
                             *              }));
                             *              if (stockItem2 != null)
                             *                  stockItemHeader.StockItem.CanPurchaseFor = stockItem2.CanPurchaseFor;
                             *          }
                             *      }
                             *  }
                             *  this._stickersPacks.Add(stockItemHeaderList);
                             * }*/
                        }
                    }
                    this.ReloadItems();
                    StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)resultData);
                    AppGlobalStateManager.Current.GlobalState.NewStoreItemsCount = 0;
                    EventAggregator.Current.Publish(new NewStoreItemsCountChangedEvent());
                }
                callback(result.ResultCode);
            }))));
        }
 public ViewTheProductsIntheDepartment(ResponseEngine response_engine, StoreCatalog store_catalog)
 {
     this.response_engine = response_engine;
     this.store_catalog = store_catalog;
 }
 public ViewTheProductsInADepartment(RenderingGateway rendering_gateway, StoreCatalog product_repository)
 {
     this.product_repository = product_repository;
     this.rendering_gateway = rendering_gateway;
 }
 public ViewProductsInADepartment(StoreCatalog store_catalog, ResponseEngine viewer)
 {
     this.store_catalog = store_catalog;
     this.viewer = viewer;
 }
 public override void Load(Action <ResultCode> callback)
 {
     StoreService.Instance.GetStickersStoreCatalog(this._isChat ? 0L : this._userOrChatId, (Action <BackendResult <StoreCatalog, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
     {
         ResultCode resultCode = result.ResultCode;
         StoreCatalog resultData = result.ResultData;
         if ((resultCode != ResultCode.Succeeded ? 0 : (resultData != null ? 1 : 0)) != 0)
         {
             List <StoreBanner> banners = resultData.banners;
             if (banners != null)
             {
                 this.Banners = banners.Select <StoreBanner, StoreBannerHeader>((Func <StoreBanner, StoreBannerHeader>)(banner => new StoreBannerHeader(banner))).ToList <StoreBannerHeader>();
             }
             this.NotifyPropertyChanged <List <StoreBannerHeader> >(() => this.Banners);
             this.NotifyPropertyChanged <Visibility>(() => this.BannersVisibility);
             this.NotifyPropertyChanged <bool>(() => this.IsSlideViewCycled);
             this._stickersPacks.Clear();
             List <StoreSection> sections = resultData.sections;
             if (sections != null)
             {
                 foreach (StoreSection storeSection in sections)
                 {
                     List <StockItem> stockItemList1;
                     if (storeSection == null)
                     {
                         stockItemList1 = (List <StockItem>)null;
                     }
                     else
                     {
                         VKList <StockItem> stickers = storeSection.stickers;
                         stockItemList1 = stickers != null ? stickers.items : (List <StockItem>)null;
                     }
                     List <StockItem> stockItemList2 = stockItemList1;
                     if (stockItemList2 != null)
                     {
                         List <StockItemHeader> stockItemHeaderList = new List <StockItemHeader>();
                         VKList <StockItem> stockItems = resultData.StockItems;
                         List <StockItem> source = stockItems != null ? stockItems.items : (List <StockItem>)null;
                         if (source != null)
                         {
                             foreach (StockItem stockItem1 in stockItemList2)
                             {
                                 int num1 = 0;
                                 long userOrChatId = this._userOrChatId;
                                 int num2 = this._isChat ? 1 : 0;
                                 StockItemHeader stockItemHeader = new StockItemHeader(stockItem1, num1 != 0, userOrChatId, num2 != 0);
                                 stockItemHeaderList.Add(stockItemHeader);
                                 StoreProduct product = stockItemHeader.StockItem.product;
                                 if (product != null)
                                 {
                                     StockItem stockItem2 = source.FirstOrDefault <StockItem>((Func <StockItem, bool>)(item =>
                                     {
                                         StoreProduct product2 = item.product;
                                         int?nullable = product2 != null ? new int?(product2.id) : new int?();
                                         int id = product.id;
                                         if (nullable.GetValueOrDefault() != id)
                                         {
                                             return(false);
                                         }
                                         return(nullable.HasValue);
                                     }));
                                     if (stockItem2 != null)
                                     {
                                         stockItemHeader.StockItem.CanPurchaseFor = stockItem2.CanPurchaseFor;
                                     }
                                 }
                             }
                         }
                         this._stickersPacks.Add(stockItemHeaderList);
                     }
                 }
             }
             this.ReloadItems();
             StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)resultData);
             AppGlobalStateManager.Current.GlobalState.NewStoreItemsCount = 0;
             EventAggregator.Current.Publish((object)new NewStoreItemsCountChangedEvent());
         }
         callback(resultCode);
     }))));
 }