示例#1
0
        //
        void setPreview()
        {
            //store a piece from the top of the queue into StoredPiece (display piece)
            StoredPiece preview   = GameObject.FindGameObjectWithTag(Constants.DISPLAY_PIECE).GetComponent <StoredPiece>();
            GameObject  nextPiece = Instantiate(nextPieces.Dequeue(),
                                                preview.transform.position,
                                                Quaternion.identity);

            nextPiece.GetComponent <Piece>().enabled = false;
            nextPiece.GetComponent <Piece>().tag     = Constants.DISPLAY_PIECE;
            preview.StowedPiece = nextPiece;
            if (nextPieces.Count <= 3)
            {
                populateNextPieces();
            }
        }
示例#2
0
文件: Piece.cs 项目: ehsu93/Tetris
 void storePiece()
 {
     if (!Global.Swapped)
     {
         tag = Constants.INACTIVE_PIECE;
         StoredPiece  storeTo  = GameObject.FindGameObjectWithTag(Constants.STORE_PIECE).GetComponent <StoredPiece>();
         PieceSpawner spawner  = FindObjectOfType <PieceSpawner>();
         GameObject   newPiece = storeTo.StowedPiece;
         storeTo.StowedPiece = gameObject;
         transform.rotation  = Quaternion.identity;
         transform.position  = storeTo.Location;
         enabled             = false;
         //Board.UpdatePosition(transform);
         if (newPiece == null)
         {
             spawner.SpawnNext();
         }
         else
         {
             spawner.SpawnPiece(newPiece);
         }
         Global.Swapped = true;
     }
 }