本文整理汇总了C#中Bag.GetItemAmount方法的典型用法代码示例。如果您正苦于以下问题:C# Bag.GetItemAmount方法的具体用法?C# Bag.GetItemAmount怎么用?C# Bag.GetItemAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bag
的用法示例。
在下文中一共展示了Bag.GetItemAmount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInventoryGetSum1
public void TestInventoryGetSum1()
{
var inventory = new Bag();
Item item1 = new Item();
item1.Id = Guid.NewGuid();
item1.Name = "a";
item1.Weight = 10;
item1.Count = 9;
item1.Effects = new Effect[0];
inventory.Add(item1);
Item item2 = new Item();
item2.Id = Guid.NewGuid();
item2.Name = "a";
item2.Weight = 10;
item2.Count = 11;
item2.Effects = new Effect[0];
inventory.Add(item2);
var amount = inventory.GetItemAmount("a");
Assert.AreEqual(20, amount);
}
示例2: TestInventoryGetSum5
public void TestInventoryGetSum5()
{
var inventory = new Bag();
Item item1 = new Item();
item1.Id = Guid.NewGuid();
item1.Name = "a";
item1.Weight = 10;
item1.Count = 1;
item1.Effects = new Effect[] { new Effect() { Type = EFFECT_TYPE.ATTACK_ADD } };
inventory.Add(item1);
Item item2 = new Item();
item2.Id = Guid.NewGuid();
item2.Name = "a";
item2.Weight = 10;
item2.Count = 1;
item2.Effects = new Effect[] { new Effect() { Type = EFFECT_TYPE.ATTACK_ADD } };
inventory.Add(item2);
inventory.Remove("a", 2);
var amount = inventory.GetItemAmount("a");
Assert.AreEqual(0, amount);
}