本文整理汇总了C#中Server.Engines.Craft.CraftSystem.ConsumeOnFailure方法的典型用法代码示例。如果您正苦于以下问题:C# CraftSystem.ConsumeOnFailure方法的具体用法?C# CraftSystem.ConsumeOnFailure怎么用?C# CraftSystem.ConsumeOnFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Engines.Craft.CraftSystem
的用法示例。
在下文中一共展示了CraftSystem.ConsumeOnFailure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConsumeRes
public bool ConsumeRes( Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure )
{
Container ourPack = from.Backpack;
if ( ourPack == null )
return false;
if ( m_NeedHeat && !Find( from, m_HeatSources ) )
{
message = 1044487; // You must be near a fire source to cook.
return false;
}
if ( m_NeedOven && !Find( from, m_Ovens ) )
{
message = 1044493; // You must be near an oven to bake that.
return false;
}
if ( m_NeedMill && !Find( from, m_Mills ) )
{
message = 1044491; // You must be near a flour mill to do that.
return false;
}
Type[][] types = new Type[m_arCraftRes.Count][];
int[] amounts = new int[m_arCraftRes.Count];
maxAmount = int.MaxValue;
CraftSubResCol resCol = ( m_UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes );
for ( int i = 0; i < types.Length; ++i )
{
CraftRes craftRes = m_arCraftRes.GetAt( i );
Type baseType = craftRes.ItemType;
// Resource Mutation
if ( (baseType == resCol.ResType) && ( typeRes != null ) )
{
baseType = typeRes;
CraftSubRes subResource = resCol.SearchFor( baseType );
if ( subResource != null && from.Skills[craftSystem.MainSkill].Base < subResource.RequiredSkill )
{
message = subResource.Message;
return false;
}
}
// ******************
for ( int j = 0; types[i] == null && j < m_TypesTable.Length; ++j )
{
if ( m_TypesTable[j][0] == baseType )
types[i] = m_TypesTable[j];
}
if ( types[i] == null )
types[i] = new Type[]{ baseType };
amounts[i] = craftRes.Amount;
// For stackable items that can ben crafted more than one at a time
if ( UseAllRes )
{
int tempAmount = ourPack.GetAmount( types[i] );
tempAmount /= amounts[i];
if ( tempAmount < maxAmount )
{
maxAmount = tempAmount;
if ( maxAmount == 0 )
{
CraftRes res = m_arCraftRes.GetAt( i );
if ( res.MessageNumber > 0 )
message = res.MessageNumber;
else if ( !String.IsNullOrEmpty( res.MessageString ) )
message = res.MessageString;
else
message = 502925; // You don't have the resources required to make that item.
return false;
}
}
}
// ****************************
if ( isFailure && !craftSystem.ConsumeOnFailure( from, types[i][0], this ) )
amounts[i] = 0;
}
// We adjust the amount of each resource to consume the max posible
if ( UseAllRes )
{
for ( int i = 0; i < amounts.Length; ++i )
amounts[i] *= maxAmount;
}
else
//.........这里部分代码省略.........
示例2: ConsumeRes
//.........这里部分代码省略.........
{
CraftRes res = m_arCraftRes.GetAt( i );
if ( res.MessageNumber > 0 )
message = res.MessageNumber;
else if ( !String.IsNullOrEmpty( res.MessageString ) )
message = res.MessageString;
else
message = 502925; // You don't have the resources required to make that item.
if (craftSystem is DefInscription)
{
from.LocalOverheadMessage(MessageType.Regular, 0x22, true, "More reagents are needed for this spell.");
}
else if (craftSystem is DefTinkering)
{
if (baseType == typeof(Bolt))
from.SendAsciiMessage("You need a crossbow bolt to make that trap!");
else if (baseType == typeof(BaseExplosionPotion))
from.SendAsciiMessage("You need a purple potion to make that trap!");
else if (baseType == typeof(BasePoisonPotion))
from.SendAsciiMessage("You need a green potion to make that trap!");
else
from.SendAsciiMessage("You don't have the resources required to make that item.");
}
else
from.SendAsciiMessage("You don't have the resources required to make that item.");
return false;
}
}
}
// ****************************
if ( isFailure && !craftSystem.ConsumeOnFailure( from, types[i][0], this ) )
amounts[i] = 0;
}
// We adjust the amount of each resource to consume the max posible
if ( UseAllRes )
{
for ( int i = 0; i < amounts.Length; ++i )
amounts[i] *= maxAmount;
}
else
maxAmount = -1;
Item consumeExtra = null;
if ( m_NameNumber == 1041267 )
{
// Runebooks are a special case, they need a blank recall rune
List<RecallRune> runes = ourPack.FindItemsByType<RecallRune>();
for ( int i = 0; i < runes.Count; ++i )
{
RecallRune rune = runes[i];
if ( rune != null && !rune.Marked )
{
consumeExtra = rune;
break;
}
}
if ( consumeExtra == null )