Exemplo n.º 1
0
        public void DeleteRows(TetroGrid grid, Cell[,] cells)
        {
            this.grid = grid;
            List <int> fullRowIndexs = new List <int>();

            int[][] cellMoveDistance = GetDistanceArray(cells.GetLength(0), cells.GetLength(1));

            for (int i = 0; i < cells.GetLength(1); i++)
            {
                fullRowIndexs.Add(i);
                for (int j = 0; j < cells.GetLength(0); j++)
                {
                    if (grid.IsCellEmpty(j, i))
                    {
                        fullRowIndexs.Remove(i);
                        break;
                    }
                }
            }
            if (fullRowIndexs.Count <= 0)
            {
                EventManager.TriggerEvent(EventNames.GridFinishedUpdating, new Message(0.0f));
                return /*false*/;
            }

            foreach (int row in fullRowIndexs)
            {
                DeleteRow(row);
                cellMoveDistance = AddOneAboveRow(cellMoveDistance, row);
            }
            EventManager.TriggerEvent(EventNames.RowCompleted, new Message(fullRowIndexs.Count));

            StartCoroutine(WaitAndMoveCells(grid.GameSettings.RowFallDelay, cellMoveDistance));
            //return true;
        }
Exemplo n.º 2
0
 private void Awake()
 {
     spawner = FindObjectOfType <Spawner>();
     grid    = FindObjectOfType <TetroGrid>();
 }