本文整理汇总了C#中Inventory.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.GetItems方法的具体用法?C# Inventory.GetItems怎么用?C# Inventory.GetItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory.GetItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseLuckyEgg
public static async Task UseLuckyEgg(Client client, Inventory inventory, StateMachine machine)
{
var inventoryContent = await inventory.GetItems();
var luckyEggs = inventoryContent.Where(p => p.ItemId == ItemId.ItemLuckyEgg);
var luckyEgg = luckyEggs.FirstOrDefault();
if (luckyEgg == null || luckyEgg.Count <= 0 || _lastLuckyEggTime.AddMinutes(30).Ticks > DateTime.Now.Ticks)
return;
_lastLuckyEggTime = DateTime.Now;
await client.Inventory.UseItemXpBoost();
var refreshCachedInventory = await inventory.RefreshCachedInventory();
machine.Fire(new UseLuckyEggEvent {Count = luckyEgg.Count});
await Task.Delay(2000);
}
示例2: UseLuckyEgg
public static void UseLuckyEgg(Client client, Inventory inventory, StateMachine machine)
{
var inventoryContent = inventory.GetItems().Result;
var luckyEggs = inventoryContent.Where(p => p.ItemId == ItemId.ItemLuckyEgg);
var luckyEgg = luckyEggs.FirstOrDefault();
if (luckyEgg == null || luckyEgg.Count <= 0)
return;
client.Inventory.UseItemXpBoost().Wait();
luckyEgg.Count -= 1;
machine.Fire(new UseLuckyEggEvent {Count = luckyEgg.Count});
Thread.Sleep(2000);
}
示例3: RetrieveItemDescriptions
/*
* Retrieve all the owned items and get the description of each
* including the correct price if user is buying or selling.
*/
private string[] RetrieveItemDescriptions (Inventory inventory)
{
string[] itemTexts = new string[inventory.GetItems ().Count];
int index = 0;
Item item;
foreach (int itemID in inventory.GetItems().Keys) {
item = itemDB.GetItem (itemID);
itemTexts [index] = item.itemName + "\n";
if (state == ShopState.BUYING) {
itemTexts [index] += String.Format ("Price: {0}\n\n", item.price);
} else if (state == ShopState.SELLING) {
itemTexts [index] += String.Format ("Price: {0}\n\n", item.sellPrice);
}
itemTexts [index] += item.description;
index++;
}
return itemTexts;
}
示例4: RetrieveItemNames
/*
* Retrieve all the owned items and get the item names to display in
* the shopping gui.
*/
private string[] RetrieveItemNames (Inventory inventory)
{
string[] itemNames = new string[inventory.GetItems ().Count];
int index = 0;
Item item;
foreach (int itemID in inventory.GetItems().Keys) {
item = itemDB.GetItem (itemID);
itemNames [index] = item.itemName;
index++;
}
return itemNames;
}