本文整理汇总了C#中Person.ListInventory方法的典型用法代码示例。如果您正苦于以下问题:C# Person.ListInventory方法的具体用法?C# Person.ListInventory怎么用?C# Person.ListInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.ListInventory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleCraftInteraction
private void HandleCraftInteraction(string[] commandWords, Person actor)
{
var gatherItemName = commandWords[3];
var hasWood = false;
var hasIron = false;
var itemType = commandWords[2];
foreach (var item in actor.ListInventory())
{
if (item is Iron)
{
hasIron = true;
}
else if (item is Wood)
{
hasWood = true;
}
}
if (itemType == "weapon" && hasIron && hasWood)
{
AddToPerson(actor, new Weapon(gatherItemName));
}
else if (itemType == "armor" && hasIron)
{
AddToPerson(actor, new Armor(gatherItemName));
}
}
示例2: HadleGatherInteraction
private void HadleGatherInteraction(Person actor, string ItemName)
{
var actorInventory = actor.ListInventory();
var IsGatherType = actor.Location as IGatheringLocation;
if (IsGatherType != null)
{
foreach (var actorInv in actorInventory)
{
if (actorInv.ItemType == IsGatherType.RequiredItem)
{
var createItem = IsGatherType.ProduceItem(ItemName);
this.AddToPerson(actor,createItem);
break;
}
}
}
}
示例3: CraftWeapon
private void CraftWeapon(Person actor, string craftItemName)
{
var actorInventory = actor.ListInventory();
if (actorInventory.Any((item) => item.ItemType == ItemType.Iron && item.ItemType == ItemType.Wood))
{
this.AddToPerson(actor, new Weapon(craftItemName, null));
}
}
示例4: HandleTravelInteraction
private void HandleTravelInteraction(string[] commandWords, Person actor)
{
var traveller = actor as ITraveller;
if (traveller != null)
{
var targetLocation = this.locationByName[commandWords[2]];
peopleByLocation[traveller.Location].Remove(actor);
traveller.TravelTo(targetLocation);
peopleByLocation[traveller.Location].Add(actor);
foreach (var item in actor.ListInventory())
{
item.UpdateWithInteraction("travel");
}
}
}
示例5: HandleSellInteraction
private void HandleSellInteraction(string[] commandWords, Person actor)
{
Item saleItem = null;
string saleItemName = commandWords[2];
foreach (var item in actor.ListInventory())
{
if (ownerByItem[item] == actor && saleItemName == item.Name)
{
saleItem = item;
}
}
var buyer = personByName[commandWords[3]] as Shopkeeper;
if (buyer != null &&
peopleByLocation[actor.Location].Contains(buyer))
{
var price = buyer.CalculateBuyingPrice(saleItem);
moneyByPerson[buyer] -= price;
moneyByPerson[actor] += price;
this.RemoveFromPerson(actor, saleItem);
this.AddToPerson(buyer, saleItem);
saleItem.UpdateWithInteraction("sell");
}
}
示例6: HandleListInventoryInteraction
private void HandleListInventoryInteraction(Person actor)
{
var inventory = actor.ListInventory();
foreach (var item in inventory)
{
if (ownerByItem[item] == actor)
{
Console.WriteLine(item.Name);
item.UpdateWithInteraction("inventory");
}
}
if (inventory.Count == 0)
{
Console.WriteLine("empty");
}
}
示例7: HandleDropInteraction
private void HandleDropInteraction(Person actor)
{
foreach (var item in actor.ListInventory())
{
if (ownerByItem[item] == actor)
{
strayItemsByLocation[actor.Location].Add(item);
this.RemoveFromPerson(actor, item);
item.UpdateWithInteraction("drop");
}
}
}
示例8: HandleGatherInteraction
private void HandleGatherInteraction(string[] commandWords,Person actor)
{
var gatherItemName = commandWords[2];
var hasWeapon = false;
var hasArmor = false;
foreach (var item in actor.ListInventory())
{
if (item is Weapon)
{
hasWeapon = true;
}
else if (item is Armor)
{
hasArmor = true;
}
}
if (actor.Location.LocationType == LocationType.Forest && hasWeapon)
{
AddToPerson(actor, new Wood(gatherItemName));
}
else if (actor.Location.LocationType == LocationType.Mine && hasArmor)
{
AddToPerson(actor, new Iron(gatherItemName));
}
}
示例9: HandleGatherInteraction
private void HandleGatherInteraction(string[] commandWords, Person actor)
{
bool hasWeapon = false;
bool hasArmor = false;
foreach (var item in actor.ListInventory())
{
if (item is Weapon)
{
hasWeapon = true;
}
if (item is Armor)
{
hasArmor = true;
}
}
Location currentLocation = DetermineActorLocation(actor);
if (hasWeapon && actor.Location.LocationType == LocationType.Forest)
{
Item gatheredItem = new WoodItem(commandWords[2], currentLocation);
actor.AddToInventory(gatheredItem);
this.AddToPerson(actor, gatheredItem);
}
if (hasArmor && actor.Location.LocationType == LocationType.Mine)
{
Item gatheredItem = new IronItem(commandWords[2], currentLocation);
actor.AddToInventory(gatheredItem);
this.AddToPerson(actor, gatheredItem);
}
}
示例10: HandleCraftInteraction
private void HandleCraftInteraction(string[] commandWords, Person actor)
{
string targetItemType = commandWords[2];
var itemsInActorInventory = actor.ListInventory();
bool canCraft = false;
bool hasIron = false;
bool hasWood = false;
Location currentLocation = DetermineActorLocation(actor);
foreach (var item in itemsInActorInventory)
{
if (item is IronItem)
{
hasIron = true;
}
if (item is WoodItem)
{
hasWood = true;
}
}
switch (targetItemType)
{
case "armor":
if (hasIron)
{
Item gatheredItem = new Armor(commandWords[3], currentLocation);
actor.AddToInventory(gatheredItem);
this.AddToPerson(actor, gatheredItem);
}
break;
case "weapon":
if (hasIron && hasWood)
{
Item gatheredItem = new Weapon(commandWords[3], currentLocation);
actor.AddToInventory(gatheredItem);
this.AddToPerson(actor, gatheredItem);
}
break;
default:
break;
}
}