示例#1
0
        // returns the fallen distance of the piece
        public int Drop(Tetrimino next)
        {
            int distance = Board.DropDistance(Piece);

            // TODO: check this again!
            if (distance < 0 && Board.Intersects(Piece))
            {
                throw new GameOverException();
            }

            // let piece fall
            Piece.Fall(distance);
            Board.Place(Piece);
            Piece = null;

            // remove lines
            int lines = Board.RemoveLines();

            Lines += lines;

            // calculate score
            Score += TetrisScore.GetSoftdropScore(distance);
            Score += TetrisScore.GetLineScore(lines, Level);

            if (NextPiece.HasValue)
            {
                // TODO: only generate new piece if this is explicitly wanted!
                Piece     = new Piece(NextPiece.Value);
                NextPiece = next;
            }

            return(distance);
        }
示例#2
0
 private void Awake()
 {
     scoringSystem    = GetComponent <TetrisScore> ();
     garbageGenerator = GetComponent <GarbageGenerator>();
     board            = GetComponent <TetrisBoard>();
     game             = GetComponent <TetrisGame>();
 }
示例#3
0
文件: TetrisScore.cs 项目: iuvei/17mj
    void Awake()
    {
        Instance = this;

        string hs = PlayerPrefs.GetString("HIGHSCORE");

        _highS       = (string.IsNullOrEmpty(hs)) ? 0 : int.Parse(hs);
        _scoreH.text = "" + _highS;
        _score.text  = "0";
        _clearColor  = _clear.color;
        _clearPos    = _clear.transform.position;
    }
示例#4
0
        internal void DropUnchecked(int distance)
        {
            // let piece fall
            Piece.Fall(distance);
            Board.PlaceUnchecked(Piece);
            Pieces.Push(new Piece(Piece)); // we need to remember the dropped pieces for the landing height feature (heuristic)
            Piece = null;

            // remove lines
            int lines = Board.RemoveLines();

            Lines += lines;

            // calculate score
            Score += TetrisScore.GetSoftdropScore(distance);
            Score += TetrisScore.GetLineScore(lines, Level);

            if (NextPiece.HasValue)
            {
                Piece     = new Piece(NextPiece.Value);
                NextPiece = Tetriminos.GetRandom();
            }
        }