Beispiel #1
0
 void PlaceBlock()
 {
     moving = false;
     scoreAndLevel.AddScore(addScoreAmount);
     for (int i = 0; i < blocks.Length; i++)
     {
         level.CheckHeight(blocks[i]);
         level.TakeSpace(blocks[i]);
     }
     level.CheckLineFull();
     spawn.CreateBlock();
 }
Beispiel #2
0
    public void CheckLineFull()
    {
        int          i = 0;
        List <float> fullRowPositions = new List <float>();
        List <int>   rowFull          = new List <int>();
        float        bottomToTop      = bottom - 0.5f + 1.0f;

        while (bottomToTop < top)
        {
            rowFull.Add(0);
            for (int j = 0; j < gridTaken.Count; j++)
            {
                if (gridTaken[j].transform.position.y == bottomToTop)
                {
                    rowFull[i]++;
                    if (rowFull[i] >= gridWidth)
                    {
                        fullRowPositions.Add(bottomToTop);
                    }
                }
            }
            bottomToTop++;
            i++;
        }
        //Remove the objects
        for (int j = 0; j < fullRowPositions.Count; j++)
        {
            for (int k = 0; k < gridTaken.Count; k++)
            {
                if (gridTaken[k].transform.position.y == fullRowPositions[j])
                {
                    Destroy(gridTaken[k]);
                    scoreAndLevel.AddScore(15);
                }
            }
        }

        //Move down above
        for (int j = fullRowPositions.Count - 1; j >= 0; j--)
        {
            for (int m = 0; m < gridTaken.Count; m++)
            {
                if (gridTaken[m].transform.position.y > fullRowPositions[j])
                {
                    gridTaken[m].transform.Translate(0, -1, 0);
                }
            }
        }
    }