示例#1
0
文件: Board.cs 项目: hirotk/Pentia
        public Board(Field field, Field nextField)
        {
            this.IsGameOver = false;
            this.field = field;
            this.nextField = nextField;
            pieceQueue = new Queue<Piece>();

            this.rand = new Random();

            this.piece = createPiece(field, field.COLS / 2, 0);

            var nextPiece = createPiece(nextField, nextField.COLS / 2, nextField.ROWS / 2);
            pieceQueue.Enqueue(nextPiece);
            nextField.Draw();
        }
示例#2
0
文件: Field.cs 项目: hirotk/Pentia
 public void RemovePiece(Piece piece)
 {
     foreach (NPoint pt in piece.Shape) {
         this[piece.X + pt.x, piece.Y + pt.y] = PcColor.None;
     }
 }
示例#3
0
文件: Field.cs 项目: hirotk/Pentia
 public void PutPiece(Piece piece)
 {
     foreach (NPoint pt in piece.Shape) {
         this[piece.X + pt.x, piece.Y + pt.y] = piece.Color;
     }
 }
示例#4
0
 public void BeginTestMethod()
 {
     field.Reset();
     target = new Piece(field, field.COLS / 2, 0, PcType.J0);
 }
示例#5
0
文件: Board.cs 项目: hirotk/Pentia
        public void Update()
        {
            if (piece.Move(Direction.Down)) {
                this.DeletedRowNum = 0;
                return;
            }

            int deletedRowNum;
            field.Update(out deletedRowNum);
            this.DeletedRowNum = deletedRowNum;

            if (piece.Y <= 0) {
                this.IsGameOver = true;
                return;
            }

            // Get the next piece
            var nextPiece = pieceQueue.Dequeue();
            nextField.RemovePiece(nextPiece);

            nextPiece.Field = this.field;
            nextPiece.X = this.field.COLS / 2;
            nextPiece.Y = 0;
            this.piece = nextPiece;

            nextPiece = createPiece(nextField, nextField.COLS / 2, nextField.ROWS / 2);
            pieceQueue.Enqueue(nextPiece);
            nextField.Draw();
        }
示例#6
0
文件: Board.cs 项目: hirotk/Pentia
 private Piece createPiece(Field field, int x, int y, PcType type = PcType.Random)
 {
     if (type == PcType.Random) { type = (PcType)rand.Next((int)PcType.Leng); }
     var piece = new Piece(field, x, y, type);
     field.PutPiece(piece);
     return piece;
 }