示例#1
0
        public void AddBlock(Gameblock gb)
        {
            if (gb != null)
            {
                App app = this.Workingsheet.Application;
                app.ScreenUpdating = false;
                Shape[] shapes = gb.BlockShape;
                foreach (Shape s in shapes)
                {
                    int x = (int)s.Left;
                    int y = (int)s.Top;
                    this.BlocksShape[y / RowWidth][x / RowWidth] = s;
                    SetValue(y / RowWidth + 1, x / RowWidth + 1, 1);
                }
                int stop  = 0;
                int count = 0;
                for (int i = 0; i < RowNum; ++i)
                {
                    if (IsFUllRow(i + 1))
                    {
                        if (stop == 0)
                        {
                            stop = i;
                        }
                        this.SpaceData[i] = 0;
                        for (int j = 0; j < ColNum; ++j)
                        {
                            this.BlocksShape[i][j]?.Delete();
                        }
                        count++;
                    }
                    else
                    {
                        if (stop != 0)
                        {
                            break;
                        }
                    }
                }
                if (count != 0)
                {
                    for (int r = stop + count - 1; r >= 0; --r)
                    {
                        if (r - count < 0)
                        {
                            for (int j = 0; j < ColNum; ++j)
                            {
                                this.BlocksShape[r][j] = null;
                            }
                        }
                        else
                        {
                            for (int j = 0; j < ColNum; ++j)
                            {
                                this.BlocksShape[r][j] = this.BlocksShape[r - count][j];
                                if (this.BlocksShape[r][j] != null)
                                {
                                    BlocksShape[r][j].Top += count * RowWidth;
                                }
                            }
                        }
                    }
                    for (int r = stop + count - 1; r >= 0; --r)
                    {
                        this.SpaceData[r] = r - count < 0 ? 0 : this.SpaceData[r - count];
                    }
                }


                if (count != 0)
                {
                    ClearRows?.Invoke(count);
                }


                app.ScreenUpdating = true;

                if (this.SpaceData[0] > 0)
                {
                    this.GameFailed?.Invoke(0);
                    return;
                }
            }
        }
示例#2
0
 private void AddProcess_Load(object sender, EventArgs e)
 {
     this.AllPr.Rows.Add(50);
     this.AllPr.ClearSelection();
     delegClear = new ClearRows(ClearRowsMethod);
 }