Example #1
0
        public void CartCheckout()
        {
            var FuncByType = new Dictionary <Type, Action <AbstractItem> > {
                { typeof(HeadItem), (ab) => hats.ItemUpdate((HeadItem)ab) },
                { typeof(BackItem), (ab) => bags.ItemUpdate((BackItem)ab) },
                { typeof(PrimaryWeapon), (ab) => primaryWeapons.ItemUpdate((PrimaryWeapon)ab) },
                { typeof(SecondaryWeapon), (ab) => secondaryWeapons.ItemUpdate((SecondaryWeapon)ab) }
            };

            List <AbstractItem> cart = new List <AbstractItem>();

            foreach (var item in shoppingCart)
            {
                AbstractItem it = item.Value;
                cart.Add(it);
                it.CurrentAmout--;
                if (FuncByType.ContainsKey(it.GetType()))
                {
                    FuncByType[it.GetType()].Invoke(it);
                }
                if (it.CurrentAmout == 0)
                {
                    OutOfStockEventHandler?.Invoke(this, it);
                }
            }
            CartItems.Add(new ShoppingCartItems(cart));
            shoppingCart.Clear();
        }
Example #2
0
 protected virtual Target BuildTarget(AbstractItem item)
 {
     if (item is MeasuresXml || item is MeasureXml)
     {
         return(Target.Measures);
     }
     if (item is MeasureGroupsXml || item is MeasureGroupXml)
     {
         return(Target.MeasureGroups);
     }
     if (item is ColumnsXml || item is ColumnXml)
     {
         return(Target.Columns);
     }
     if (item is TablesXml || item is TableXml)
     {
         return(Target.Tables);
     }
     if (item is PropertiesXml || item is PropertyXml)
     {
         return(Target.Properties);
     }
     if (item is LevelsXml || item is LevelXml)
     {
         return(Target.Levels);
     }
     if (item is HierarchiesXml || item is HierarchyXml)
     {
         return(Target.Hierarchies);
     }
     if (item is DimensionsXml || item is DimensionXml)
     {
         return(Target.Dimensions);
     }
     if (item is SetsXml || item is SetXml)
     {
         return(Target.Sets);
     }
     if (item is RoutineParametersXml || item is RoutineParameterXml)
     {
         return(Target.Parameters);
     }
     if (item is RoutinesXml || item is RoutineXml)
     {
         return(Target.Routines);
     }
     if (item is PerspectivesXml || item is PerspectiveXml)
     {
         return(Target.Perspectives);
     }
     else
     {
         throw new ArgumentException(item.GetType().Name);
     }
 }
Example #3
0
        /// <summary>
        /// When occurs one of the items is out of stock,User can't see this item anymore
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Service_OutOfStockEventHandler(object sender, AbstractItem e)
        {
            var FuncByType = new Dictionary <Type, Action <AbstractItem> > {
                { typeof(HeadItem), ai => (ShopListLv.Items[3] as ComboBox).ItemsSource = service.GetItems <HeadItem>().Where(x => x.CurrentAmout > 0) },
                { typeof(BackItem), ai => (ShopListLv.Items[2] as ComboBox).ItemsSource = service.GetItems <BackItem>().Where(x => x.CurrentAmout > 0) },
                { typeof(PrimaryWeapon), ai => (ShopListLv.Items[0] as ComboBox).ItemsSource = service.GetItems <PrimaryWeapon>().Where(x => x.CurrentAmout > 0) },
                { typeof(SecondaryWeapon), ai => (ShopListLv.Items[1] as ComboBox).ItemsSource = service.GetItems <SecondaryWeapon>().Where(x => x.CurrentAmout > 0) }
            };

            FuncByType[e.GetType()]?.Invoke(e);
        }
Example #4
0
 protected override Target BuildTarget(AbstractItem item)
 {
     if (item is MeasureGroupXml)
     {
         return(Target.Dimensions);
     }
     if (item is DimensionXml)
     {
         return(Target.MeasureGroups);
     }
     else
     {
         throw new ArgumentException(item.GetType().Name);
     }
 }
Example #5
0
        protected virtual Target BuildTarget(AbstractItem item)
        {
            if (item is MeasureXml)
            {
                return(Target.Measures);
            }
            if (item is ColumnXml)
            {
                return(Target.Columns);
            }
            if (item is PropertyXml)
            {
                return(Target.Properties);
            }

            throw new ArgumentException(item.GetType().Name);
        }
Example #6
0
 //add item to cart
 public void AddToCart(AbstractItem item)
 {
     shoppingCart[item.GetType()] = item;
 }
Example #7
0
        private void OnItemCollected(AbstractItem item, Player collectedBy)
        {
            // Check what was collected
            Console.WriteLine("Found item of type:" + item.GetType());
            if (item is GunItem)
            {
                EvolutionManager.Instance.HasGun = true;
                // Update the player
                EvolutionManager.Instance.SetupPlayer(player);
                player.LoadContent();

            }
            else if (item is LegsItem)
            {
                // Set legs to true
                EvolutionManager.Instance.HasLegs = true;
                // Update the player
                EvolutionManager.Instance.SetupPlayer(player);
                player.LoadContent();
            }

            item.OnCollected(collectedBy);
        }