Example #1
0
        public TetrisGamePanel(int row, int col, Worksheet ws)
        {
            InitializeComponent();


            if (GameSheet == null)
            {
                GameSheet = ws;
            }
            RowNum         = row;
            ColNum         = col;
            this.Wplane    = new GamePlane(ws, row, col);
            this.GameTimer = new Timer();

            #region Event Define
            GameTimer.Interval = 120;
            {
                Globals.ThisAddIn.Application.WindowResize += Application_WindowResize;
                GameTimer.Tick    += GameTimer_Tick;
                Wplane.ClearRows  += Wplane_ClearRows;
                Wplane.GameFailed += Wplane_GameFailed;
            }
            #endregion

            RandomNum = new Random();

            CurrentType       = RandomNum.Next(7);
            NextType          = RandomNum.Next(7);
            this.Deactivate  += PauseGame;
            StepWise          = DefStepWise;
            GameTimer.Enabled = false;

            this.CurrentBlock = new Gameblock(ws, col / 2 * Gwidth, -1 * Gwidth, Gwidth, CurrentType, 1);
            textBox1.Text     = Heading + StringShow[NextType];
        }
Example #2
0
 private int Wplane_GameFailed(int Args)
 {
     MessageBox.Show("You lost and the score is " + Score.ToString());
     foreach (Shape s in this.GameSheet.Shapes)
     {
         s.Delete();
     }
     Wplane            = new GamePlane(GameSheet, RowNum, ColNum);
     this.CurrentBlock = new Gameblock(GameSheet, ColNum / 2 * Gwidth, -1 * Gwidth, Gwidth, 1, 1);
     Wplane.Show();
     CurrentBlock.Show();
     return(Args);
 }