Example #1
0
    private void Awake()
    {
        var startPiece = GridPiece.GeneratePiece(this, new Square());

        startPiece.Place(Vector2.zero);

        m_FinalPiece = GridPiece.GeneratePiece(this, new Square());
        m_FinalPiece.Place(new Vector2(0, m_Distance));
    }
    private void TryPlacePiece()
    {
        // check if can place piece in front of player...
        Coordinate nextCoordinate = null;

        if (!m_CurrentCoordinte.TryMove(m_Facing, ref nextCoordinate))
        {
            ClearPreview();

            Vector2 placePostition = WorldGrid.OffsetDirection(m_CurrentCoordinte.GridPosition(), m_Facing);
            // TODO: overlapping piece handling...
            m_PlayerPiece.Place(placePostition);
            Respawn();
        }
    }