本文整理汇总了C#中UMAData.SetRace方法的典型用法代码示例。如果您正苦于以下问题:C# UMAData.SetRace方法的具体用法?C# UMAData.SetRace怎么用?C# UMAData.SetRace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMAData
的用法示例。
在下文中一共展示了UMAData.SetRace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetGeneratedUMARace
protected virtual UMACrowdRandomSet.CrowdRaceData SetGeneratedUMARace(UMAData.UMARecipe umaRecipe)
{
if (randomPool != null && randomPool.Length > 0)
{
int randomResult = Random.Range(0, randomPool.Length);
UMACrowdRandomSet.CrowdRaceData race = randomPool[randomResult].data;
umaRecipe.SetRace(raceLibrary.GetRace(race.raceID));
return race;
}
else
{
umaRecipe.SetRace(raceLibrary.GetRace("RACHumanFemale"));
return null;
}
}
示例2: FillUMARecipe
/// <summary>
/// Fills in a UMA recipe with random partial fragments from the sections.
/// </summary>
/// <param name="umaRecipe">UMA recipe.</param>
/// <param name="context">Context.</param>
public void FillUMARecipe(UMAData.UMARecipe umaRecipe, UMAContext context)
{
if (raceData == null)
{
Debug.LogWarning("Race Data must be set!");
return;
}
umaRecipe.SetRace(raceData);
int sectionCount = (recipeSections == null) ? 0 : recipeSections.Length;
for (int i = 0; i < sectionCount; i++)
{
RecipeSection section = recipeSections[i];
if ((section.recipes == null) || (section.recipes.Length == 0))
continue;
switch (section.selectionRule)
{
case SelectionType.IncludeNone:
break;
case SelectionType.IncludeAll:
for (int j = 0; j < section.recipes.Length; j++)
{
IncludeRecipe(section.recipes[j], umaRecipe, context, false);
}
break;
case SelectionType.IncludeSome:
float chance = 1f / (float)(section.recipes.Length + 1);
for (int j = 0; j < section.recipes.Length; j++)
{
if (Random.value < chance)
{
IncludeRecipe(section.recipes[j], umaRecipe, context, false);
}
}
break;
case SelectionType.IncludeOne:
default:
int index = Random.Range(0, section.recipes.Length);
IncludeRecipe(section.recipes[index], umaRecipe, context, false);
break;
}
}
for (int i = 0; i < additionalRecipes.Length; i++)
{
IncludeRecipe(additionalRecipes[i], umaRecipe, context, true);
}
}