Exemplo n.º 1
0
    private int Points(int row)
    {
        int points = ConfigurationUtils.Points;

        for (int i = 1; i < width - 3; i++)
        {
            int seguidas = 1;
            for (int j = i + 1; j < width - 1; j++)
            {
                if (MatriceUtils.Compare(i, row, j, row))
                {
                    seguidas++;
                }
                else
                {
                    i = j - 1;
                    break;
                }
            }
            if (seguidas >= 3)
            {
                points += seguidas * ConfigurationUtils.BonusPerColors;
            }
        }
        return(points);
    }
Exemplo n.º 2
0
    private void HandleCheckRowsEvent(string nothing)
    {
        int points        = 0,
            multiplicador = -1;

        for (int row = 1; row < width - 1; row++)
        {
            if (MatriceUtils.FullRow(row))
            {
                multiplicador++;
                points += Points(row);
                MatriceUtils.EmptyRow(row);
                unityEvents[EventName.DestroyBlockEvent].Invoke(row.ToString());
            }
            else if (MatriceUtils.RowIsEmpty(row))
            {
                break;
            }
        }

        if (multiplicador >= 0)
        {
            AudioManager.Play(AudioClipName.Points);
            points += multiplicador * ConfigurationUtils.BonusPerRow;
            unityEvents[EventName.PointsEvent].Invoke(points.ToString());
            Invoke("ReajustarMatriz", ConfigurationUtils.TimeDownBlocks);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Comprueba si la posicion dada se encuentra ocupada
    /// </summary>
    /// <para>
    /// Transforma en posiciones locales de la matriz
    /// </para>
    /// <param name="positionX">Posicion del eje X en el espacio mundo</param>
    /// <param name="positionY">Posicion del eje Y en el spacio mundo</param>
    /// <returns>True si esta ocupado y False en caso contrario</returns>
    private bool Stop(float positionX, float positionY)
    {   // Transforma los valores en valores locales de la matriz
        float y = Mathf.Abs(table.transform.position.y) + positionY;
        float x = Mathf.Abs(table.transform.position.x) + positionX;

        return(MatriceUtils.GetPosition(new Vector2(x, y)) != ColorName.empty);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Agrega el bloque a la matriz
    /// </summary>
    /// <para>
    /// Toma en cuenta la posicion del objeto
    /// y la transforma a posiciones locales de la matriz
    /// </para>
    private void Add()
    {
        // Transforma los valores en valores locales de la matriz
        float x = Mathf.Abs(table.transform.position.x) + rigidbody2D.position.x;
        float y = Mathf.Abs(table.transform.position.y) + rigidbody2D.position.y;

        MatriceUtils.SetPosition(new Vector2(x, y), color);
    }
Exemplo n.º 5
0
    private void Awake()
    {
        MatriceUtils.Initialize();

        width     = MatriceUtils.Width;
        height    = MatriceUtils.Height;
        tolerance = ConfigurationUtils.Tolerance;

        CreateWalls();
        Grid();
    }
Exemplo n.º 6
0
 private void CreateWalls()
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             if (x == 0 || x == width - 1 || y == 0)
             {
                 Vector3 position = new Vector3(x, y);
                 Instantiate(square, transform.position + position,
                             Quaternion.identity, transform);
                 MatriceUtils.SetPosition(position, ColorName.wall);
             }
         }
     }
 }
Exemplo n.º 7
0
 private void ReajustarMatriz()
 {
     for (int row = 1; row < height - 2; row++)
     {
         if (MatriceUtils.RowIsEmpty(row))
         {
             int bajar  = 1,
                 rowAux = row + 1;
             while (MatriceUtils.RowIsEmpty(rowAux) && rowAux < height - 1)
             {
                 bajar++;
                 rowAux++;
             }
             string datos = rowAux.ToString() + bajar.ToString();
             unityEvents[EventName.DownBlockEvent].Invoke(datos);
             MatriceUtils.DownRows(row, bajar);
         }
     }
 }