Range() 공개 메소드

public Range ( float min, float max ) : float
min float
max float
리턴 float
 Vector2 RandomVariation(Rand hash, Vector2 reference, float fraction)
 {
     float variationMin = reference.x * fraction;
     float variationMax = reference.y * fraction;
     return new Vector2 (
         hash.Range (reference.x - variationMin, reference.x + variationMin),
         hash.Range (reference.y - variationMax, reference.y + variationMax)
     );
 }
 float RandomVariation(Rand hash, float reference, float fraction)
 {
     float variation = reference * fraction;
     return hash.Range (reference - variation, reference + variation);
 }
    void RandomizeTrees(Rand hash, bool newTheme = true)
    {
        generator.initialLength = RandomVariation (hash, referenceGenerator.initialLength, 0.3f);
        generator.initialWidth = RandomVariation (hash, referenceGenerator.initialWidth, 0.7f);
        generator.smallBranchBias = RandomVariation (hash, referenceGenerator.smallBranchBias, 1.0f);
        generator.turn1 = RandomVariation (hash, referenceGenerator.turn1, 1.3f);
        generator.turn2 = RandomVariation (hash, referenceGenerator.turn2, 1.3f);
        generator.turn3 = RandomVariation (hash, referenceGenerator.turn3, 1.3f);
        generator.roll1 = RandomVariation (hash, referenceGenerator.roll1, 1.3f);
        generator.roll2 = RandomVariation (hash, referenceGenerator.roll2, 1.3f);
        generator.roll3 = RandomVariation (hash, referenceGenerator.roll3, 1.3f);
        generator.lengthScale1 = RandomVariation (hash, referenceGenerator.lengthScale1, 0.3f);
        generator.lengthScale2 = RandomVariation (hash, referenceGenerator.lengthScale2, 0.3f);
        generator.lengthScale3 = RandomVariation (hash, referenceGenerator.lengthScale3, 0.3f);
        generator.lengthScale1 = Clamp (generator.lengthScale1, 0.05f, 0.95f);
        generator.lengthScale2 = Clamp (generator.lengthScale2, 0.05f, 0.95f);
        generator.lengthScale3 = Clamp (generator.lengthScale3, 0.05f, 0.95f);
        generator.e = RandomVariation (hash, referenceGenerator.e, 0.2f);
        generator.branchNo = referenceGenerator.branchNo;
        generator.iter = hash.Range (9, 10+1);

        if (newTheme)
            generator.showLeaves = (hash.value < 0.85f);

        generator.leafMid = RandomVariation (hash, referenceGenerator.leafMid, 0.9f);
        generator.leafRotate = RandomVariation (hash, referenceGenerator.leafRotate, 0.5f);
        generator.gravity = RandomVariation (hash, referenceGenerator.gravity, 1.5f);
    }
    void RandomizePlacement(Rand hash, bool newTheme = true)
    {
        placementSeed = hash.Next () % 1000;

        if (newTheme)
            baseDist = hash.Range (0.50f, 0.75f);

        noiseSize1 = RandomVariation (hash, referenceParameters.noiseSize1, 0.3f);
        noiseSize2 = RandomVariation (hash, referenceParameters.noiseSize2, 0.5f);
        threshold = RandomVariation (hash, referenceParameters.threshold, 0.15f);
        randomness = RandomVariation (hash, referenceParameters.randomness, 0.5f);
        scaleBase = RandomVariation (hash, referenceParameters.scaleBase, 0.3f);
    }
    List<Color> GetPrimaryColors(Color baseColor, Rand hash)
    {
        List<Color> colors = new List<Color> ();
        colors.Add (baseColor);

        Vector4 hsv = ColorUtility.RGBToHSV (baseColor);

        int selector = hash.Range (0, 2);
        if (selector == 0) {
            hsv.x += 0.49f;
            colors.Add (ColorUtility.HSVToRGB (hsv));
        }
        else if (selector == 1) {
            hsv.x += 1/3f;
            colors.Add (ColorUtility.HSVToRGB (hsv));
            hsv.x += 1/3f;
            colors.Add (ColorUtility.HSVToRGB (hsv));
        }

        return colors;
    }
 void AddVariationColors(List<Color> colors, Rand rand)
 {
     int index = rand.Range (0, colors.Count);
     float t = rand.Range (0.3f, 0.7f);
     Color newColor = LerpColorInHSV (
         colors[index],
         colors[(index + 1) % colors.Count],
         t
     );
     colors.Add (newColor);
 }