Exemple #1
0
 public ItemImage(Options options, string baseName, ItemGroup baseGroup)
 {
     _baseName = baseName;
     _baseGroup = baseGroup;
     Options = options;
     _defaultImage = LoadDefaultImage();
     LoadImage();
 }
Exemple #2
0
 protected ItemImage(ItemImage baseItemImage)
 {
     Options = baseItemImage.Options;
     _baseName = baseItemImage._baseName;
     _baseGroup = baseItemImage._baseGroup;
     _imageSource = baseItemImage._imageSource;
     _isDefaultImage = baseItemImage._isDefaultImage;
     _defaultImage = baseItemImage._defaultImage;
 }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public IItemHierarchy GetRoot() {
			if ( vRoot == null ) {
				var rootLevel = new ItemGroup(GetChildItems);

				vRoot = new ItemHierarchy();
				vRoot.Title = Title;
				vRoot.Build(rootLevel);
			}

			return vRoot;
		}
Exemple #4
0
        private void InitializeListBoxes()
        {
            listBoxAvailableItems.SelectedItem = null;
            listBoxIncludedItems.SelectedItem  = null;
            listBoxAvailableItems.Items.Clear();
            listBoxIncludedItems.Items.Clear();

            List <Item> items = ItemMaintenanceControl.ItemCache;

            if (_activeItem != null)
            {
                // Remove current item
                items.Remove(Item.FindById(items, _activeItem.Id));

                foreach (ItemGroup itemGroup in ItemGroup.GetAll(_activeItem.Id))
                {
                    bool      added, changed, removed;
                    ItemGroup current = GetItemGroup(itemGroup.Id,
                                                     out added, out changed, out removed);
                    if (removed)
                    {
                        continue;
                    }
                    Item item = Item.FindById(items, itemGroup.TargetItemId);
                    AddItemGroupToListBox(
                        (changed ? current : itemGroup), item);
                }
            }

            // Note: Added ones have an ItemId of zero so GetAll (above) will not find them
            foreach (ItemGroup itemGroup in _itemGroupsAdded)
            {
                Item item = Item.FindById(items, itemGroup.TargetItemId);
                AddItemGroupToListBox(itemGroup, item);
            }

            foreach (Item item in items)
            {
                if (ItemGroup.IsGroupMember(item.Id))
                {
                    continue;
                }
                listBoxAvailableItems.Items.Add(
                    new FormattedListBoxItem(item, item.FullName, true));
            }

            SetButtonsEnabled();
        }
        void CalculateRects(ItemGroup items, Vector2 position, Vector2 offset)
        {
            float maxWidth = minWidth, curHeight = 0;

            minHeight = GUI.skin.label.CalcSize(items.Get(0).content).y + 4;

            foreach (MenuItem item in items)
            {
                if (item.content.text == "Saparator")
                {
                    curHeight += 3;
                }
                else
                {
                    maxWidth   = Mathf.Max(maxWidth, GUI.skin.label.CalcSize(item.content).x + (item.Group ? GroupIconSize : 0) + 20);
                    curHeight += minHeight;
                }
            }
            bool right = (position.x + offset.x + maxWidth < boundingRect.xMax) ? true : false;
            bool down  = (position.y + offset.y + curHeight < boundingRect.yMax) ? true : false;

            items.position = new Rect(position + new Vector2((right) ? offset.x : -(offset.x + maxWidth), (down) ? -offset.y : (offset.y - curHeight)), new Vector2(maxWidth, curHeight));
            curHeight      = 0;

            foreach (MenuItem item in items)
            {
                if (item.content.text == "Saparator")
                {
                    item.position = new Rect(0, curHeight, maxWidth, 3);
                    curHeight    += 3;
                }
                else
                {
                    item.position = new Rect(0, curHeight, maxWidth, minHeight);

                    if (item.Group)
                    {
                        CalculateRects(item.subItems, items.position.position + item.position.center, item.position.size / 2);
                    }
                    curHeight += minHeight;
                }
            }

            if (curHeight != items.position.height)
            {
                throw new UnityException();
            }
        }
Exemple #6
0
        public override void OnSlotDragEnd(Slot originalSlot, Slot targetSlot, PointerEventData eventData)
        {
            base.OnSlotDragEnd(originalSlot, targetSlot, eventData);

            BagSlot originalBagSlot = (BagSlot)originalSlot;

            if (targetSlot != null && originalBagSlot.ItemGroup != null)
            {
                if (targetSlot.Manager == this) // 在同一SlotManager中拖拽
                {
                    BagSlot targetBagSlot = (BagSlot)targetSlot;
                    Bag.MoveItemGroup(originalBagSlot.Index, targetBagSlot.Index);
                }
                else if (targetSlot.Manager.Flag == SlotManagerFlag.ShopBagPanel) // 拖到商店的格子上
                {
                    BagSlot targetBagSlot = (BagSlot)targetSlot;

                    // 出售
                    BagPanel shopBagPanel = targetBagSlot.Manager;
                    Bag      shopBag      = shopBagPanel.Bag;

                    ItemGroup selling = Bag.RemoveItemGroup(originalBagSlot.Index);
                    selling.Count = shopBagPanel.Bag.AddItemGroup(targetBagSlot.Index, selling);

                    if (selling.Count > 0) // 没卖完
                    {
                        Bag.AddItemGroup(originalBagSlot.Index, selling);
                    }
                }
                else if (targetSlot.Manager.Flag == SlotManagerFlag.PlayerEquipmentsPanel) // 拖到装备槽上
                {
                    EquipmentSlot targetEquipmentSlot = (EquipmentSlot)targetSlot;
                    Character     character           = targetEquipmentSlot.Manager.Character;
                    Item          equipment           = originalBagSlot.ItemGroup.Item;
                    // 替换装备
                    Item replaceEquipment = targetEquipmentSlot.Item;

                    if (character.Equip(equipment, targetEquipmentSlot.EquipmentSlotType)) // 装备成功
                    {
                        Bag.RemoveItemGroup(originalBagSlot.Index);
                        if (replaceEquipment != null)
                        {
                            Bag.AddItem(originalBagSlot.Index, replaceEquipment, 1);
                        }
                    }
                }
            }
        }
Exemple #7
0
    public bool CanPutIn(ItemGroup putInItemGroup, out ItemGroup extraItemGroup)
    {
        bool canPutIn = isEmpty || myItemGroup.itemCount > 0 && myItemGroup.CompareTo(putInItemGroup) == 0;

        extraItemGroup = null;
        if (canPutIn && myItemGroup != null)
        {
            ItemBaseInfo putInItemInfo = putInItemGroup.itemInfo;
            int          extraCount    = putInItemGroup.itemCount + myItemGroup.itemCount - putInItemInfo.maxCountInGrid;
            if (extraCount > 0)
            {
                extraItemGroup = new ItemGroup(putInItemInfo, extraCount);
            }
        }
        return(canPutIn);
    }
        public async Task ShouldFindSuccessfully()
        {
            var itemGroup = new ItemGroup().Of(_token.TenantId);

            _server.Database.ItemGroups.Add(itemGroup);
            await _server.Database.SaveChangesAsync();

            var path     = $"/item-groups/{itemGroup.Id}";
            var response = await _client.GetAsync(path);

            var jsonResponse = await _client.ReadJsonAsync <ItemGroupJson>(response);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(itemGroup.Id, jsonResponse.Id);
            Assert.Equal(itemGroup.Title, jsonResponse.Title);
        }
        // GET: ItemGroups/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ItemGroup itemGroup = db.ItemGroups.Find(id);

            if (itemGroup == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CompanyID     = new SelectList(db.Companies, "ID", "Code", itemGroup.CompanyID);
            ViewBag.ParentGroupID = new SelectList(db.ItemGroups, "ID", "Code", itemGroup.ParentGroupID);
            return(View(itemGroup));
        }
        /// <summary>
        /// 获取物品组。
        /// </summary>
        /// <param name="itemGroupName">物品组名称。</param>
        /// <returns>要获取的物品组。</returns>
        public IItemGroup GetItemGroup(string itemGroupName)
        {
            if (string.IsNullOrEmpty(itemGroupName))
            {
                throw new GameFrameworkException("Item group name is invalid.");
            }

            ItemGroup itemGroup = null;

            if (m_ItemGroups.TryGetValue(itemGroupName, out itemGroup))
            {
                return(itemGroup);
            }

            return(null);
        }
Exemple #11
0
        public virtual bool IsTimeForDeliverItem(GameUnit unit)
        {
            var lairPos = ChunkUtil.GetUpper(unit.GroupObj.GetLairPos());

            if (unit.pickUped == null || !unit.GroupObj.IsSetUpedLairPos(unit) ||
                (ChunkUtil.IsAnyEntity(unit.ChunkNumber, lairPos) && unit.CurrentPos != lairPos))
            {
                return(false);
            }
            if (!SecondaryGroundLvL.IsEmptyPos(unit.ChunkNumber, lairPos))
            {
                return(ItemGroup.IsCanBeStacked(unit.pickUped.OriginalName,
                                                SecondaryGroundLvL.GetGroundEnt(unit.ChunkNumber, lairPos).OriginalName));
            }
            return(true);
        }
        public async Task ShouldRespond422ForInexistentGroupId()
        {
            var itemGroup = new ItemGroup().Of(_token.TenantId);

            _server.Database.ItemGroups.Add(itemGroup);
            await _server.Database.SaveChangesAsync();

            var path        = "/items";
            var jsonRequest = new SaveItemJson().Build(groupId: 90);
            var response    = await _client.PostJsonAsync(path, jsonRequest);

            var jsonResponse = await _client.ReadJsonAsync <UnprocessableEntityError>(response);

            Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
            Assert.Equal("ITEM_GROUP_NOT_FOUND", jsonResponse.Error);
        }
Exemple #13
0
    // returns the amount of an item we have in the inventory
    public int containsItem(ItemGroup itemGroup)
    {
        int count = 0;

        // go through all the stored items if the item is the one
        // we are looking for then add the amount to the total count
        foreach (StoredItem storedItem in storedItems)
        {
            if (storedItem.itemGroup == itemGroup)
            {
                count += storedItem.amount;
            }
        }

        return(count);
    }
Exemple #14
0
        public Order FromOrderDTOToOrder(OrderDTO orderDTOToMap)
        {
            Order orderToReturn = new Order();

            if (orderDTOToMap.IdOfCustomer == -1 || orderDTOToMap.ItemGroupsDTO.Count == 0)
            {
                throw new OrderException();
            }
            foreach (var itemgroupDTO in orderDTOToMap.ItemGroupsDTO)
            {
                ItemGroup itemGroupFromThisOrder = _itemGroupMapper.FromItemGroupDTOToItemGroup(itemgroupDTO);
                orderToReturn.ItemGroups.Add(itemGroupFromThisOrder);
            }
            orderToReturn.CalculatePriceOfOrder();
            return(orderToReturn);
        }
Exemple #15
0
        private bool EditQuantityNeedsUpdating(ItemGroup itemGroup)
        {
            bool cachedAdd = false, cachedChange = false;

            foreach (ItemGroup checkItemGroup in _itemGroupsAdded
                     .Where(checkItemGroup => checkItemGroup.Id == itemGroup.Id))
            {
                cachedAdd = true;
            }
            foreach (ItemGroup checkItemGroup in _itemGroupsNeedingUpdate
                     .Where(checkItemGroup => checkItemGroup.Id == itemGroup.Id))
            {
                cachedChange = true;
            }
            return(!cachedAdd && !cachedChange);
        }
Exemple #16
0
        public ItemGroup Create(string name, Guid?parentId)
        {
            var group = new ItemGroup()
            {
                Id          = Guid.NewGuid(),
                PartNumber  = name ?? "NA-Group",
                ParentId    = parentId,
                ItemType    = ItemTypes.Group,
                CreatedDate = DateTime.Now,
            };

            erpNodeDBContext.ItemGroups.Add(group);

            this.SaveChanges();
            return(group);
        }
        public static void AddBeforeLastImport()
        {
            var project = Project.Load("testproj.csproj");

            var lastImport = project.Imports.Last();

            var itemGroup = new ItemGroup();

            var newFile = new Compile("testfile.cs");

            itemGroup.Add(newFile);

            lastImport.AddBeforeSelf(itemGroup);

            project.Save();
        }
        public void Enqueue(T change)
        {
            if (_currentGroup == null || !_currentGroup.IsOpenGroup)
            {
                _currentGroup = CreateNewItemGroup(change);
                _itemGroupQueue.Enqueue(_currentGroup);
            }
            else if (_currentGroup.IsBlocking != change.IsBlocking)
            {
                _currentGroup.CloseGroup();
                _currentGroup = CreateNewItemGroup(change);
                _itemGroupQueue.Enqueue(_currentGroup);
            }

            _currentGroup.Enqueue(change);
        }
Exemple #19
0
        public ItemGroupViewModel SaveItemGroup(ItemGroupViewModel model)
        {
            exceptionService.Execute((m) =>
            {
                if (itemGroupRepository.Table.Any(x => x.Name == model.Name && x.Id != model.Id))
                {
                    model.AddModelError(x => x.Name, "Error.DuplicateValue", "Item group name already exists.");
                }

                if (model.HasError)
                {
                    return;
                }

                if (!model.Validate())
                {
                    return;
                }

                var entity = new ItemGroup();

                if (model.Id > 0)
                {
                    entity              = itemGroupRepository.GetById(model.Id);
                    entity.Name         = model.Name;
                    entity.Code         = model.Code;
                    entity.ItemTypeId   = model.ItemTypeId;
                    entity.DisplayOrder = model.DisplayOrder;
                    itemGroupRepository.Update(entity);
                }
                else
                {
                    entity = AutomapperConfig.Mapper.Map <ItemGroup>(model);
                    itemGroupRepository.Insert(entity);
                }
                if (model.Id == 0)
                {
                    model.Message = localizationService.GetLocalizedText("Message.EmployeeSavedSuccessfully", IMSAppConfig.Instance.CurrentLanguage, "Employee saved succeeded.");
                }
                else
                {
                    model.Message = localizationService.GetLocalizedText("Message.EmployeeUpdatedSuccessfully", IMSAppConfig.Instance.CurrentLanguage, "Employee update succeeded.");
                }
            }, model);

            return(model);
        }
Exemple #20
0
        private ItemGroup FindOrCreateLinkItemGroup(Project project)
        {
            var itemGroup = project.ItemGroups
                            .FirstOrDefault(group =>
                                            group.Contents.Any(content =>
                                                               content is Compile compile &&
                                                               compile.Link != null &&
                                                               compile.Condition == null));

            if (itemGroup == null)
            {
                itemGroup = new ItemGroup();
                project.AddItemGroup(itemGroup);
            }

            return(itemGroup);
        }
Exemple #21
0
        public void SetItem(ItemGroup itemGroup)
        {
            var itemInfo = ItemSys.GetInfo(itemGroup.Id);

            if (_CurItemGroup.Id != itemGroup.Id)
            {
                var texture = _CurItemGroup.Id == 0
                    ? null
                    : BundleSys.GetAsset<Texture>(itemInfo.PackageCellTexturePath);
                _Texture.texture = new NTexture(texture);
            }

            if(_CurItemGroup.Count!=itemGroup.Count)
                _Num.text = itemGroup.Count.ToString();

            _CurItemGroup = itemGroup;
        }
        // POST: api/Unit
        public ServerResponse Post([FromBody] ItemGroup itemGroup)
        {
            var res = new ServerResponse();

            using (ItemGroupBL itemGroupBL = new ItemGroupBL())
            {
                try
                {
                    res.Data = itemGroupBL.SaveItemGroup(itemGroup);
                }
                catch (Exception ex)
                {
                    res.Success = false;
                }
            }
            return(res);
        }
        public JsonResult Edit(String igID, String item_group_name)
        {
            try
            {
                var ig = new ItemGroup();
                ig.ItemGroupName = item_group_name;

                dbContext.ItemGroups.Update(ig);
                dbContext.SaveChanges();
                return(GETJSON());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(GETJSON());
        }
Exemple #24
0
 /// <summary>
 /// 初始化 行分组数据.
 /// </summary>
 /// <param name="result"></param>
 protected void InitRow(ItemMaster result)
 {
     for (int i = 0; i < sizeOfArray; i++)
     {
         ItemGroup itemGroup = new ItemGroup()
         {
             // 名称.
             GroupName = String.Format("第{0}行", i),
             // 固定数据列表.
             FixItemList = result.FixItemList.Where(p => p.Y == i).ToList(),
             // 动态数据列表.
             DynamicsItemList = result.DynamicsItemList.Where(p => p.Y == i).ToList(),
         };
         // 加入数据组.
         result.ItemGroupList.Add(itemGroup);
     }
 }
        public BuildTarget(int lineNumber, PropertyGroup targetProps, ItemGroup targetItems)
        {
            LineNumber = lineNumber;
            Properties = targetProps;
            Items = targetItems;
            Name = targetProps.GetRequiredValue("TargetName");
            InputFiles = targetItems.GetRequiredValue("TargetInputs");
            OutputFiles = targetItems.GetRequiredValue("TargetOutputs");

            Func<IList<ParsedPath>, IEnumerable<string>> extractAndSortExtensions = (files) =>
            {
                return files.Select<ParsedPath, string>(f => f.Extension).Distinct<string>().OrderBy(s => s, StringComparer.CurrentCultureIgnoreCase);
            };

            InputExtensions = extractAndSortExtensions(InputFiles);
            OutputExtensions = extractAndSortExtensions(OutputFiles);
        }
Exemple #26
0
        public void getlItmGrp()
        {
            //lDept = new List<Department>();

            DataTable dt = new DataTable();

            dt = selectAll();
            foreach (DataRow row in dt.Rows)
            {
                ItemGroup curr1 = new ItemGroup();
                curr1.item_group_id     = row[itmGrp.item_group_id].ToString();
                curr1.item_group_name_t = row[itmGrp.item_group_name_t].ToString();
                curr1.item_group_name_e = row[itmGrp.item_group_name_e].ToString();

                lExpnT.Add(curr1);
            }
        }
Exemple #27
0
        public async Task ShouldDeleteSuccessfully()
        {
            var itemGroup = new ItemGroup().Of(_token.TenantId);

            _server.Database.ItemGroups.Add(itemGroup);
            await _server.Database.SaveChangesAsync();

            var path     = $"/item-groups/{itemGroup.Id}";
            var response = await _client.DeleteAsync(path);

            var hasBeenDeleted = !await _server.Database.ItemGroups
                                 .WhereKey(_token.TenantId, itemGroup.Id)
                                 .AnyAsync();

            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
            Assert.True(hasBeenDeleted);
        }
Exemple #28
0
        protected override void GenerateTheDetails()
        {
            AttackSpeed = (float)random.Next(5, 26) / 10;
            ChanceToHit = (0.9f + (float)ItemLevel) * .05f;
            DamageOnHit = random.Next(5, 11) * ItemLevel;
            /// <summary>
            /// DPS = Math.Ceiling((((minDamageOnHit+MaxDamageOnHit)/2)*(AttackSpeed + ChanceToHit)));
            /// </summary>

            DamagePerSecond       = (int)Math.Ceiling((((1 + DamageOnHit) / 2) * (AttackSpeed + ChanceToHit)));
            PriceBuy              = ((ItemLevel * DamagePerSecond) + (ItemLevel * StatsModAmount)) * 100;
            PriceSell             = (PriceBuy * random.Next(2, 6)) / 10;
            DamageReductionAmount = 0;
            //Debug.Log("_baseName = " + _baseName);
            ItemSlug = "weapon-" + (ItemGroup.ToLower()) + "-" + ItemLevel.ToString() + "-" + (_baseName.ToLower());
            // Debug.Log("Weapon! Name:" + Name +"/ Class:"+ItemClass+ "/ Level:" + ItemLevel + "/ ItemGroup: " + ItemGroup + "/ ItemQuality:" + ItemQuality + "/ PriceBuy:" + PriceBuy + "/ PriceSell:" + PriceSell+"/ DamageOnHit: " + DamageOnHit +"/ AttackSpeed: "+AttackSpeed+"/ ChanceToHit: "+ChanceToHit+"/ DPS: "+DamagePerSecond+"/ StatsModAmount: "+ StatsModAmount+"/ slug: "+ItemSlug +".png");
        }
Exemple #29
0
        public List <PresentationItemGroup> GetPresentationItemGroups(string searchString)
        {
            List <PresentationItem>      _presentationItems      = new List <PresentationItem>();
            List <PresentationItemGroup> _presentationItemGroups = new List <PresentationItemGroup>();
            List <Item> _searchresultItems = _searcher.Search(searchString);

            // Creates and adds presentationsItems to list
            foreach (var i in _searchresultItems)
            {
                ItemGroup           searchresultItemGroup = _db.TableItemGroup.GetItemGroup(i.ItemGroupID);
                List <StoreSection> itemStoreSections     = _db.TableItemSectionPlacement.FindPlacementsByItem(i.ItemID);

                List <Point> itemPlacementList = new List <Point>();
                foreach (var section in itemStoreSections)
                {
                    itemPlacementList.Add(new Point((int)section.CoordinateX, (int)section.CoordinateY));
                }
                if (itemPlacementList.Any())
                {
                    _presentationItems.Add(new PresentationItem(i.Name, searchresultItemGroup.ItemGroupName, itemPlacementList));
                }
            }

            // Distributes presentationItems to PresentationItemsGroups with same itemgroup name
            foreach (var pi in _presentationItems)
            {
                var tempPIG = _presentationItemGroups.FirstOrDefault(g => g.Name == pi.Itemgroupname);

                // if there is no existing PresentationItemGroup with same Itemgroup name
                if (tempPIG == null)
                {
                    //Create new PresentationItemGroup
                    PresentationItemGroup PIG = new PresentationItemGroup(pi.Itemgroupname, new List <PresentationItem>()
                    {
                        pi
                    });
                    _presentationItemGroups.Add(PIG);
                }
                else // if there is a PresentationItemGroup with same Itemgroup name
                {
                    tempPIG.PresentationItems.Add(pi);
                }
            }

            return(_presentationItemGroups);
        }
Exemple #30
0
        protected override void SelectionHandler(SelectButton selection)
        {
            RadioButton radio = selection as RadioButton;

            if (!ItemGroup.Contains(radio))
            {
                return;
            }

            foreach (RadioButton btn in ItemGroup)
            {
                if (btn != null && btn != radio && btn.IsEnabled == true)
                {
                    btn.IsSelected = false;
                }
            }
        }
Exemple #31
0
        /// <summary>
        /// Returns all <see cref="ItemSlot"/>s items of this group can be slotted into.
        /// </summary>
        public static ItemSlot ItemSlots(this ItemGroup group)
        {
            switch (group)
            {
            case ItemGroup.BodyArmour:
                return(ItemSlot.BodyArmour);

            case ItemGroup.Boots:
                return(ItemSlot.Boots);

            case ItemGroup.Gloves:
                return(ItemSlot.Gloves);

            case ItemGroup.Helmet:
                return(ItemSlot.Helm);

            case ItemGroup.Shield:
            case ItemGroup.Quiver:
                return(ItemSlot.OffHand);

            case ItemGroup.OneHandedWeapon:
                return(ItemSlot.MainHand | ItemSlot.OffHand);

            case ItemGroup.TwoHandedWeapon:
                return(ItemSlot.MainHand);

            case ItemGroup.Belt:
                return(ItemSlot.Belt);

            case ItemGroup.Ring:
                return(ItemSlot.Ring | ItemSlot.Ring2);

            case ItemGroup.Amulet:
                return(ItemSlot.Amulet);

            case ItemGroup.Gem:
                return(ItemSlot.Gem);

            case ItemGroup.Jewel:
            case ItemGroup.Unknown:
                return(ItemSlot.Unequipable);

            default:
                return(ItemSlot.Unequipable);
            }
        }
        public ItemGroup GetMaxProfitValue(int forFirstN, int atWeight)
        {
            // value at 0 items or 0 weight, or 0 items chosen is 0
            if (forFirstN == 0 || atWeight <= 0)
            {
                return(new ItemGroup());
            }

            // calculate the previous value
            if (_maxProfitItemGroup[forFirstN - 1, atWeight] is null)
            {
                _maxProfitItemGroup[forFirstN - 1, atWeight] = GetMaxProfitValue(forFirstN - 1, atWeight);
            }

            // if current item weight is greater than weight being calculated, don't add the value
            if (_items[forFirstN - 1].Weight > atWeight)
            {
                _maxProfitItemGroup[forFirstN, atWeight] = new ItemGroup(_maxProfitItemGroup[forFirstN - 1, atWeight]);
            }
            else
            {
                var itemGroupExcludingCurrent = _maxProfitItemGroup[forFirstN - 1, atWeight - _items[forFirstN - 1].Weight];

                // if we haven't calculated max without current item, do it now
                if (itemGroupExcludingCurrent is null)
                {
                    itemGroupExcludingCurrent = GetMaxProfitValue(forFirstN - 1, atWeight - _items[forFirstN - 1].Weight);
                    _maxProfitItemGroup[forFirstN - 1, atWeight - _items[forFirstN - 1].Weight] = itemGroupExcludingCurrent;
                }

                int profitAtWeightExcludingCurrentItem = itemGroupExcludingCurrent.TotalValue();
                int profitOfCurrentItem       = _items[forFirstN - 1].Value;
                int profitOnPreviousIteration = _maxProfitItemGroup[forFirstN - 1, atWeight].TotalValue();

                if (profitAtWeightExcludingCurrentItem + profitOfCurrentItem > profitOnPreviousIteration)
                {
                    _maxProfitItemGroup[forFirstN, atWeight] = (ItemGroup) new ItemGroup(itemGroupExcludingCurrent).Add(_items[forFirstN - 1]);;
                }
                else
                {
                    _maxProfitItemGroup[forFirstN, atWeight] = new ItemGroup(_maxProfitItemGroup[forFirstN - 1, atWeight]);
                }
            }

            return(_maxProfitItemGroup[forFirstN, atWeight]);
        }
Exemple #33
0
        private static int GetWidthForItem(ItemType type, ItemGroup group, string name)
        {
            switch (group)
            {
            case ItemGroup.Helmet:
            case ItemGroup.BodyArmour:
            case ItemGroup.Belt:
            case ItemGroup.Gloves:
            case ItemGroup.Boots:
            case ItemGroup.Quiver:
            case ItemGroup.Shield:
            case ItemGroup.TwoHandedWeapon:
                return(name == "Corroded Blade" ? 1 : 2);
            }
            switch (type)
            {
            case ItemType.OneHandedAxe:
            case ItemType.Claw:
            case ItemType.Sceptre:
                return(2);

            case ItemType.OneHandedMace:
                if (name.EndsWith("Club") || name == "Tenderizer")
                {
                    return(1);
                }
                return(2);

            case ItemType.OneHandedSword:
                switch (name)
                {
                case "Rusted Sword":
                case "Gemstone Sword":
                case "Corsair Sword":
                case "Cutlass":
                case "Variscite Blade":
                case "Sabre":
                case "Copper Sword":
                    return(1);
                }
                return(2);
            }

            // Thrusting swords, rings, amulets
            return(1);
        }
Exemple #34
0
        void SaveSettings()
        {
            for (int i = 0; i < chkListBoxBootstrappers.Items.Count; i++)
            {
                Util.BootstrapperPackage package = chkListBoxBootstrappers.Items[i] as Util.BootstrapperPackage;
                if (package == null)
                {
                    continue;
                }

                bool isChecked = chkListBoxBootstrappers.GetItemChecked(i);

                ItemGroup itemGroup = config.ItemGroupBootstrapperPackages;

                BootstrapperPackageItem item = null;
                if (itemGroup.ContainsKey(package.ProductCode))
                {
                    item = itemGroup[package.ProductCode] as BootstrapperPackageItem;
                }
                else
                {
                    item = new BootstrapperPackageItem(package.ProductCode);
                    itemGroup.Add(item);
                }

                item.Install = isChecked;
            }

            CsProject.PropertyCollection properties = config.PropertyItems;
            properties.BootstrapperEnabled = chkBootstrapperEnabled.Checked;

            if (radioComponentsLocationRelative.Checked)
            {
                properties.BootstrapperComponentsLocation = CsProject.BootstrappersLocations.Relative;
            }
            else if (radioComponentsLocationAbsolute.Checked)
            {
                properties.BootstrapperComponentsLocation = CsProject.BootstrappersLocations.Absolute;
            }
            else
            {
                properties.BootstrapperComponentsLocation = CsProject.BootstrappersLocations.Default;
            }
            properties.BootstrapperComponentsUrl = cmbBootstrapperComponentsUrl.Text;
        }
Exemple #35
0
        private static int GetWidthForItem(ItemType type, ItemGroup group, string name)
        {
            switch (group)
            {
                case ItemGroup.Helmet:
                case ItemGroup.BodyArmour:
                case ItemGroup.Belt:
                case ItemGroup.Gloves:
                case ItemGroup.Boots:
                case ItemGroup.Quiver:
                case ItemGroup.Shield:
                case ItemGroup.TwoHandedWeapon:
                    return name == "Corroded Blade" ? 1 : 2;
            }
            switch (type)
            {
                case ItemType.OneHandedAxe:
                case ItemType.Claw:
                case ItemType.Sceptre:
                    return 2;

                case ItemType.OneHandedMace:
                    if (name.EndsWith("Club") || name == "Tenderizer")
                        return 1;
                    return 2;

                case ItemType.OneHandedSword:
                    switch (name)
                    {
                        case "Rusted Sword":
                        case "Gemstone Sword":
                        case "Corsair Sword":
                        case "Cutlass":
                        case "Variscite Blade":
                        case "Sabre":
                        case "Copper Sword":
                            return 1;
                    }
                    return 2;

            }

            // Thrusting swords, rings, amulets
            return 1;
        }
Exemple #36
0
        private static int GetHeightForItem(ItemType type, ItemGroup group, string name)
        {
            switch (group)
            {
                case ItemGroup.TwoHandedWeapon:
                    return name.EndsWith("Crude Bow") || name.EndsWith("Short Bow") || name.EndsWith("Grove Bow") || name.EndsWith("Thicket Bow") ? 3 : 4;
                case ItemGroup.Helmet:
                case ItemGroup.Gloves:
                case ItemGroup.Boots:
                    return 2;

                case ItemGroup.Shield:
                    if (name.EndsWith("Kite Shield") || name.EndsWith("Round Shield"))
                        return 3;
                    if (name.EndsWith("Tower Shield"))
                        return 4;
                    return 2;

                case ItemGroup.Quiver:
                case ItemGroup.BodyArmour:
                    return 3;
            }

            // belts, amulets, rings
            if (group != ItemGroup.OneHandedWeapon) return 1;

            switch (type)
            {
                case ItemType.Claw:
                    return 2;
                case ItemType.Dagger:
                case ItemType.Wand:
                case ItemType.OneHandedAxe:
                case ItemType.OneHandedMace:
                case ItemType.Sceptre:
                case ItemType.OneHandedSword:
                    return 3;
                case ItemType.ThrustingOneHandedSword:
                    return 4;
                default:
                    return 1;
            }
        }
        private ItemGroup GetOrCreateGroup(object obj, int groupIndex)
        {
            ItemGroup group = null;

            var named = obj as IName;
            if (named != null || IsFlatList)
            {
                string name = named == null ? string.Empty : named.Name;
                if (IsFlatList)
                    name = "flat";
                _groups.TryGetValue(name, out group);

                // Update the underlying object anyway!
                //if (group != null)
                //{
                // TODO: Would have to replace the underlying one.   Not really a core scenario, having the header need to change. Footer yes though when I add that.
                //group.SetContent(obj, HeaderTemplate);
                //}
            }
//#if DEBUG
            else
            {
                throw new InvalidOperationException("The group objects must be an IName or a flat list.");
            }
//#endif

            if (group == null)
            {
//#if BUILDING_4TH_AND_MAYOR
                Panel panel = PanelType == "WrapPanel" ? (Panel)(new WrapPanel()) : (Panel)(new StackPanel());
//#else
                //Panel panel = (Panel)(new StackPanel());
//#endif
                string nametoUse = named == null ? string.Empty : named.Name;
                if (IsFlatList)
                {
                    nametoUse = "flat";
                }
                group = new ItemGroup(nametoUse, obj, IsFlatList ? null : HeaderTemplate, panel);
                // To preserve the Top template, insert + 1.
                group.InsertGroupIntoVisualTree(_stack, groupIndex + 1);


                _groups[nametoUse] = group;
                //_groupItems.Add(group);
            }
            //else
            //{
                //group.MoveGroupIfNeeded(_stack, groupIndex);
            //}

            return group;
        }
        private List<CompilerClass> LoadCompilerClasses(ItemGroup itemGroup, PropertyGroup propGroup)
        {
            List<CompilerClass> compilerClasses = new List<CompilerClass>();
            IList<ParsedPath> paths = itemGroup.GetRequiredValue("CompilerAssembly");

            foreach (var path in paths)
            {
                Assembly assembly = null;

                try
                {
                    // We use Assembly.Load so that the test assembly and subsequently loaded
                    // assemblies end up in the correct load context.  If the assembly cannot be
                    // found it will raise a AssemblyResolve event where we will search for the
                    // assembly.
                    assembly = Assembly.LoadFrom(path);
                }
                catch (Exception e)
                {
                    throw new ApplicationException(String.Format("Unable to load content compiler assembly file '{0}'. {1}", path, e.ToString()), e);
                }

                Type[] types;

                // We won't get dependency errors until we actually try to reflect on all the types in the assembly
                try
                {
                    types = assembly.GetTypes();
                }
                catch (ReflectionTypeLoadException e)
                {
                    string message = String.Format("Unable to reflect on assembly '{0}'", path);

                    // There is one entry in the exceptions array for each null in the types array,
                    // and they correspond positionally.
                    foreach (Exception ex in e.LoaderExceptions)
                        message += Environment.NewLine + "   " + ex.Message;

                    // Not being able to reflect on classes in the test assembly is a critical error
                    throw new ApplicationException(message, e);
                }

                // Go through all the types in the test assembly and find all the
                // compiler classes, those that inherit from IContentCompiler.
                foreach (var type in types)
                {
                    Type interfaceType = type.GetInterface(typeof(IContentCompiler).ToString());

                    if (interfaceType != null)
                    {
                        CompilerClass compilerClass = new CompilerClass(assembly, type);

                        compilerClasses.Add(compilerClass);
                    }
                }
            }

            return compilerClasses;
        }
        private List<BuildTarget> PrepareBuildTargets(List<ContentFileV2.Target> rawTargets, ItemGroup globalItems, PropertyGroup globalProps)
        {
            List<BuildTarget> buildTargets = new List<BuildTarget>();

            foreach (var rawTarget in rawTargets)
            {
                try
                {
                    PropertyGroup targetProps = new PropertyGroup(globalProps);

                    targetProps.Set("TargetName", rawTarget.Name);

                    if (rawTarget.Properties != null)
                        targetProps.ExpandAndAddFromList(rawTarget.Properties, targetProps);

                    ItemGroup targetItems = new ItemGroup(globalItems);

                    ParsedPathList inputFiles = new ParsedPathList();
                    string[] list = rawTarget.Inputs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (var rawInputFile in list)
                    {
                        ParsedPath pathSpec = null;
                        string s = targetProps.ReplaceVariables(rawInputFile);

                        try
                        {
                            pathSpec = new ParsedPath(s, PathType.File).MakeFullPath();
                        }
                        catch (Exception e)
                        {
                            throw new ContentFileException("Bad path '{0}'".CultureFormat(s), e);
                        }

                        if (pathSpec.HasWildcards)
                        {
                            if (!Directory.Exists(pathSpec.VolumeAndDirectory))
                            {
                                throw new ContentFileException("Directory '{0}' does not exist".CultureFormat(pathSpec.VolumeAndDirectory));
                            }

                            IList<ParsedPath> files = DirectoryUtility.GetFiles(pathSpec, SearchScope.DirectoryOnly);

                            if (files.Count == 0)
                            {
                                throw new ContentFileException("Wildcard input refers to no files after expansion");
                            }

                            inputFiles = new ParsedPathList(inputFiles.Concat(files));
                        }
                        else
                        {
                            if (!File.Exists(pathSpec))
                            {
                                throw new ContentFileException("Input file '{0}' does not exist".CultureFormat(pathSpec));
                            }

                            inputFiles.Add(pathSpec);
                        }
                    }

                    ParsedPathList outputFiles = new ParsedPathList();

                    list = rawTarget.Outputs.Split(';');

                    foreach (var rawOutputFile in list)
                    {
                        string s = targetProps.ReplaceVariables(rawOutputFile);

                        try
                        {
                            ParsedPath outputFile = new ParsedPath(s, PathType.File).MakeFullPath();

                            outputFiles.Add(outputFile);
                        }
                        catch (Exception e)
                        {
                            throw new ContentFileException("Bad path '{0}'".CultureFormat(s), e);
                        }
                    }

                    targetItems.Set("TargetInputs", inputFiles);
                    targetItems.Set("TargetOutputs", outputFiles);

                    bool needsRebuild = IsCompileRequired(inputFiles, outputFiles);

                    if (!needsRebuild)
                        continue;

                    buildTargets.Add(new BuildTarget(rawTarget.LineNumber, targetProps, targetItems));
                }
                catch (Exception e)
                {
                    throw new ContentFileException(this.ContentPath, rawTarget.LineNumber, "Error preparing targets", e);
                }
            }

            return buildTargets;
        }
Exemple #40
0
        // 根据一个MARC字段,创建Group数组
        // 必须符合下列定义:
        // 将$a放入到Barcode
        // 将$h放入到RegisterNo
        public int BuildGroups(string strField,
            out List<ItemGroup> groups,
            out string strWarning,
            out string strError)
        {
            strError = "";
            strWarning = "";
            groups = new List<ItemGroup>();
            int nRet = 0;

            // 进行子字段组循环
            for (int g = 0; ; g++)
            {
                string strGroup = "";
                // 从字段中得到子字段组
                // parameters:
                //		strField	字段。其中包括字段名、必要的指示符,字段内容。也就是调用GetField()函数所得到的字段。
                //		nIndex	子字段组序号。从0开始计数。
                //		strGroup	[out]得到的子字段组。其中包括若干子字段内容。
                // return:
                //		-1	出错
                //		0	所指定的子字段组没有找到
                //		1	找到。找到的子字段组返回在strGroup参数中
                nRet = MarcUtil.GetGroup(strField,
                    g,
                    out strGroup);
                if (nRet == -1)
                {
                    strError = "从MARC记录字段中获得子字段组 " + Convert.ToString(g) + " 时出错";
                    return -1;
                }

                if (nRet == 0)
                    break;

                // 册条码

                string strSubfield = "";
                string strNextSubfieldName = "";

                string strBarcode = "";
                string strRegisterNo = "";

                // 从字段或子字段组中得到一个子字段
                // parameters:
                //		strText		字段内容,或者子字段组内容。
                //		textType	表示strText中包含的是字段内容还是组内容。若为ItemType.Field,表示strText参数中为字段;若为ItemType.Group,表示strText参数中为子字段组。
                //		strSubfieldName	子字段名,内容为1位字符。如果==null,表示任意子字段
                //					形式为'a'这样的。
                //		nIndex			想要获得同名子字段中的第几个。从0开始计算。
                //		strSubfield		[out]输出子字段。子字段名(1字符)、子字段内容。
                //		strNextSubfieldName	[out]下一个子字段的名字,内容一个字符
                // return:
                //		-1	出错
                //		0	所指定的子字段没有找到
                //		1	找到。找到的子字段返回在strSubfield参数中
                nRet = MarcUtil.GetSubfield(strGroup,
                    ItemType.Group,
                    "a",
                    0,
                    out strSubfield,
                    out strNextSubfieldName);
                if (strSubfield.Length >= 1)
                {
                    strBarcode = strSubfield.Substring(1).Trim();   // 去除左右多余的空白
                }

                if (String.IsNullOrEmpty(strBarcode) == false)
                {
                    // 去掉左边的'*'号 2006/9/2 add
                    if (strBarcode[0] == '*')
                        strBarcode = strBarcode.Substring(1);

                    /*
                    // return:
                    //      -1  error
                    //      0   OK
                    //      1   Invalid
                    nRet = VerifyBarcode(
                        false,
                        strBarcode,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    // 检查册条码长度
                    if (nRet != 0)
                    {
                        strWarning += "册条码 '" + strBarcode + "' 不合法 -- " + strError + "; ";
                    }*/

                    strBarcode = strBarcode.ToUpper();  // 2008/10/24 new add
                }


                // 登录号
                nRet = MarcUtil.GetSubfield(strGroup,
        ItemType.Group,
        "h",
        0,
        out strSubfield,
        out strNextSubfieldName);
                if (strSubfield.Length >= 1)
                {
                    strRegisterNo = strSubfield.Substring(1);
                }

                // TODO: 需要加入检查登录号长度的代码


                ItemGroup group = new ItemGroup();
                group.strValue = strGroup;
                group.strBarcode = strBarcode;
                group.strRegisterNo = strRegisterNo;

                groups.Add(group);
            }

            return 0;
        }
Exemple #41
0
            public string strMergeComment = ""; // 合并过程细节注释

            // 从另一Group对象中合并必要的子字段值过来
            // 2008/4/14 new add
            // parameters:
            //      strSubfieldNames    若干个需要合并的子字段名 2008/12/28 new add
            public void MergeValue(ItemGroup group,
                string strSubfieldNames)
            {
                int nRet = 0;
                // string strSubfieldNames = "b";  // 若干个需要合并的子字段名

                for (int i = 0; i < strSubfieldNames.Length; i++)
                {
                    char subfieldname = strSubfieldNames[i];

                    string strSubfieldName = new string(subfieldname, 1);

                    string strSubfield = "";
                    string strNextSubfieldName = "";

                    string strValue = "";

                    // 从字段或子字段组中得到一个子字段
                    // parameters:
                    //		strText		字段内容,或者子字段组内容。
                    //		textType	表示strText中包含的是字段内容还是组内容。若为ItemType.Field,表示strText参数中为字段;若为ItemType.Group,表示strText参数中为子字段组。
                    //		strSubfieldName	子字段名,内容为1位字符。如果==null,表示任意子字段
                    //					形式为'a'这样的。
                    //		nIndex			想要获得同名子字段中的第几个。从0开始计算。
                    //		strSubfield		[out]输出子字段。子字段名(1字符)、子字段内容。
                    //		strNextSubfieldName	[out]下一个子字段的名字,内容一个字符
                    // return:
                    //		-1	出错
                    //		0	所指定的子字段没有找到
                    //		1	找到。找到的子字段返回在strSubfield参数中
                    nRet = MarcUtil.GetSubfield(this.strValue,
                        ItemType.Group,
                        strSubfieldName,
                        0,
                        out strSubfield,
                        out strNextSubfieldName);
                    if (strSubfield.Length >= 1)
                    {
                        strValue = strSubfield.Substring(1).Trim();   // 去除左右多余的空白
                    }

                    // 如果为空,才需要看看增补
                    if (String.IsNullOrEmpty(strValue) == true)
                    {
                        string strOtherValue = "";

                        strSubfield = "";
                        nRet = MarcUtil.GetSubfield(group.strValue,
                            ItemType.Group,
                            strSubfieldName,
                            0,
                            out strSubfield,
                            out strNextSubfieldName);
                        if (strSubfield.Length >= 1)
                        {
                            strOtherValue = strSubfield.Substring(1).Trim();   // 去除左右多余的空白
                        }

                        if (String.IsNullOrEmpty(strOtherValue) == false)
                        {
                            // 替换字段中的子字段。
                            // parameters:
                            //		strField	[in,out]待替换的字段
                            //		strSubfieldName	要替换的子字段的名,内容为1字符。如果==null,表示任意子字段
                            //					形式为'a'这样的。
                            //		nIndex		要替换的子字段所在序号。如果为-1,将始终为在字段中追加新子字段内容。
                            //		strSubfield	要替换成的新子字段。注意,其中第一字符为子字段名,后面为子字段内容
                            // return:
                            //		-1	出错
                            //		0	指定的子字段没有找到,因此将strSubfieldzhogn的内容插入到适当地方了。
                            //		1	找到了指定的字段,并且也成功用strSubfield内容替换掉了。
                            nRet = MarcUtil.ReplaceSubfield(ref this.strValue,
                                strSubfieldName,
                                0,
                                strSubfieldName + strOtherValue);
                        }
                    }
                }


            }
 public static List<NativeDescriptor> GetDescriptorsByItemGroup(ItemGroup itemGroup)
 {
     return _indexByGroup[itemGroup];
 }
        private void UpdateMappings(ItemGroup group, IList items, ref int liveItemCount)
        {
            bool isLimitingGroups = InitialItemsLimit > 0;
            int ilg = InitialItemsLimit;

            int c = items.Count;
#if DEBUG_GIC
            Debug.WriteLine("UpdateMappings is looking at " + group.Name + 
                " working with " + c + 
                " items and the incoming live count was " + liveItemCount);
#endif
            Dictionary<Mapping, bool> previousItemsHash = new Dictionary<Mapping, bool>(group.Items.Count);
            foreach (var item in group.Items)
            {
#if DEBUG_GIC
                Debug.WriteLine("A previous item is " + item.SpecializedString);
#endif
                previousItemsHash[item] = true;
            }
            group.Items.Clear();

            int insertionIndex = -1;
            for (int i = 0; i < c; ++i)
            {
                insertionIndex++;
                liveItemCount++;

                var icsc = items[i] as ISpecializedComparisonString;

                //Debug.Assert(icsc != null);

                string s = icsc != null ? icsc.SpecializedComparisonString : items[i].ToString();

                Mapping existing;

                if (s == null)
                {
                    continue;
                }

                bool needToCreate = true;

                // If it already mapped somewhere?
                if (_knownSpecializations.TryGetValue(s, out existing))
                {
                    //Debug.WriteLine("A known specialization exists already for " + s);
                    if (existing.Group.Name == group.Name)
                    {
                        needToCreate = false;

                        //Debug.WriteLine("+ and it stayed in the same group.");
                        previousItemsHash.Remove(existing);

                        // TODO: REORDERING!
                        //int itemIndex = group.Panel.Children.IndexOf(existing.Presenter);
                        existing.Content = items[i];
                        if (existing.HasBeenShownYet)
                        {
                            existing.Presenter.Content = existing.Content;
                        }

                        // Needs to be in the new ordered list.
                        group.Items.Insert(insertionIndex, existing);

                        // Could see if they even really changed or not.
                    }
                    else
                    {
                        //Debug.WriteLine("- but it moved to this group from another!");

                        // Now present in this group, remove it from the old.
#if DEBUG_GIC
                        Debug.WriteLine("A previous item moved to the new group! " + s + existing.Content);
#endif
                        existing.Group.Panel.Children.Remove(existing.Presenter);
                        group.Items.Remove(existing);
                        _knownSpecializations.Remove(s);

                        // Decrement for a new insert!
                        // i--;
                        //insertionIndex--; // ? is this correct ?
                    }
                }

                if (needToCreate)
                {
                    // Create a new mapping.
                    var map = new Mapping
                    {
                        Content = items[i],
                        Group = group,
                    };
                    map.SetToEmpty(MinimumItemHeight);

                    _knownSpecializations[s] = map;

                    map.OverallItemIndex = liveItemCount;

                    // Index of 0, not a count actually.
                    if (liveItemCount < _itemsInFirstScreen + 1)
                    {
                        map.IsInitialLoadSet = true;
                    }

                    if (isLimitingGroups && i > ilg)
                    {
                        map.IsHidden = true;
                        // store insertion index?

                        // TODO: SHOW GROUP FOOTER!
                    }
                    else
                    {
                        int count = group.Panel.Children.Count;

#if DEBUG
                        if (count < insertionIndex)
                        {
                            // TODO: DEBUG AND FIX!!!!!
                            Debug.WriteLine("DANGER! This is not good math. {0} {1} {2} {3}",
                                insertionIndex,
                                count,
                                IsFlatList,
                                group != null ? group.Name : "null group name");
                        }
#endif
                        if (count < insertionIndex)
                        {
                            insertionIndex = count;
                        }

                        group.Panel.Children.Insert(insertionIndex, map.Presenter);
                        group.Items.Insert(insertionIndex, map);
                    }
                }
            }

            foreach (var emptyItem in previousItemsHash.Keys)
            {
                // Only if the item didn't move groups. So imagine a move up 
                // to a higher group, this would still return for hte other.
                if (emptyItem.Group.Name == group.Name)
                {
                    var pp = emptyItem.Presenter;
#if DEBUG_GIC
                    Debug.WriteLine("Removing previous item " + emptyItem.SpecializedString + emptyItem.ToString() + " " + emptyItem.Content);
#endif
                    emptyItem.Group.Panel.Children.Remove(pp);
                    _knownSpecializations.Remove(emptyItem.SpecializedString);
                }
            }

            // Empty group.
            if (c == 0)
            {
#if DEBUG_GIC
                Debug.WriteLine("--- empty group with c=0 so removing");
#endif
                group.RemoveGroup(this);
            }
        }
        private void SafeExecute()
        {
            if (!NoLogo)
                Console.WriteLine(Parser.LogoBanner);

            if (!runningFromCommandLine)
            {
                Parser.GetTargetArguments(this);
                Output.Message(MessageImportance.Normal, Parser.CommandName + Parser.Arguments);
            }

            if (ShowHelp)
            {
                Console.WriteLine(Parser.Usage);
                return;
            }

            if (String.IsNullOrEmpty(ContentPath))
            {
                Output.Error("A .content file must be specified");
                return;
            }

            this.ContentPath = this.ContentPath.MakeFullPath();

            if (!File.Exists(this.ContentPath))
            {
                Output.Error("Content file '{0}' does not exist", this.ContentPath);
                return;
            }

            // Initialize properties from the environment and command line
            PropertyGroup globalProps = new PropertyGroup();

            globalProps.AddFromEnvironment();
            globalProps.AddWellKnownProperties(
                new ParsedPath(Assembly.GetExecutingAssembly().Location, PathType.File).VolumeAndDirectory,
                ContentPath.VolumeAndDirectory);
            globalProps.AddFromPropertyString(this.Properties);

            BuildContext buildContext = new BuildContext(this.Output, this.ContentPath);

            ContentFileV2 contentFile = null;

            try
            {
                contentFile = ContentFileReaderV2.ReadFile(this.ContentPath);
            }
            catch (Exception e)
            {
                throw new ContentFileException(this.ContentPath, (int)e.Data["LineNumber"], "Problem reading content file", e);
            }

            Output.Message(MessageImportance.Low, "Read content file '{0}'", this.ContentPath);

            ItemGroup globalItems = new ItemGroup();

            globalItems.ExpandAndAddFromList(contentFile.Items, globalProps);

            List<CompilerClass> compilerClasses = LoadCompilerClasses(globalItems, globalProps);

            this.NewestAssemblyWriteTime = FindNewestAssemblyWriteTime(compilerClasses);
            this.ContentPathWriteTime = File.GetLastWriteTime(this.ContentPath);

            List<BuildTarget> BuildTargets = PrepareBuildTargets(contentFile.Targets, globalItems, globalProps);

            foreach (var buildTarget in BuildTargets)
            {
                bool compilerFound = false;

                foreach (var compilerClass in compilerClasses)
                {
                    if (buildTarget.InputExtensions.SequenceEqual(compilerClass.InputExtensions) &&
                        buildTarget.OutputExtensions.SequenceEqual(compilerClass.OutputExtensions))
                    {
                        compilerFound = true;

                        string msg = String.Format("Building target '{0}' with '{1}' compiler", buildTarget.Name, compilerClass.Name);

                        foreach (var input in buildTarget.InputFiles)
                        {
                            msg += Environment.NewLine + "\t" + input;
                        }

                        msg += Environment.NewLine + "\t->";

                        foreach (var output in buildTarget.OutputFiles)
                        {
                            msg += Environment.NewLine + "\t" + output;
                        }

                        Output.Message(MessageImportance.Normal, msg);

                        if (TestMode)
                            continue;

                        compilerClass.ContextProperty.SetValue(compilerClass.Instance, buildContext, null);
                        compilerClass.TargetProperty.SetValue(compilerClass.Instance, buildTarget, null);

                        try
                        {
                            compilerClass.CompileMethod.Invoke(compilerClass.Instance, null);
                        }
                        catch (TargetInvocationException e)
                        {
                            ContentFileException contentEx = e.InnerException as ContentFileException;

                            if (contentEx != null)
                            {
                                contentEx.EnsureFileNameAndLineNumber(buildContext.ContentFile, buildTarget.LineNumber);
                                throw contentEx;
                            }
                            else
                            {
                                throw new ContentFileException(
                                    this.ContentPath, buildTarget.LineNumber, "Unable to compile target '{0}'".CultureFormat(buildTarget.Name), e.InnerException);
                            }
                        }

                        // Ensure that the output files were generated
                        foreach (var outputFile in buildTarget.OutputFiles)
                        {
                            if (!File.Exists(outputFile))
                            {
                                throw new ContentFileException(this.ContentPath, buildTarget.LineNumber,
                                    "Output file '{0}' was not generated".CultureFormat(outputFile));
                           	}
                        }
                    }
                }

                if (!compilerFound)
                    Output.Warning("No compiler found for target '{0}' for extensions '{1}' -> '{2}'",
                   		buildTarget.Name,
                        String.Join(Path.PathSeparator.ToString(), buildTarget.InputExtensions),
                        String.Join(Path.PathSeparator.ToString(), buildTarget.OutputExtensions));
            }

            Output.Message(MessageImportance.Normal, "Done");
        }
Exemple #45
0
 public ItemPreset(ItemGroup g, ItemType t, string n, ItemQuality q, int sprId, int stk)
 {
     group = g;
     type = t;
     name = n;
     quality = q;
     spriteId = sprId;
     stackSize = stk;
 }
        private void btn_addGroup_Click(object sender, EventArgs e)
        {
            bool occupied = true;
            NameHelper.RestartNameInc(0);
            String groupName = "";
            while (occupied)
            {
                groupName = NameHelper.GetNextName("Group");
                if (!ModuleSharer.SceneMgr.GroupNameTaken(groupName))
                    occupied = false;
            }

            ItemGroup itemGrp = new ItemGroup();
            itemGrp.Name = groupName;
            ModuleSharer.SceneMgr.ItemGroups.Add(itemGrp);
            updateItemCollection();
        }
        private void btn_respawnRole_Click(object sender, EventArgs e)
        {
            ItemGroup roleGrp = ModuleSharer.SceneMgr.GetGroupByName("RoleGroup");
            if(roleGrp == null)
            {
                roleGrp = new ItemGroup();
                roleGrp.Name = "RoleGroup";
                ModuleSharer.SceneMgr.ItemGroups.Add(roleGrp);
            }
            roleGrp.Items.Clear();

            Role role = new Role();
            role.Name = "Role";
            AnimTexture animTex = new AnimTexture("Roles/MarioRole");
            animTex.SourceRect = new Rectangle(0, 0, 28, 48);
            animTex.AnimSeqList.Add(new AnimSequence("Run", 0, 8, 10, false, true));
            animTex.PlaySeq("Run");
            role.AnimTexture = animTex;
            role.PhysicsBody = new PhysicsBody(role.AnimTexture.TextureSize);
            role.Active = true;
            role.IsStatic = false;
            role.Position = ModuleSharer.SceneMgr.Camera.Focus;
            roleGrp.Add(role);
            // SceneMgr.Instance.RespawnRole(new Vector2(GameMgr.GameWidth / 2, GameMgr.GameHeight / 2));
        }
Exemple #48
0
        protected override IEnumerable<RecipeDef> GetRecipeDefs()
        {
            var AnyGel = new ItemGroup(new[]
            {
                new ItemRef(ItemID.    Gel),
                new ItemRef(ItemID.PinkGel)
            }, "Any gel");

            return new[]
            {
                new RecipeDef(
                    new ItemRef("Pizza"), 8,
                    new RecipeItems
                    {
                        { AnyGel, 30 }
                    }
                ),
                new RecipeDef(
                    new ItemRef("Ant"), 1,
                    new RecipeItems
                    {
                        { new ItemRef("Pizza"   ),  1 },
                        {              AnyGel    , 20 }
                    }
                ),
                new RecipeDef(
                    new ItemRef("Pizzant"), 1,
                    new RecipeItems
                    {
                        { new ItemRef("Pizza"   ), 1 },
                        { new ItemRef("Ant"     ), 1 },
                        {              AnyGel    , 4 }
                    },
                    new[] { new TileRef(TileID.TinkerersWorkbench) }
                ),
                new RecipeDef(
                    new ItemRef("Pizzantzioli"), 1,
                    new RecipeItems
                    {
                        { new ItemRef("Pizza"   ), 3 },
                        { new ItemRef("Pizzant" ), 1 },
                        {              AnyGel    , 4 }
                    },
                    new[] { new TileRef(TileID.Dirt) }
                ),
                new RecipeDef(
                    new ItemRef("WallPlacer"), 1,
                    new RecipeItems
                    {
                        { AnyGel, 1 }
                    }
                ),
                new RecipeDef(
                    new ItemRef("TilePlacer"), 1,
                    new RecipeItems
                    {
                        { AnyGel, 1 }
                    }
                )
            };
        }
 public bool Equals(ItemGroup other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Name, Name);
 }