예제 #1
0
 private bool PreviousLineHasPieces(PiecesLine line)
 {
     if (line.IsRoof)
     {
         return(false);
     }
     return(lines[line.Index - 1].HasPiece);
 }
예제 #2
0
        public static PiecesLine EmptyLine(int index, int amount)
        {
            var pl = new PiecesLine(index, true, false);

            for (int i = 0; i < amount; i++)
            {
                pl.Add(null);
            }
            return(pl);
        }
예제 #3
0
        public void StepDown()
        {
            CurrentStep++;

            for (int i = lines.Count - 1; i >= 0; i--)
            {
                lines[i].StepDown();
            }

            if (lines[lines.Count - CurrentStep].HasPiece)
            {
                mGameEngine.GameOver();
            }

            lines.Insert(0, PiecesLine.EmptyLine(0, MAX_PIECES_PER_LINE));
            lines.RemoveAt(lines.Count - 1);
        }
예제 #4
0
        private void CreateBoard()
        {
            for (var i = 0; i < MAX_LINES; i++)
            {
                var line       = new PiecesLine(i, (i % 2 != 0), i == 0);
                var lineAmount = MAX_PIECES_PER_LINE - (line.IsShortLine ? 1 : 0);

                for (var j = 0; j < lineAmount; j++)
                {
                    var pieceToAdd = i < INITIAL_LINE_AMOUNT?NormalPiece.GetRandom() : null;

                    pieceToAdd?.UpdatePosition(line, j);
                    pieceToAdd?.Lock();
                    line.Add(pieceToAdd);
                }

                lines.Add(line);
            }

            UpdateConnections();

            Dump();
        }
예제 #5
0
 public void UpdatePosition(PiecesLine line, int index)
 {
     Line  = line;
     Index = index;
 }