Ejemplo n.º 1
0
        uint AppearanceTimeDifference = 500; //aiming for 50ms here
        public PrimaryBlockAppearanceState(GameplayGameState startupState)
        {
            SortedList <Guid, Blocks.LineSeriesPrimaryBlock> appearanceshuffler = new SortedList <Guid, Blocks.LineSeriesPrimaryBlock>();

            StandardState = startupState;
            //set all Primary Blocks to invisible and force a redraw.

            var field = StandardState.PlayField.Contents;

            for (int x = 0; x < StandardState.PlayField.ColCount; x++)
            {
                for (int y = 0; y < StandardState.PlayField.RowCount; y++)
                {
                    var block = field[y][x];
                    if (block is Blocks.LineSeriesPrimaryBlock lsmb)
                    {
                        lsmb.Visible = false;
                        appearanceshuffler.Add(Guid.NewGuid(), lsmb);
                    }
                }
            }
            AppearanceBlocks = new Queue <Blocks.LineSeriesPrimaryBlock>(appearanceshuffler.Values);
            StandardState.PlayField.HasChanged = true; //since we made them all invisible I'd say that counts as a change!
            LastAppearanceTick = TetrisGame.GetTickCount();
        }
Ejemplo n.º 2
0
 public override void GameProc(IStateOwner pOwner)
 {
     if (FirstTick == 0)
     {
         FirstTick = TetrisGame.GetTickCount();
     }
     PausedState.GameProc(pOwner);
     if (((TetrisGame.GetTickCount() - FirstTick) > PauseTicks))
     {
         Resume(pOwner);
     }
 }
Ejemplo n.º 3
0
        public override void GameProc(IStateOwner pOwner)
        {
            //if the timeout has elapsed, make another one visible.
            var currtick = TetrisGame.GetTickCount();
            var tickdiff = currtick - LastAppearanceTick;

            if (tickdiff > AppearanceTimeDifference)
            {
                if (AppearanceBlocks.Count == 0)
                {
                    if (StandardState.NoTetrominoSpawn)
                    {
                        StandardState.NoTetrominoSpawn = false;
                    }
                    StandardState.PlayField.ClearActiveBlockGroups();
                    pOwner.CurrentState = StandardState;

                    return;
                }
                var nextAppear = AppearanceBlocks.Dequeue();
                nextAppear.Visible = true;
                StandardState.PlayField.HasChanged = true;
            }
        }
Ejemplo n.º 4
0
 private static uint GetTickCount()
 {
     return(TetrisGame.GetTickCount());
 }