本文整理汇总了C#中Aura.Channel.World.Entities.Creature.GetProductionSuccessChance方法的典型用法代码示例。如果您正苦于以下问题:C# Creature.GetProductionSuccessChance方法的具体用法?C# Creature.GetProductionSuccessChance怎么用?C# Creature.GetProductionSuccessChance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.Channel.World.Entities.Creature
的用法示例。
在下文中一共展示了Creature.GetProductionSuccessChance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Complete
//.........这里部分代码省略.........
// Cancel if one item matches multiple materials.
// It's unknown how this would be handled, can it even
// happen? Can one item maybe only be used as one material?
if (inUse.Contains(material.Item.EntityId))
{
Send.ServerMessage(creature, Localization.Get("Unable to handle request, please report, with this information: ({0}/{1})."), material.Item.Info.Id, productData.Id);
Log.Warning("ProductionSkill.Complete: Item '{0}' matches multiple materials for product '{1}'.", material.Item.Info.Id, productData.Id);
goto L_Fail;
}
var reduce = Math.Min(reqMat.Amount, material.Item.Amount);
reqMat.Amount -= reduce;
toReduce.Add(new ProductionMaterial(material.Item, reduce));
inUse.Add(material.Item.EntityId);
}
// Break once we got what we need
if (reqMat.Amount == 0)
break;
}
}
if (requiredMaterials.Any(a => a.Amount != 0))
{
// Unofficial, the client should normally prevent this.
Send.ServerMessage(creature, Localization.Get("Insufficient materials."));
goto L_Fail;
}
// Check success
var rank = skill.Info.Rank <= SkillRank.R1 ? skill.Info.Rank : SkillRank.R1;
var baseChance = potentialProducts.Sum(a => a.SuccessRates[rank]);
var rainBonus = productData.RainBonus;
var chance = creature.GetProductionSuccessChance(skill, category, baseChance, rainBonus);
var rnd = RandomProvider.Get();
var success = (rnd.Next(100) < chance);
// Debug
if (creature.Titles.SelectedTitle == TitleId.devCAT)
Send.ServerMessage(creature, "Debug: Chance {0}%", chance);
// Select random product
// Do this here, so we have the data for skill training,
// no matter the outcome.
if (potentialProducts.Length > 1)
{
var itemId = 0;
var num = rnd.NextDouble() * baseChance;
var n = 0.0;
foreach (var potentialProduct in potentialProducts)
{
n += potentialProduct.SuccessRates[rank];
if (num <= n)
{
itemId = potentialProduct.ItemId;
productData = potentialProduct;
break;
}
}
// Sanity check
if (itemId == 0)
{
Log.Error("ProductionSkill.Complete: Failed to select random product item for {0}/{1}, num: {2}.", category, productId, num);
Send.ServerMessage(creature, "Failed to generate product.");
goto L_Fail;