本文整理汇总了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() + '.'); }
}
示例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); }
}