コード例 #1
0
        public void GetCompletedLinesTestNoArgs()
        {
            BlockGrid grid = CompleteLinesInitialize();

            List <int> lineIndexes = grid.GetCompletedLines();

            Assert.AreEqual(2, lineIndexes.Count);
        }
コード例 #2
0
        public void GetCompletedLinesTestWithGameShape()
        {
            BlockGrid grid = CompleteLinesInitialize();
            GameShape gs   = new SquareShape(new Block(4, 3), defaultOri);

            grid.PlaceShape(gs);

            List <int> lineIndexes = grid.GetCompletedLines(gs);


            Assert.AreEqual(2, lineIndexes.Count);
        }
コード例 #3
0
        //Called after shape placed:
        //===> Update GameState (Score, lines, level) + reset line
        private void UpdateGameState(BlockGrid grid)
        {
            //CHECK FOR GAMEOVER
            GameShape activeShape = TryActivateGameShape();

            if (activeShape == null)
            {
                //GAME OVER -- Shutdown... (or start reset game?)
                GameOver();
            }
            else
            {
                // Tell BlockGrid whether new lines cleared
                List <int> cl = grid.GetCompletedLines();
                grid.RemoveLines(cl);
                state.totalLinesCleared += cl.Count;
                state.currentLevel       = levelManager.UpdateLevel(state.totalLinesCleared);
                state.currentScore       = scoreManager.UpdateScore(cl.Count, state.currentLevel);
                lineCycleTimer.ResetTimer();
            }
        }
コード例 #4
0
        public void RemoveMultipleLinesTest()
        {
            List <Vector2> expectedPoints;
            BlockGrid      grid = RemoveLinesInitialize(out expectedPoints);

            //Get indexes of lines to remove
            List <int> lineIndexes = grid.GetCompletedLines();

            //Remove lines and shift above blocks down
            grid.RemoveLines(lineIndexes);

            //check that blocks removed and remaining above blocks shifted down
            List <Vector2> points = grid.GetOccupiedCoordinates();

            foreach (Vector2 p in expectedPoints)
            {
                //check if p in expected points
                if (!points.Contains(p))
                {
                    Assert.Fail("Block at point: {0}, {1} not found on grid", p.X, p.Y);
                }
            }
        }