本文整理汇总了C#中IRandom.RandomRange方法的典型用法代码示例。如果您正苦于以下问题:C# IRandom.RandomRange方法的具体用法?C# IRandom.RandomRange怎么用?C# IRandom.RandomRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRandom
的用法示例。
在下文中一共展示了IRandom.RandomRange方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDecorationAt
private void CreateDecorationAt(int blockX, int blockY, int blockZ, IRandom random)
{
int trunkLength = random.RandomRange(6, 10);
// Trunk
CreateColumnAt(blockX, blockY, blockZ, trunkLength, BlockType.Dirt);
// Leaves
CreateSphereAt(blockX, blockY, blockZ + trunkLength, random.RandomRange(3, 4));
}
示例2: CreateDecorationAt
private void CreateDecorationAt(int blockX, int blockY, int blockZ, IRandom random)
{
//PALM TREES
int trunkLength = random.RandomRange(6, 10);
// Trunk
for (int z = blockZ + 1; z <= blockZ + trunkLength; z++)
{
CreateTrunkAt(blockX, blockY, z);
}
CreateCrossAt(blockX, blockY, blockZ + trunkLength, random.RandomRange(2, 3));
///PALM TREES
//
}
示例3: IsAValidLocationforDecoration
private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, IRandom random)
{
if (random.RandomRange(1, 1000) < 999)
{
return false;
}
return IsLocationLowEnough(blockZ) && TheSpaceHereIsEmpty(blockX, blockY, blockZ);
}
示例4: IsAValidLocationforDecoration
private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, IRandom random)
{
if (random.RandomRange(0, 10000) < 9995)
{
return false;
}
if (!TheSpaceHereIsEmpty(blockX, blockY, blockZ - 1))
{
return false;
}
return true;
}
示例5: IsAValidLocationforDecoration
/// <summary>
/// Determines if a tree decoration even wants to be at this location.
/// </summary>
/// <param name="blockX"></param>
/// <param name="blockY"></param>
/// <param name="blockZ"></param>
/// <param name="random"></param>
/// <returns></returns>
private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, IRandom random)
{
// We don't want TOO many trees...make it a 1% chance to be drawn there.
if (random.RandomRange(1, 1000) < 999)
{
return false;
}
if (!IsLocationLowEnough(blockZ))
{
return false;
}
// Trees like to have a minimum amount of space to grow in.
return TheSpaceHereIsEmpty(blockX, blockY, blockZ);
}
示例6: CreateDecorationAt
private void CreateDecorationAt(int blockX, int blockY, int blockZ, IRandom random)
{
//PINE TREES
int trunkLength = random.RandomRange(10, 20);
// Trunk
for (int z = blockZ + 1; z <= blockZ + trunkLength; z++)
{
CreateTrunkAt(blockX, blockY, z);
}
//leaves
for (int z = blockZ + 3; z <= blockZ + trunkLength; z += 2)
{
CreateDiskAt(blockX, blockY, z, (blockZ + trunkLength - z) / 3);
}
CreateLeavesAt(blockX, blockY, blockZ + trunkLength);
}
示例7: IsAValidLocationforDecoration
/// <summary>
/// Determines if a tree decoration even wants to be at this location.
/// </summary>
/// <param name="blockX"></param>
/// <param name="blockY"></param>
/// <param name="blockZ"></param>
/// <param name="random"></param>
/// <returns></returns>
private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, IRandom random)
{
// We don't want TOO many trees...make it a 1% chance to be drawn there.
if (random.RandomRange(1, 1000) < 999)
{
return false;
}
// Trees don't like to grow too high
if (blockZ >= m_WorldData.DepthInBlocks - 20)
{
return false;
}
// Trees like to have a minimum amount of space to grow in.
return SpaceAboveIsEmpty(blockX, blockY, blockZ, 8, 2, 2);
}