コード例 #1
0
 public void NewTrick()
 {
     CurrX     = 6;
     CurrY     = -4;
     CurrTrick = NextTrick;
     NextTrick = new ClassTrick();
     IsChange  = false;
 }
コード例 #2
0
 public void CreatGame()
 {
     NextTrick = new ClassTrick();
     NewTrick();
     if (ShowTrick != null)
     {
         ShowTrick(null, null);
     }
     timer.Tick    += new EventHandler(timer_Tick);
     timer.Interval = speed;
     timer.Start();
     timertime.Tick    += new EventHandler(timertime_Tick);
     timertime.Interval = 1000;
     timertime.Start();
 }
コード例 #3
0
        void game_ShowTrick(object sender, EventArgs e)
        {
            gridTrick.Children.Clear();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (game.CurrY + i < 0)
                    {
                        continue;
                    }
                    if (game.CurrTrick.CurrBlocks[i, j] != null)
                    {
                        Label r = new Label();
                        r.Margin     = new Thickness((game.CurrX + j) * game.Width, (game.CurrY + i) * game.Height, 0, 0);
                        r.Width      = game.Width;
                        r.Height     = game.Height;
                        r.Background = game.CurrTrick.CurrBlocks[i, j].BackBrush;
                        r.Style      = style;
                        gridTrick.Children.Add(r);
                    }
                }
            }
            gridnext.Children.Clear();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (game.NextTrick.CurrBlocks[i, j] != null)
                    {
                        Label r = new Label();
                        r.Margin      = new Thickness((j) * 20, (i) * 20, 0, 0);
                        r.Width       = 20;
                        r.Height      = 20;
                        r.Background  = game.NextTrick.CurrBlocks[i, j].BackBrush;
                        r.BorderBrush = Brushes.Black;
                        r.Style       = style;
                        gridnext.Children.Add(r);
                    }
                }
            }
            gridsave.Children.Clear();
            if (game.SaveTrick != null)
            {
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (game.SaveTrick.CurrBlocks[i, j] != null)
                        {
                            Label r = new Label();
                            r.Margin      = new Thickness((j) * 20, (i) * 20, 0, 0);
                            r.Width       = 20;
                            r.Height      = 20;
                            r.Style       = style;
                            r.Background  = game.SaveTrick.CurrBlocks[i, j].BackBrush;
                            r.BorderBrush = Brushes.Black;
                            gridsave.Children.Add(r);
                        }
                    }
                }
                int cnt = 11;
                for (int i = 1; i <= cnt; i++)
                {
                    if (i % 4 == 1)
                    {
                        //头
                    }

                    //中间内容

                    if (i % 4 == 0 || i == cnt)
                    {
                        //尾
                    }
                }
            }
            gridDockTrick.Children.Clear();
            ClassTrick c = new ClassTrick();

            c.CurrBlocks = game.CurrTrick.CurrBlocks;
            for (int k = 0; k < 20; k++)
            {
                for (int y = 0; y < 4; y++)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        if (k + y + 1 < 0)
                        {
                            continue;
                        }
                        if (c.CurrBlocks[y, x] != null)
                        {
                            //超过了背景
                            if (y + k + 1 >= 20)
                            {
                                for (int i = 0; i < 4; i++)
                                {
                                    for (int j = 0; j < 4; j++)
                                    {
                                        if (c.CurrBlocks[i, j] != null)
                                        {
                                            Label r = new Label();
                                            r.Margin     = new Thickness((game.CurrX + j) * game.Width, (k + i) * game.Height, 0, 0);
                                            r.Width      = game.Width;
                                            r.Height     = game.Height;
                                            r.Background = c.CurrBlocks[i, j].BackBrush;
                                            r.Opacity    = 0.3;
                                            r.Style      = style;
                                            gridDockTrick.Children.Add(r);
                                        }
                                    }
                                }
                                return;
                            }
                            if (x + game.CurrX >= 14)
                            {
                                game.CurrX = 13 - x;
                            }
                            if (game.CurrDeskBlocks[y + k + 1, x + game.CurrX] != null)
                            {
                                for (int i = 0; i < 4; i++)
                                {
                                    for (int j = 0; j < 4; j++)
                                    {
                                        if (c.CurrBlocks[i, j] != null)
                                        {
                                            Label r = new Label();
                                            r.Margin     = new Thickness((game.CurrX + j) * game.Width, (k + i) * game.Height, 0, 0);
                                            r.Width      = game.Width;
                                            r.Height     = game.Height;
                                            r.Background = c.CurrBlocks[i, j].BackBrush;
                                            r.Opacity    = 0.3;
                                            r.Style      = style;
                                            gridDockTrick.Children.Add(r);
                                        }
                                    }
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }