コード例 #1
0
    public List <string> GetMaterialsInfoString(IEnumerable <MaterialInfo> materials)
    {
        List <string> info = new List <string>();

        if (!Inventory)
        {
            return(info);
        }
        using (var materialEnum = materials.GetEnumerator())
            while (materialEnum.MoveNext())
            {
                if (materialEnum.Current.MakingType == MakingType.SingleItem)
                {
                    info.Add(string.Format("{0}\t[{1}/{2}]", materialEnum.Current.ItemName, GetAmount(materialEnum.Current.Item), materialEnum.Current.Amount));
                }
                else
                {
                    Inventory.TryGetDatas(x => x.Model_old.MaterialType == materialEnum.Current.MaterialType, out var finds);
                    int amount = 0;
                    foreach (var item in finds)
                    {
                        amount += item.amount;
                    }
                    info.Add(string.Format("{0}\t[{1}/{2}]", MaterialItem.GetMaterialTypeString(materialEnum.Current.MaterialType), amount, materialEnum.Current.Amount));
                }
            }
        return(info);
    }
コード例 #2
0
    public IEnumerable <string> GetMaterialsInfo(IEnumerable <MaterialInfo> materials)
    {
        List <string> info = new List <string>();

        using (var materialEnum = materials.GetEnumerator())
            while (materialEnum.MoveNext())
            {
                if (materialEnum.Current.MakingType == MakingType.SingleItem)
                {
                    info.Add(string.Format("{0}\t[{1}/{2}]", materialEnum.Current.ItemName, Backpack.GetItemAmount(materialEnum.Current.Item), materialEnum.Current.Amount));
                }
                else
                {
                    var finds  = Backpack.Items.FindAll(x => x.item.MaterialType == materialEnum.Current.MaterialType);
                    int amount = 0;
                    foreach (var item in finds)
                    {
                        amount += item.Amount;
                    }
                    info.Add(string.Format("{0}\t[{1}/{2}]", MaterialItem.GetMaterialTypeString(materialEnum.Current.MaterialType), amount, materialEnum.Current.Amount));
                }
            }
        return(info.AsEnumerable());
    }