Пример #1
0
        public void RemoveRow(bool addScore)
        {
            List <int>   rowRemoves = gridModel.FindEmptyRow();
            List <float> tempPos    = new List <float>();

            foreach (var VARIABLE in gridModel.Grid)
            {
                tempPos.Add(0);
            }
            for (int i = 0; i < rowRemoves.Count; i++)
            {
                for (int j = rowRemoves[i] * gridModel.Cols; j < gridModel.Grid.Count; j++)
                {
                    tempPos[j] += GridTransform.GetComponent <GridLayoutGroup>().cellSize.y;
                }
            }
            bool one = true;

            for (int i = 0; i < rowRemoves.Count; i++)
            {
                GridTransform.GetComponent <GridLayoutGroup>().enabled   = false;
                GridTransform.GetComponent <ContentSizeFitter>().enabled = false;
                if (addScore)
                {
                    PlusScore(gridModel.Grid[rowRemoves[i] * gridModel.Cols].GetView().transform.position, 50);
                }
                gridModel.DestroyRowView(rowRemoves[i]);
                if (one)
                {
                    for (int j = 0; j < gridModel.Grid.Count; j++)
                    {
                        if (gridModel.Grid[j].GetView() != null)
                        {
                            gridModel.Grid[j].GetView().DoMove(
                                new Vector3(gridModel.Grid[j].GetView().transform.localPosition.x,
                                            gridModel.Grid[j].GetView().transform.localPosition.y +
                                            tempPos[j], 0), 0.2f);
                        }
                    }
                }
                one = false;
                //_cellViews
                gridModel.ChangeIndexAfterRowDestroy(rowRemoves[i]);
                gridModel.RemoveBadIndex(rowRemoves[i]);
                gridModel.Rows--;
            }
            CheckGameEnd();
        }