Ejemplo n.º 1
0
    void SpawnInShape(GameObject _wave)
    {
        for (int i = 0; i < spawnPositions.Length; i++)
        {
            int    _shapeID = Random.Range(0, smScript.shapes.Length);
            string _shape   = GetShapeTag(_shapeID);

            for (int j = 0; j < smScript.pooledShapes.Count; j++)
            {
                if (smScript.pooledShapes[j].tag == _shape)
                {
                    if (!smScript.pooledShapes[j].activeInHierarchy)
                    {
                        GameObject _chosenShape = smScript.pooledShapes[j];

                        _chosenShape.GetComponent <SpriteRenderer>().enabled = true;
                        _chosenShape.GetComponent <SpriteRenderer>().color   = ObjectColour();

                        _chosenShape.transform.parent        = _wave.transform;
                        _chosenShape.transform.localPosition = spawnPositions[i];

                        _chosenShape.SetActive(true);
                        currentWaveType = waveType.border;
                        break;
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Start()
    {
        frequencySlider = GameObject.Find("FrequencySlider").GetComponent <Slider> ();
        offsetSlider    = GameObject.Find("OffsetSlider").GetComponent <Slider> ();
//		lowPassFilter = GameObject.Find ("lowPassFilter").GetComponent<AudioLowPassFilter> ();
//		lowPassFilter = this.GetComponent<AudioLowPassFilter> ();
        frequency = frequencySlider.value;
        offset    = offsetSlider.value;

        soundWave = waveType.Saw;
    }
Ejemplo n.º 3
0
    void SpawnInBorder(GameObject _wave)
    {
        for (int i = 0; i < spawnPositions.Length; i++)
        {
            int    _shapeID = Random.Range(0, smScript.borders.Length);
            string _shape   = GetShapeTag(_shapeID);

            for (int j = 0; j < smScript.pooledBorders.Count; j++)
            {
                if (smScript.pooledBorders[j].tag == _shape)
                {
                    if (!smScript.pooledBorders[j].activeInHierarchy)
                    {
                        GameObject _chosenShape = smScript.pooledBorders[j];

                        _chosenShape.GetComponent <SpriteRenderer>().color = ObjectColour();

                        _chosenShape.transform.parent        = _wave.transform;
                        _chosenShape.transform.localPosition = spawnPositions[i];

                        bool hasHeart = false;
                        bool hasStar  = false;


                        if (lmScript.numOfLives < 3)
                        {
                            hasHeart = isHealthPickUpActive();
                        }

                        if (!hasHeart)
                        {
                            hasStar = isStarPickUpActive();
                        }

                        _chosenShape.SetActive(true);

                        if (hasHeart)
                        {
                            ActivatePickUp(_chosenShape.transform.GetChild(0).gameObject);
                        }

                        if (hasStar)
                        {
                            ActivatePickUp(_chosenShape.transform.GetChild(1).gameObject);
                        }

                        currentWaveType = waveType.shape;
                        break;
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void setWave(waveType wave)
    {
        WaveForm = wave;
        switch (wave)
        {
        case waveType.Sine:
            osc = new Sine();
            break;

        case waveType.Square:
            osc = new Square();
            break;

        case waveType.Tri:
            osc = new Triangle();
            break;

        case waveType.Saw:
            osc = new Sawtooth();
            break;
        }
    }
Ejemplo n.º 5
0
        public override int Read(short[] buffer, int offset,
          int sampleCount)
        {

            switch (currentType)
            {
                case waveType.SineWave:
                    {
                        for (int index = 0; index < sampleCount; index++)
                        {
                            buffer[offset + index] =
                              (short)(Amplitude * Math.Sin(phaseAngle));
                            if (!isDrawBufferFull)
                            {
                                drawBuffer[index] = buffer[offset + index];
                            }
                            phaseAngle +=
                              2 * Math.PI * Frequency / WaveFormat.SampleRate;

                            if (phaseAngle > 2 * Math.PI)
                                phaseAngle -= 2 * Math.PI;
                        }
                        isDrawBufferFull = true;
                        break;
                    }
                case waveType.triangleWave:
                    {
                        for (int index = 0; index < sampleCount; index++)
                        {
                            buffer[offset + index] =
                              (short)(Amplitude * phaseAngle);
                            if (!isDrawBufferFull)
                            {
                                drawBuffer[index] = buffer[offset + index];
                            }
                            //why 2 here?
                            phaseAngle += 2 * Frequency / WaveFormat.SampleRate;

                            if (phaseAngle > 1)
                                phaseAngle -= 2;
                        }
                        isDrawBufferFull = true;
                        break;
                    }
                case waveType.rectangleWave:
                    {
                        for (int index = 0; index < sampleCount; index++)
                        {
                            buffer[offset + index] =
                                (short)(Amplitude * (phaseAngle > 0 ? 1 : -1));
                            if (!isDrawBufferFull)
                            {
                                drawBuffer[index] = buffer[offset + index];
                            }
                            phaseAngle += 2 * Frequency / WaveFormat.SampleRate;

                            if (phaseAngle > 1)
                                phaseAngle -= 2;
                        }
                        isDrawBufferFull = true;
                        break;
                    }
                case waveType.whiteNoiseWave:
                    {
                        int randomMaxValue = 1000;
                        int halfRandomMaxValue = randomMaxValue / 2;
                        int doubleRandomMaxValue = randomMaxValue * 2;
                        Random r = new Random();
                        for (int index = 0; index < sampleCount; index++)
                        {
                            buffer[offset + index] =
                                (short)((double)Amplitude * (double)(r.Next(randomMaxValue) - halfRandomMaxValue) / doubleRandomMaxValue);
                            if (!isDrawBufferFull)
                            {
                                drawBuffer[index] = buffer[offset + index];
                            }
                        }
                        isDrawBufferFull = true;
                        break;
                    }
                case waveType.zero:
                    break;
                default:
                    this.currentType = waveType.zero;
                    break;
            }
            return sampleCount;
        }
Ejemplo n.º 6
0
    void SpawnInBorder(GameObject _wave)
    {
        for (int i = 0; i < spawnPositions.Length; i++)
        {
            int _shapeID = Random.Range(0, smScript.borders.Length);
            string _shape = GetShapeTag(_shapeID);

            for (int j = 0; j < smScript.pooledBorders.Count; j++)
            {
                if (smScript.pooledBorders[j].tag == _shape)
                {
                    if (!smScript.pooledBorders[j].activeInHierarchy)
                    {
                        GameObject _chosenShape = smScript.pooledBorders[j];

                        _chosenShape.GetComponent<SpriteRenderer>().color = ObjectColour();

                        _chosenShape.transform.parent = _wave.transform;
                        _chosenShape.transform.localPosition = spawnPositions[i];

                        bool hasHeart = false;
                        bool hasStar = false;                       


                        if(lmScript.numOfLives < 3)
                        {
                            hasHeart = isHealthPickUpActive();
                        }

                        if (!hasHeart)
                        {
                            hasStar = isStarPickUpActive();
                        }

                        _chosenShape.SetActive(true);

                        if (hasHeart)
                        {
                            ActivatePickUp(_chosenShape.transform.GetChild(0).gameObject);
                        }

                        if (hasStar)
                        {
                            ActivatePickUp(_chosenShape.transform.GetChild(1).gameObject);
                        }

                        currentWaveType = waveType.shape;
                        break;
                    }
                }
            }
        }
    }
Ejemplo n.º 7
0
    void SpawnInShape(GameObject _wave)
    {
        for(int i = 0; i < spawnPositions.Length; i++)
        {
            int _shapeID = Random.Range(0, smScript.shapes.Length);
            string _shape = GetShapeTag(_shapeID);

            for(int j = 0; j < smScript.pooledShapes.Count; j++)
            {
               if(smScript.pooledShapes[j].tag == _shape)
                {
                    if (!smScript.pooledShapes[j].activeInHierarchy)
                    {
                        GameObject _chosenShape = smScript.pooledShapes[j];

                        _chosenShape.GetComponent<SpriteRenderer>().enabled = true;
                        _chosenShape.GetComponent<SpriteRenderer>().color = ObjectColour();

                        _chosenShape.transform.parent = _wave.transform;
                        _chosenShape.transform.localPosition = spawnPositions[i];

                        _chosenShape.SetActive(true);
                        currentWaveType = waveType.border;
                        break;
                    }
                }
            }
        }
    }