当前位置: 首页>>代码示例>>C#>>正文


C# Person.ListInventory方法代码示例

本文整理汇总了C#中TradeAndTravel.Person.ListInventory方法的典型用法代码示例。如果您正苦于以下问题:C# Person.ListInventory方法的具体用法?C# Person.ListInventory怎么用?C# Person.ListInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TradeAndTravel.Person的用法示例。


在下文中一共展示了Person.ListInventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleGatherInteraction

 private void HandleGatherInteraction(string[] commandWords, Person actor)
 {
     if (actor.Location is Forest && actor.ListInventory().Any(item => item is Weapon))
     {
        this.AddToPerson(actor, new Wood(commandWords[2]));
     }
     else if (actor.Location is Mine && actor.ListInventory().Any(item => item is Armor))
     {
         this.AddToPerson(actor, new Iron(commandWords[2]));
     }
 }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:11,代码来源:WorkAndTravelInteractionManager.cs

示例2: HandleCraftInteraction

        private void HandleCraftInteraction(string itemNameString, string itemTypeString, Person actor)
        {
            if (itemTypeString == "weapon" && actor.ListInventory().Any(item => item is Iron) && (actor.ListInventory().Any(item => item is Wood)))
            {
                this.AddToPerson(actor, new Weapon(itemNameString));
            }

            if (itemTypeString == "armor" && actor.ListInventory().Any(item => item is Iron))
            {
                this.AddToPerson(actor, new Armor(itemNameString));
            }
        }
开发者ID:NikolaPineda,项目名称:Telerik,代码行数:12,代码来源:ExtendedInteractionManager.cs

示例3: CraftWeapon

 private void CraftWeapon(string newItemName, Person actor)
 {
     var ironItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Iron);
     var woodItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Wood);
     if (ironItems != null && woodItems != null && ironItems.Count() > 0 && woodItems.Count() > 0)
     {
         var item = new Weapon(newItemName, null);
         actor.AddToInventory(item);
         ownerByItem.Add(item, actor);
         item.UpdateWithInteraction("craft");
     }                       
 }
开发者ID:krstan4o,项目名称:TelerikAcademy,代码行数:12,代码来源:ExtendedIteractionManager.cs

示例4: HandleCraftInteraction

 private void HandleCraftInteraction(string[] commandWords, Person actor)
 {
     if (actor.ListInventory().Any(item => item is Iron))
     {
         if (commandWords[2] == "weapon" && actor.ListInventory().Any(item => item is Wood))
         {
             this.AddToPerson(actor, new Weapon(commandWords[3]));
         }
         else if (commandWords[2] == "armor")
         {
             this.AddToPerson(actor, new Armor(commandWords[3]));
         }
     }
 }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:14,代码来源:WorkAndTravelInteractionManager.cs

示例5: HandleCraftInteraction

        private void HandleCraftInteraction(string[] commandWords, Person actor)
        {
            var craftedItemType = commandWords[2];
            string craftedItemName = commandWords[3];
            Item theNewCraftedItem = null;
            var actorInventory = actor.ListInventory();

            if (craftedItemType == "weapon")
            {
                bool hasWood = PossessTheRequiredItem(actorInventory, ItemType.Wood);
                bool hasIron = PossessTheRequiredItem(actorInventory, ItemType.Iron);

                if (hasWood && hasIron)
                {
                    theNewCraftedItem = new Weapon(craftedItemName);
                    this.AddToPerson(actor, theNewCraftedItem);
                    theNewCraftedItem.UpdateWithInteraction("craft");
                }
            }
            else if (craftedItemType == "armor")
            {
                bool hasIron = PossessTheRequiredItem(actorInventory, ItemType.Iron);

                if (hasIron)
                {
                    theNewCraftedItem = new Armor(craftedItemName);
                    this.AddToPerson(actor, theNewCraftedItem);
                    theNewCraftedItem.UpdateWithInteraction("craft");
                }
            }
        }
开发者ID:BorislavIvanov,项目名称:Telerik_Academy,代码行数:31,代码来源:ModifiedInteractionManager.cs

示例6: HandleCraftInteraction

        private void HandleCraftInteraction(Person actor, string[] commandWords)
        {
            var inventory = actor.ListInventory();

            bool hasIron = false;
            bool hasWood = false;

            foreach (var item in inventory)
            {
                if (item is Iron)
                {
                    hasIron = true;
                }
                else if (item is Wood)
                {
                    hasWood = true;
                }
            }

            if (commandWords[2] == "armor" && hasIron)
            {
                this.AddToPerson(actor, new Armor(commandWords[3], actor.Location));
            }
            else if (commandWords[2] == "weapon" && hasIron && hasWood)
            {
                this.AddToPerson(actor, new Weapon(commandWords[3], "weapon", actor.Location));
            }
        }
开发者ID:nikolay-radkov,项目名称:Telerik-Academy,代码行数:28,代码来源:ImprovedInteractionManger.cs

示例7: HandleGatherInteraction

 private void HandleGatherInteraction(string itemNameString, Person actor)
 {
     var gatherLoc = actor.Location as IGatheringLocation;   
     if (gatherLoc != null && actor.ListInventory().Any(item => item.ItemType == gatherLoc.RequiredItem))
     {
         this.AddToPerson(actor, gatherLoc.ProduceItem(itemNameString));
     }
 }
开发者ID:NikolaPineda,项目名称:Telerik,代码行数:8,代码来源:ExtendedInteractionManager.cs

示例8: HandleCraftInteraction

 public void HandleCraftInteraction(Person person, string itemType, string newItemName)
 {
     if (itemType == "weapon")
     {
         if (person.ListInventory().Exists(x => x.ItemType == ItemType.Iron) && person.ListInventory().Exists(x => x.ItemType == ItemType.Wood))
         {
             this.AddToPerson(person, new Weapon(newItemName, null));
         }
     }
     else if (itemType == "armor")
     {
         if (person.ListInventory().Exists(x => x.ItemType == ItemType.Iron))
         {
             this.AddToPerson(person, new Armor(newItemName, null));
         }
     }
 }
开发者ID:dirk-dagger-667,项目名称:telerik-c--OOP-exam-prep,代码行数:17,代码来源:InteractionManagerExtended.cs

示例9: CraftArmor

 private void CraftArmor(Person actor, string craftedItemName)
 {
     var actorInventory = actor.ListInventory();
     if (actorInventory.Any((item) => item.ItemType == ItemType.Iron))
     {
         this.AddToPerson(actor, new Armor(craftedItemName));
     }
 }
开发者ID:valkanov,项目名称:TelerikAcademy,代码行数:8,代码来源:AdvancedInteractionManager.cs

示例10: HandleGatherInteraction

 public void HandleGatherInteraction(Person person, string newItemName)
 {
     if (person.Location.LocationType == LocationType.Forest)
     {
         if (person.ListInventory().Exists(x => x.ItemType == ItemType.Weapon))
         {
             this.AddToPerson(person, new Wood(newItemName, null));
         }
     }
     else if (person.Location.LocationType == LocationType.Mine)
     {
         if (person.ListInventory().Exists(x => x.ItemType == ItemType.Armor))
         {
             this.AddToPerson(person, new Iron(newItemName, null));
         }
     }
 }
开发者ID:dirk-dagger-667,项目名称:telerik-c--OOP-exam-prep,代码行数:17,代码来源:InteractionManagerExtended.cs

示例11: HandleCraftInteraction

 private void HandleCraftInteraction(Person actor, string name)
 {
     if (actor.ListInventory().Exists(x => x is Iron))
     {
         if (actor.ListInventory().Exists(x => x is Weapon))
         {
             var item = new Weapon(name);
             actor.AddToInventory(item);
             this.AddToPerson(actor, item);
             return;
         }
         else
         {
             var item = new Armor(name);
             actor.AddToInventory(item);
             this.AddToPerson(actor, item);
         }
     }
 }
开发者ID:TeeeeeC,项目名称:TelerikAcademy2015-2016,代码行数:19,代码来源:EntensionInteractionManager.cs

示例12: HandleGatherInteraction

        protected void HandleGatherInteraction(Person actor, string newName)
        {
            if (actor.Location is IGatheringLocation)
            { 
                var gatheringLocation = actor.Location as IGatheringLocation;

                if (actor.ListInventory().Any(x => x.ItemType == gatheringLocation.RequiredItem))
                {
                    this.AddToPerson(actor, gatheringLocation.ProduceItem(newName));
                }
            }
        }
开发者ID:AndrewMitev,项目名称:Telerik-Academy,代码行数:12,代码来源:ExtendedInteractionManager.cs

示例13: HandleGatherInteraction

        private void HandleGatherInteraction(string name, Person actor)
        {
            if (actor.Location is IGatheringLocation)
            {
                var location = actor.Location as IGatheringLocation;

                if (actor.ListInventory().Any(i => i.ItemType == location.RequiredItem))
                {
                    AddToPerson(actor, location.ProduceItem(name));
                }
            }
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:12,代码来源:CustiomInteractionManager.cs

示例14: HandleCraftInteraction

        private void HandleCraftInteraction(string[] commandWords, Person actor)
        {
            string craftItemType = commandWords[2];
            string craftItemName = commandWords[3];

            if (craftItemType == "armor")
            {
                bool hasIron = false;

                foreach (var item in actor.ListInventory())
                {
                    if (item.ItemType == ItemType.Iron)
                    {
                        hasIron = true;
                        break;
                    }
                }

                if (hasIron)
                {
                    var addedItem = new Armor(craftItemName);
                    this.AddToPerson(actor, addedItem);
                    addedItem.UpdateWithInteraction("craft");
                }
            }

            if (craftItemType == "weapon")
            {
                bool hasWood = false;
                bool hasIron = false;

                foreach (var item in actor.ListInventory())
                {
                    if (item.ItemType == ItemType.Wood)
                    {
                        hasWood = true;
                    }
                    else if (item.ItemType == ItemType.Iron)
                    {
                        hasIron = true;
                    }
                }

                if (hasWood && hasIron)
                {
                    var addedItem = new Weapon(craftItemName);
                    this.AddToPerson(actor, addedItem);
                    addedItem.UpdateWithInteraction("craft");
                }
            }
        }
开发者ID:jesconsa,项目名称:Telerik-Academy,代码行数:51,代码来源:ExtendedInteractionManager.cs

示例15: 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");
                }
            }
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:16,代码来源:InteractionManager.cs


注:本文中的TradeAndTravel.Person.ListInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。