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


C# Thing.CanBeDropped方法代码示例

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


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

示例1: Drop

        /// <summary>
        /// Has the <see cref="Actor"/> try to drop
        /// a given <see cref="Thing"/>.
        /// </summary>
        /// <param name="item">the <see cref="Thing"/> to drop</param>
        /// <exception cref="DroppingItemNotHeldException">
        /// if the <see cref="Thing"/> is not in the <see cref="Actor"/>'s
        /// <see cref="Inventory"/>
        /// </exception>
        /// <exception cref="DroppingCursedUndroppableItemException">
        /// if the <see cref="Thing"/> is cursed/undroppable
        /// </exception>
        public void Drop(Thing item)
        {
            // if the actor isn't carrying the item, throw an exception
            if(!this.Carries(item)) {
                throw new DroppingItemNotHeldException(); }

            // if the item is cursed/undroppable, throw an exception
            if(!item.CanBeDropped()) {
                throw new DroppingCursedUndroppableItemException(); }

            // actor is carrying the item and it is not cursed
            else {
                this.inventory.RemoveThing(item);
                item.SetLocation(this.GetLocation());
                this.GetLocation().AddThing(item);
                GameManager.ReportIfVisible(this, this.GetName() + ' ' +  this.GetConjugatedVerb(VerbSet.ToDrop) + ' ' + item.GetSpecificName() + '.'); }
        }
开发者ID:julia-ford,项目名称:Game-Engine,代码行数:29,代码来源:Actor.cs

示例2: Drop

        /// <summary>
        /// Has the <see cref="Person"/> try to drop
        /// a given <see cref="Thing"/>.
        /// </summary>
        /// 
        /// <param name="item">the <see cref="Thing"/> to drop</param>
        /// 
        /// <exception cref="DroppingItemNotHeldException">
        /// if the <see cref="Thing"/> is not in the <see cref="Person"/>'s
        /// <see cref="Hands"/>
        /// </exception>
        /// 
        /// <exception cref="DroppingCursedUndroppableItemException">
        /// if the <see cref="Thing"/> is cursed/undroppable
        /// </exception>
        public override void Drop(Thing item)
        {
            // if the actor isn't carrying the item, throw an exception
            if(!this.Carries(item)) {
                throw new DroppingItemNotHeldException(); }

            // if the item is cursed/undroppable, throw an exception
            if(!item.CanBeDropped()) {
                throw new DroppingCursedUndroppableItemException(); }

            // actor is carrying the item and it is not cursed
            else {
                this.hands.RemoveThing(item);
                item.SetLocation(this.GetLocation());
                this.GetLocation().AddThing(item);
                GameManager.ReportIfVisible(this, VerbSet.ToDrop, item); }
        }
开发者ID:julia-ford,项目名称:Game-Engine,代码行数:32,代码来源:Person.cs


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