Esempio n. 1
0
    public void PlaceGamePiece(GamePiece gamePiece, int x, int y, int shape, int newLine, float timeToFade)
    {
        if (gamePiece == null)
        {
            Debug.LogWarning("Invalid GamePiece");
            return;
        }

        // Check if the piece needs to move into the field from outside of the board
        if (newLine == 1)
        {
            // fall in from top
            gamePiece.transform.position = new Vector3(x, y + 1, 0);
            gamePiece.transform.rotation = Quaternion.identity;
            animationQueue.addMoveAnimation(gamePiece, moveTime, new Vector3(x, y, 0));
        }
        else if (newLine == 2)
        {
            // fall in from right
            gamePiece.transform.position = new Vector3(x + 1, y, 0);
            gamePiece.transform.rotation = Quaternion.identity;
            animationQueue.addMoveAnimation(gamePiece, moveTime, new Vector3(x, y, 0));
        }
        else
        {
            // just place it
            gamePiece.transform.position = new Vector3(x, y, 0);
            gamePiece.transform.rotation = Quaternion.identity;
        }

        if (IsWithinBounds(x, y))
        {
            //Debug.Log ("Piece at position " + x + ", " + y + " placed");
            m_allGamePieces [x, y] = gamePiece;
        }

        // Set the coordinates in the shape
        gamePiece.SetCoord(x, y, shape);
        //TODO: WIP
        animationQueue.addFadeAnimation(gamePiece, timeToFade, 1);
        //gamePiece.FadeIn(fadeTime);
    }