예제 #1
0
    void PlaceWord(string word, int row, int offset)
    {
        //UnityEngine.Debug.Log("PlaceWord(word = " + word + ", row = " + row + ", offset = " + offset + ")");
        List <LibrettoTile> wordTiles = wordGrid.GetRowTiles(word.Length, row, offset);
        var chars = word.ToCharArray();

        for (int i = 0; i < word.Length; i++)
        {
            LibrettoTile tile = wordTiles[i];
            tile.SetTileData(chars[i]);
            tile.ShowFixed();
        }
    }
예제 #2
0
    public void HandleTouchDown(Vector2 touch)
    {
        ClearSelection();

        touchPosition   = Camera.main.ScreenToWorldPoint(touch);
        touchPosition.z = 0;

        //check panel grid
        var tile = panelGrid.TileCloseToPoint(touchPosition);

        if (tile == null || !tile.gameObject.activeSelf)
        {
            //check word grid
            tile = wordGrid.TileCloseToPoint(touchPosition);
            if (tile != null && tile.gameObject.activeSelf && tile.IsMovable())
            {
                //pick tile from panel
                var tempTile = Instantiate(panelGrid.gridTileGO) as GameObject;
                tempTileOrigin = tile;

                selectedTile = tempTile.GetComponent <LibrettoTile>();
                selectedTile.transform.localScale = panelGrid.transform.localScale;
                selectedTile.transform.parent     = wordGrid.transform;

                selectedTile.transform.localPosition = tile.transform.localPosition;
                selectedTile.gridType = LibrettoGrid.GRID_TYPE.WORD_GRID;
                selectedTile.SetTileData(tile.TypeChar);
                selectedTile.ShowTemporary();

                tile.ShowGap();
            }
        }
        else
        {
            selectedTile = tile;
        }

        if (selectedTile != null)
        {
            selectedTile.Select(true);
        }
    }