Exemple #1
0
        /// <summary>
        /// When the timer ticks the autodrop happens
        /// </summary>
        void autodrop_initiated(object sender, ElapsedEventArgs e)
        {
            bool isValid = blockLogic.moveCurrentShapeDown("STEP");

            //mainWindow.appendMatrixToDebug();
            if (mainWindow.isConnectedAsClient)
            {
                mainWindow.client.sendMsgToClient(blockLogic.objectToSend);
            }
            if (mainWindow.isConnectedAsServer)
            {
                mainWindow.server.sendMsgToClient(blockLogic.objectToSend);
            }
            if (isValid)
            {
            }               //mainWindow.redrawMatrix(mainWindow.graphicsObj2);
            else
            {
                mainWindow.isGameStarted = false;
                autodrop.Enabled         = false;
                mainWindow.drawMyMatrix(mainWindow.graphicsObj2);
                mainWindow.drawString();
            }
        }
Exemple #2
0
        internal bool moveCurrentShapeDown(string type)
        {
            int[,] shape = new int[3, 4];
            int[] removedPs   = new int[10];
            bool  isFinalMove = false;

            shape = getShape(currentShape, currentRotation);

            if (type == "SNAP")
            {
                myScore.addInstaDropBonus(20 - currentAnchorRow);
                while (!isFinalMove)
                {
                    isFinalMove = applyMoveDown(shape);
                }
            }
            else
            {
                isFinalMove = applyMoveDown(shape);
            }

            if (isFinalMove)
            {
                int clearedLinesThisDrop = 0;
                int iCanStillRemove      = removeOrNotAndWhat(tet_constants.gameMatrix);
                while (iCanStillRemove != -1)
                {
                    removedPs = doTheRemove(tet_constants.gameMatrix, iCanStillRemove);
                    for (int i = 0; i < 10; i++)
                    {
                        if (removedPs[i] == 'p')
                        {
                            myScore.addStarBonus();
                        }
                    }
                    clearedLinesThisDrop++;
                    iCanStillRemove = removeOrNotAndWhat(tet_constants.gameMatrix);
                }

                if (clearedLinesThisDrop != 0)
                {
                    myScore.addScoringMove(clearedLinesThisDrop);
                    clearedLines += clearedLinesThisDrop;
                }
                else
                {
                    myScore.addNonScoringMove();
                }

                usedShapesNr++;

                mainWindow.drawMyMatrix(mainWindow.graphicsObj1);

                mainWindow.drawMyScore(mainWindow.graphicsObj1);

                objectToSend.enemyScore = myScore.getScore();

                if (!pushNewPiece())
                {
                    return(false);
                }
            }

            return(true);
        }