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


C# Person.AddToInventory方法代码示例

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


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

示例1: CraftArmor

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

示例2: 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

示例3: AddToPerson

 protected void AddToPerson(Person actor, Item item)
 {
     actor.AddToInventory(item);
     ownerByItem[item] = actor;
 }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:5,代码来源:InteractionManager.cs

示例4: HandleGatherInteraction

        private void HandleGatherInteraction(Person actor, string itemName)
        {
            //Gathering means a Person takes an item from a special location
            //A Person should be able to gather from mines and from forests
            //A Person can gather from a forest only if he has a Weapon in his inventory
            //Gathering from a forests results in adding a Wood item in the Person’s inventory
            //A Person can gather from a mine only if he has an Armor in his inventory
            //Gathering from a mine results in adding an Iron item in the Person’s inventory
            //Syntax: Joro gather newItemName – gathers an item, naming it newItemName if the Person Joro is at a mine or forest, and respectively has an Armor or Weapon

            if (actor.Location.LocationType == LocationType.Forest && actor.ListInventory().Any(a => a.GetType() == typeof(Weapon)))
            {
                Wood a = new Wood(itemName);
                base.AddToPerson(actor, a);
                actor.AddToInventory(new Wood(itemName));
            }

            if (actor.Location.LocationType == LocationType.Mine && actor.ListInventory().Any(a => a.GetType() == typeof(Armor)))
            {
                Iron a = new Iron(itemName);
                base.AddToPerson(actor, a);
                actor.AddToInventory(new Iron(itemName));
            }
        }
开发者ID:VDGone,项目名称:TelerikAcademy-2,代码行数:24,代码来源:UpdatedInteractionManager.cs

示例5: HandleCraftInteraction

 private void HandleCraftInteraction(Person actor, string itemToCraft, string itemName)
 {
     //A Person can craft items, provided he has some items in his inventory
     //A Person should be able to craft Weapons and Armor
     //Crafting an Armor requires that the Person has Iron in his inventory
     //Results in adding an Armor item in the Person’s inventory
     //Crafting a Weapon requires that the Person has Iron and Wood in his inventory
     //Syntax: Joro craft weapon/armor newItemName - gathers an item, naming it newItemName if the Person Joro has the necessary
     switch (itemToCraft)
     {
         case "armor":
             if (actor.ListInventory().Any(a => a.GetType() == typeof(Iron)))
             {
                 Armor armor = new Armor(itemName);
                 base.AddToPerson(actor, armor);
                 actor.AddToInventory(new Armor(itemName));
             }
             break;
         case "weapon":
             if (actor.ListInventory().Any(a => a.GetType() == typeof(Iron)) && actor.ListInventory().Any(a => a.GetType() == typeof(Wood)))
             {
                 Weapon weapon = new Weapon(itemName);
                 base.AddToPerson(actor, weapon);
                 actor.AddToInventory(new Weapon(itemName));
             }
             break;
         default:
             break;
     }
 }
开发者ID:VDGone,项目名称:TelerikAcademy-2,代码行数:30,代码来源:UpdatedInteractionManager.cs

示例6: HandleGatherInteraction

        private void HandleGatherInteraction(Person actor, string itemName)
        {
            var actorItems = actor.ListInventory();

            for (int i = 0; i < actorItems.Count; i++)
            {
                if (actorItems[i] is Weapon && actor.Location is Forest)
                {
                    var item = new Wood(itemName);
                    actor.AddToInventory(item);
                    this.ownerByItem.Add(item, actor);
                    return;
                }
                else if (actorItems[i] is Armor && actor.Location is Mine)
                {
                    var item = new Iron(itemName);
                    actor.AddToInventory(item);
                    this.ownerByItem.Add(item, actor);
                    return;
                }
            }
        }
开发者ID:razsilev,项目名称:TelerikAcademy_Homework,代码行数:22,代码来源:Program.cs

示例7: HandleCraftInteraction

 private void HandleCraftInteraction(Person actor, string itemType, string itemName)
 {
     if (actor.ListInventory().Find(i => i is Iron) != null)
     {
         if (itemType == "weapon" && actor.ListInventory().Find(i => i is Wood) != null)
         {
             var item = new Weapon(itemName);
             actor.AddToInventory(item);
             this.ownerByItem.Add(item, actor);
         }
         else if (itemType == "armor")
         {
             var item = new Armor(itemName);
             actor.AddToInventory(item);
             this.ownerByItem.Add(item, actor);
         }
     }
 }
开发者ID:razsilev,项目名称:TelerikAcademy_Homework,代码行数:18,代码来源:Program.cs

示例8: HandleGatherInteraction

        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            if (actor.Location.LocationType == LocationType.Forest)
            {
                var inventoryItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Weapon);
                if (inventoryItems != null && inventoryItems.Count() > 0)
                {
                    var item = new Wood(commandWords[2], null);
                    actor.AddToInventory(item);
                    ownerByItem.Add(item, actor);
                    item.UpdateWithInteraction("gather");
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                var inventoryItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Armor);
                if (inventoryItems != null && inventoryItems.Count() > 0)
                {
                    var item = new Iron(commandWords[2], null);
                    actor.AddToInventory(item);
                    ownerByItem.Add(item, actor);
                }
            }

        }
开发者ID:krstan4o,项目名称:TelerikAcademy,代码行数:25,代码来源:ExtendedIteractionManager.cs

示例9: HandleGatherInteraction

        private void HandleGatherInteraction(Person actor, string name)
        {
            var locationForest = actor.Location as Forest;
            if (locationForest is Forest)
            {
                if (actor.ListInventory().Exists(x => x is Weapon))
                {
                    var item = new Wood(name, actor.Location);
                    actor.AddToInventory(item);
                    this.AddToPerson(actor, item);
                }
            }

            var locationMine = actor.Location as Mine;
            if (locationMine is Mine)
            {
                if (actor.ListInventory().Exists(x => x is Armor))
                {
                    var item = new Iron(name, actor.Location);
                    actor.AddToInventory(item);
                    this.AddToPerson(actor, item);
                }
            }
        }
开发者ID:TeeeeeC,项目名称:TelerikAcademy2015-2016,代码行数:24,代码来源:Program.cs


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