Exemplo n.º 1
0
    void FixedUpdate()
    {
        Clock += Time.deltaTime;
        if (Clock >= SpawnRate)
        {
            float scale = 10000;
            median = Analyser.GetMedianOfSpectrum() * scale;
            foreach (float frequency in FrequencyList)
            {
                ShipSettings setts = new ShipSettings();
                //lows
                float   currentFreq = frequency;
                Vector3 initial     = GetARandomTreePos();
                initial.x    = Analyser.GetFrequencyVolume(frequency) * scale / 10;
                frequencyNow = initial.x;
                if (initial.x > 15)
                {
                    BulletSettings bSetts = new BulletSettings();
                    bSetts.Damage          = 5;
                    bSetts.Speed           = 3;
                    bSetts.Type            = BulletType.LINEAR;
                    setts.Bullet           = bullet;
                    setts.BulletParameters = bSetts;
                    setts.HitPoints        = 50;
                    setts.MovementSpeed    = 1;
                    setts.RateOfFire       = 0.5f;
                    SpawnBasic(setts, initial, GetEmiterBounds());
                }
                //mids
                currentFreq *= 3;
                setts        = new ShipSettings();
                initial      = GetARandomTreePos();
                initial.x    = Analyser.GetFrequencyVolume(frequency) * scale / 10;
                if (initial.x > 30)
                {
                    BulletSettings bSetts = new BulletSettings();
                    bSetts.Damage          = 5;
                    bSetts.Speed           = 3;
                    bSetts.Type            = BulletType.LINEAR;
                    setts.Bullet           = bullet;
                    setts.BulletParameters = bSetts;
                    setts.HitPoints        = 10;
                    setts.MovementSpeed    = 15;
                    setts.RateOfFire       = 0.5f;
                    SpawnBasic(setts, initial, GetEmiterBounds());
                }
            }

            Clock = 0;
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        float freq        = 32.70f;
        float fundamental = freq;
        int   pitch       = 1;

        foreach (GameObject item in objs)
        {
            float a = Analyser.GetFrequencyVolume(freq);
            item.transform.localScale = Vector3.Lerp(new Vector3(0.5f, 1 * (a * SpectrumScale), 0.5f), item.transform.localScale, Time.deltaTime * smooth);
            float aconst = Mathf.Pow(2.0f, 1.0f / 12.0f);
            float aN     = (Mathf.Pow(aconst, (float)pitch));
            freq = fundamental * aN;
            pitch++;
        }
    }