Esempio n. 1
0
    /// <summary>
    /// Dels the column cluster.
    /// </summary>
    /// <returns>
    /// The column cluster.
    /// </returns>
    /// <param name='_from'>
    /// _from.
    /// </param>
    /// <param name='_to'>
    /// _to.
    /// </param>
    /// <param name='column'>
    /// Column.
    /// </param>
    /// <param name='_matrix'>
    /// _matrix.
    /// </param>
    GameObject[,] DelColumnCluster(int _from, int _to, int column, GameObject[,] _matrix)
    {
        int count = _to - _from + 1;                                                                                                                    //lenght of the cluster

        gameControllerScript.BubblesDestroyed(count);
        GameObject[] buffer = new GameObject[count];

        int a = 0;

        for (int i = _from; i <= _to; i++)
        {
            buffer[a] = _matrix[column, i];

            GameObject someBlast = (GameObject)Instantiate(bubbleBlast, buffer[a].transform.position, buffer[a].transform.rotation);        //TODO: Make colors of blast same as bubbles
            //someBlast.particleSystem.renderer.material.color = buffer[a].renderer.material.color;                                                      //Don't work http://answers.unity3d.com/questions/347675/how-to-change-particle-systems-color-over-lifetime.html
            //someBlast.particleSystem.Play();
            //Hide cluster of bubbles
            BubbleController bubbleScript = buffer[a].GetComponent <BubbleController>();
            bubbleScript.Hide(bubbleFadeTime);


            a++;
        }



        for (int i = _to; i - count >= 0; i--)
        {
            _matrix[column, i] = _matrix[column, i - count];

            Vector3          pos          = new Vector3(column * (bubbleRadius * 2 + bubbleInterval), i * (bubbleRadius * 2 + bubbleInterval));
            BubbleController bubbleScript = _matrix[column, i].GetComponent <BubbleController>();                                                                        //relocate the bubbles
            bubbleScript.targetPos     = pos;
            bubbleScript.isMoving      = true;
            bubbleScript.speedOfMoving = bubbleMovingSpeed;
        }

        for (int i = 0; i < count; i++)
        {
            _matrix[column, i] = buffer[i];
            Vector3 pos = new Vector3(column * (bubbleRadius * 2 + bubbleInterval), i * (bubbleRadius * 2 + bubbleInterval));                           //Position in the local space
            _matrix[column, i].transform.localPosition = pos;
            _matrix[column, i].renderer.material.color = RandColor();

            BubbleController bubbleScript = _matrix[column, i].GetComponent <BubbleController>();
            _matrix[column, i].transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            bubbleScript.speedOfScaling             = bubbleScalingSpeed;
            bubbleScript.targetRadius = bubbleRadius;
            bubbleScript.isScaling    = true;

            a++;
        }

        return(_matrix);
    }
Esempio n. 2
0
    /// <summary>
    /// Dels the row cluster.
    /// </summary>
    /// <returns>
    /// The same size bubble matrix
    /// </returns>
    /// <param name='_from'>
    /// Number from column
    /// </param>
    /// <param name='_to'>
    /// Number till column
    /// </param>
    /// <param name='row'>
    /// The row number
    /// </param>
    /// <param name='_matrix'>
    /// The bubble matrix
    /// </param>
    GameObject[,] DelRowCluster(int _from, int _to, int row, GameObject[,] _matrix)
    {
        int count = _to - _from + 1;                                                                                                                    //lenght of the cluster

        gameControllerScript.BubblesDestroyed(count);

        GameObject[] buffer = new GameObject[count];

        Debug.Log("columns from " + _from + " to " + _to + " row " + row);

        int a = 0;                                                                                                                                                                                                          //buffer counter

        for (int i = _from; i <= _to; i++)
        {                                                                                                                                                                                           //Fill the buffer
            buffer[a] = _matrix[i, row];

            GameObject someBlast = (GameObject)Instantiate(bubbleBlast, buffer[a].transform.position, buffer[a].transform.rotation);        //TODO: Make colors of blast same as bubbles
            //someBlast.particleSystem.renderer.material.color = buffer[a].renderer.material.color;                                                      //Don't work http://answers.unity3d.com/questions/347675/how-to-change-particle-systems-color-over-lifetime.html
            //omeBlast.particleSystem.Play();
            //buffer[a].renderer.enabled = false;												                                            //Hide cluster of bubbles
            BubbleController bubbleScript = buffer[a].GetComponent <BubbleController>();
            bubbleScript.Hide(bubbleFadeTime);


            a++;
        }

        //IMPORTANT i > 0 exclusive 0;
        for (int i = row; i > 0; i--)
        {
            for (int j = _from; j <= _to; j++)
            {
                _matrix[j, i] = _matrix[j, i - 1];

                Vector3          pos          = new Vector3(j * (bubbleRadius * 2 + bubbleInterval), i * (bubbleRadius * 2 + bubbleInterval));
                BubbleController bubbleScript = _matrix[j, i].GetComponent <BubbleController>();                                                         //relocate the bubbles
                bubbleScript.targetPos     = pos;
                bubbleScript.isMoving      = true;
                bubbleScript.speedOfMoving = bubbleMovingSpeed;
                //_matrix[j,i].transform.localPosition = pos;
            }
        }

        a = 0;
        for (int i = _from; i <= _to; i++)
        {                                                                                                                                               //realase the buffer
            _matrix[i, 0] = buffer[a];
            Vector3 pos = new Vector3(i * (bubbleRadius * 2 + bubbleInterval), 0.0f);                                                                   //Position in the local space
            _matrix[i, 0].transform.localPosition = pos;
            _matrix[i, 0].renderer.material.color = RandColor();

            BubbleController bubbleScript = _matrix[i, 0].GetComponent <BubbleController>();
            _matrix[i, 0].transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            bubbleScript.speedOfScaling        = bubbleScalingSpeed;
            bubbleScript.targetRadius          = bubbleRadius;
            bubbleScript.isScaling             = true;
            //_matrix[i,0].renderer.enabled = true;
            a++;
        }

        return(_matrix);
    }