void Start()
    {
        Hover hover = GetComponent <Hover>();

        if (usePerlin)
        {
            if (hover != null)
            {
                int     num = Mathf.Min(hover.offsets.Length, hover.oscis.Length);
                Vector3 pos = transform.position;
                pos.x *= .12112f;
                pos.y *= .32131f;
                pos.z *= .51241f;

                pos.x += pos.z;
                pos.y += pos.z * .5f;


                for (int i = 0; i < num; i++)
                {
                    Oscillator osci = hover.oscis[i];

                    osci.maxTime *= time.Perlin(pos.x, pos.y);
                    float val = scale.Perlin(pos.x, pos.y);
                    osci.minVal *= val;
                    osci.maxVal *= val;

                    Vector3 offset = hover.offsets[i];
                    Vector3 scales = new Vector3(offsetx.Perlin(pos.x, pos.y), offsety.Perlin(pos.x, pos.y), offsetz.Perlin(pos.x, pos.y));
                    hover.offsets[i] = Vector3.Scale(offset, scales);

                    if (PerlinNoise.GetValue(pos.x, pos.y) < .5)
                    {
                        hover.offsets[i] *= -1;
                    }
                }
            }
        }
        else
        {
            int oldSeed = Random.seed;
            if (useSeed)
            {
                Random.seed = seed;
            }

            if (hover != null)
            {
                int num = Mathf.Min(hover.offsets.Length, hover.oscis.Length);
                for (int i = 0; i < num; i++)
                {
                    Oscillator osci = hover.oscis[i];

                    osci.maxTime *= time.value;
                    float val = scale.value;
                    osci.minVal *= val;
                    osci.maxVal *= val;

                    Vector3 offset = hover.offsets[i];
                    Vector3 scales = new Vector3(offsetx.value, offsety.value, offsetz.value);
                    hover.offsets[i] = Vector3.Scale(offset, scales);
                    if (Random.value < .5)
                    {
                        hover.offsets[i] *= -1;
                    }
                }
            }

            if (useSeed)
            {
                Random.seed = oldSeed; seed++;
            }
        }
        Destroy(this);
    }
Exemplo n.º 2
0
    void Start()
    {
        HoverRotation hover = GetComponent <HoverRotation>();

        if (hover != null)
        {
            if (usePerlin)
            {
                int     num = Mathf.Min(hover.rotations.Length);
                Vector3 p   = transform.position;
                p.x *= .12112f;
                p.y *= .32131f;
                p.z *= .51241f;

                p.x += p.z;
                p.y += p.z * .5f;

                for (int i = 0; i < num; i++)
                {
                    var        pos  = p + new Vector3(i * .01337f, i * .31337f, i * .73313f);
                    Oscillator osci = hover.oscis[i];

                    if (curTime.randomize)
                    {
                        osci.SetTime(curTime.Perlin(pos.z, pos.x), PerlinNoise.GetValue(pos.y, pos.z) < .5f);
                    }

                    osci.maxTime *= time.Perlin(pos.x, pos.y);
                    osci.curTime  = osci.maxTime * new BMM(true, 0, 1).Perlin(pos.z, pos.x);
                    float val = scale.Perlin(pos.y, pos.z);
                    osci.minVal *= val;
                    osci.maxVal *= val;

                    Vector3 offset = hover.rotations[i];
                    Vector3 scales = new Vector3(offsetx.Perlin(pos.y, pos.z), offsety.Perlin(pos.z, pos.x), offsetz.Perlin(pos.z, pos.y));
                    hover.rotations[i] = Vector3.Scale(offset, scales);

                    if (PerlinNoise.GetValue(pos.x, pos.z) < .5)
                    {
                        hover.rotations[i] *= -1;
                    }
                }
            }
            else
            {
                if (useSeed)
                {
                    Random.Push(seed);
                }
                int num = Mathf.Min(hover.rotations.Length, hover.oscis.Length);
                for (int i = 0; i < num; i++)
                {
                    Oscillator osci = hover.oscis[i];

                    osci.maxTime *= time.value;
                    osci.curTime  = osci.maxTime * Random.value;
                    float val = scale.value;
                    osci.minVal *= val;
                    osci.maxVal *= val;

                    Vector3 offset = hover.rotations[i];
                    Vector3 scales = new Vector3(offsetx.value, offsety.value, offsetz.value);
                    hover.rotations[i] = Vector3.Scale(offset, scales);
                    if (Random.value < .5)
                    {
                        hover.rotations[i] *= -1;
                    }
                }
                if (useSeed)
                {
                    Random.Pop(); seed++;
                }
            }
        }

        Destroy(this);
    }