Esempio n. 1
0
 private void DropNextBlock()
 {
     if (nextBlock != null)
     {
         if (gameBoard[nextBlockColumn].Count() != NUM_ROWS)
         {
             gameBoard[nextBlockColumn].Insert(0, nextBlock);
             nextBlock.column = nextBlockColumn;
             this.numMovesLeft--;
             nextBlock.Drop();
             nextBlock = null;
             this.dropBlockCount++;
             this.gamePlayState = GamePlayState.dropping;
         }
     }
 }
Esempio n. 2
0
        private void DrawBlock(NumberBlock block, SpriteBatch spriteBatch)
        {
            Texture2D blockSprite = null;
            if (block.blockNumber == -1)
            {
                blockSprite = this.blockIcons[9];
            }
            else
            {
                blockSprite = this.blockIcons[block.blockNumber];
            }

            Color tint = Color.White;
            if (gamePlayState == GamePlayState.removingAnim && block.beingRemoved)
            {
                byte alpha = (byte)(256 - 256* removingTimeout / GetRemoveAnimationTime());
               tint = new Color(Color.Pink, alpha);
            }
            spriteBatch.Draw(blockSprite, block.position, tint);
        }
Esempio n. 3
0
        public void PushNewRow()
        {
            int pushNonBrickProbability = this.settings.pushNonBrickProbability;

            int i = 0;
            foreach (List<NumberBlock> column in this.gameBoard)
            {
                int count = column.Count();
                if (count == NUM_ROWS)
                {
                    GameOver();
                }
                NumberBlock newBlock = null;
                if (rand.Next(100) <= pushNonBrickProbability)
                {
                    newBlock = randomBlock(false);
                }
                else
                {
                    newBlock = new NumberBlock(this);
                    newBlock.blockNumber = 0;
                    newBlock.lockCount = 2;
                }
                newBlock.column = i;
                Components.Add(newBlock);
                column.Insert(column.Count(), newBlock);

                int j = 0;
                int startHeight = (NUM_ROWS - count - 1) * 50 + BOARD_OFFSET_Y;
                foreach (NumberBlock block in column)
                {
                    block.position = new Vector2((BOARD_OFFSET_X + block.column * 50), startHeight + (j+1) * 50);
                    block.destination_y = startHeight + j * 50;
                    block.Float();
                    this.dropBlockCount++;

                    j++;
                }

                i++;
            }
            this.Score(new Vector2(BOARD_OFFSET_X, BOARD_OFFSET_SLOT_Y + 5), this.currLevel * 1000);

            if (gamePlayState != GamePlayState.gameOver)
            {
                if (this.currLevel == 31 && achievementHub.hasAchieved(AchievementHub.ACH_SURVIVOR_MAN) == false)
                {
                    AwardAchievement(AchievementHub.ACH_SURVIVOR_MAN);
                }
                gamePlayState = GamePlayState.dropping;
            }
        }
Esempio n. 4
0
        private void CreateNextBlock(bool cleanQueue)
        {
            int total = 0;
            foreach (List<NumberBlock> col in this.gameBoard)
            {
                total += col.Count();
            }
            if (total == NUM_COLUMNS * NUM_ROWS)
            {
                GameOver();
            }
            else
            {
                if (total == 0)
                {
                    this.Score(new Vector2(BOARD_OFFSET_X + 5, BOARD_OFFSET_SLOT_Y + NUM_ROWS*50 - 20), this.currLevel * 20000);
                    if (achievementHub.hasAchieved(AchievementHub.ACH_CLEAN_SLATE) == false)
                    {
                        AwardAchievement(AchievementHub.ACH_CLEAN_SLATE);
                    }
                }

                if (cleanQueue == true || nextBlockQueue.Count() == 0)
                {
                    nextBlock = randomBlock(false);
                }
                else
                {
                    nextBlock = nextBlockQueue.ElementAt(0);
                    nextBlockQueue.RemoveAt(0);
                    nextBlockQueue.Add(randomBlock(false));
                }

                nextBlock.position.X = BOARD_OFFSET_X + nextBlockColumn * 50;
                nextBlock.position.Y = BOARD_OFFSET_SLOT_Y;
                Components.Add(nextBlock);
            }
        }
Esempio n. 5
0
        private NumberBlock randomBlock(bool allowLockedBlocks)
        {
            NumberBlock returnBlock = new NumberBlock(this);

            if(allowLockedBlocks)
                returnBlock.blockNumber = rand.Next(0,9);
            else
                returnBlock.blockNumber = rand.Next(1, 9);

            if (returnBlock.blockNumber == 0)
            {
                returnBlock.lockCount = 2;
            }
            else if (returnBlock.blockNumber == 9)
            {
                returnBlock.lockCount = 1;
            }
            return returnBlock;
        }