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


C# Person.ListInventory方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:tima-t,项目名称:Telerik-Academy,代码行数:29,代码来源:InteractionManagerExtended.cs

示例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;
                    }
                }

            }
        }
开发者ID:Producenta,项目名称:TelerikAcademy,代码行数:18,代码来源:Program.cs

示例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));
     }
 }
开发者ID:Producenta,项目名称:TelerikAcademy,代码行数:8,代码来源:Program.cs

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

示例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");
            }
        }
开发者ID:Producenta,项目名称:TelerikAcademy,代码行数:25,代码来源:Program.cs

示例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");
            }
        }
开发者ID:Producenta,项目名称:TelerikAcademy,代码行数:17,代码来源:Program.cs

示例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");
                }
            }
        }
开发者ID:Producenta,项目名称:TelerikAcademy,代码行数:13,代码来源:Program.cs

示例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));
            }
        }
开发者ID:tima-t,项目名称:Telerik-Academy,代码行数:27,代码来源:InteractionManagerExtended.cs

示例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);
        }
    }
开发者ID:NikolovNikolay,项目名称:Exam-Tasks,代码行数:34,代码来源:Program.cs

示例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;
        }
    }
开发者ID:NikolovNikolay,项目名称:Exam-Tasks,代码行数:44,代码来源:Program.cs


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