Exemplo n.º 1
0
 void Awake()
 {
     if (retryButton == null)
     {
         Debug.Log("retryButton == null");
     }
     if (detailButton == null)
     {
         Debug.Log("detailButton == null");
     }
     if (detailPanel == null)
     {
         Debug.Log("detailPanel == null");
     }
     if (pauseButton == null)
     {
         Debug.Log("pauseButton == null");
     }
     if (remainingWordlist == null)
     {
         Debug.Log("remainingWOrdlist == null");
     }
     if (timer == null)
     {
         Debug.Log("timer == null");
     }
     tileManager    = TileManager.GetInstance();
     wordChecker    = WordChecker.GetInstance();
     linkController = LinkController.GetInstance();
 }
Exemplo n.º 2
0
    void UpdateLink()
    {
        bool    isTouching = touchManager.isTouching && touchManager.touchPriority <= 0 && !touchManager.isTouchingUI;
        Vector2 touchPos   = touchManager.touchPos;

        SetLinkFlareActive(isTouching);

        //linking
        if (isTouching)
        {
            if (!prevTouching || linkedTiles.Count > 0)
            {
                GameObject tile = TouchManager.GetTouchingTile();

                if (tile != null && !tile.GetComponent <TileBehaviour>().isLinked)
                {
                    if (IsTileAdjacentToLastTile(tile))
                    {
                        LinkTile(tile);
                    }
                }
            }
            SetLinkTailFollowTouch(touchPos);
        }

        //end linking
        else if (prevTouching)
        {
            //string str = getLinkedWord();
            print(linkedStr);

            bool isWordValid = WordChecker.GetInstance().IsWordValid(linkedStr);
            if (isWordValid && GameController.GetInstance().FinishWord(linkedStr))
            {
                DestroyLink(false);
            }
            else
            {
                if (!isWordValid && AreAllCharactersSame(linkedStr) && IsLinkRectangle())
                {
                    tileManager.MergeTiles(linkedTiles);
                }
                DestroyLink(isWordValid);
            }
            linkedStr           = "";
            LinkedWordText.text = "";
        }

        prevTouching = isTouching;
    }
Exemplo n.º 3
0
    public void Drop(string[][] tileSetup, bool shouldGenerateTile = true)
    {
        UnmergeAllTile();

        int[] tilePosOffset = new int[colCount];

        //section 1
        for (int i = 0; i < colCount; i++)
        {
            tilePosOffset[i] = -2;
        }
        for (int i = rowCount - 1; i >= 0; i--)
        {
            for (int j = 0; j < colCount; j++)
            {
                if (GetDropSection(i, j) != 1)
                {
                    continue;
                }
                if (tiles[i][j] == null)
                {
                    int row = i - 1;
                    while (row >= 0)
                    {
                        if (tiles[row][j] != null)
                        {
                            tiles[row][j].GetComponent <TileBehaviour>().row = i;
                            tiles[i][j]   = tiles[row][j];
                            tiles[row][j] = null;
                            break;
                        }
                        row--;
                    }
                    if (shouldGenerateTile && row == -1)
                    {
                        if (i < tileSetup.Length && j < tileSetup[i].Length)
                        {
                            CreateTile(tileSetup[i][j], i, j, --tilePosOffset[j]);
                        }
                        else
                        {
                            CreateTile(GetRandomCharacter(), i, j, --tilePosOffset[j]);
                        }
                    }
                }
            }
        }

        //section 2
        for (int i = 0; i < rowCount; i++)
        {
            tilePosOffset[i] = -2;
        }
        for (int j = 0; j < colCount; j++)
        {
            for (int i = 0; i < rowCount; i++)
            {
                if (GetDropSection(i, j) != 2)
                {
                    continue;
                }
                if (tiles[i][j] == null)
                {
                    int col = j + 1;
                    while (col < colCount)
                    {
                        if (tiles[i][col] != null)
                        {
                            tiles[i][col].GetComponent <TileBehaviour>().col = j;
                            tiles[i][j]   = tiles[i][col];
                            tiles[i][col] = null;
                            break;
                        }
                        col++;
                    }
                    if (shouldGenerateTile && col == colCount)
                    {
                        if (i < tileSetup.Length && j < tileSetup[i].Length)
                        {
                            CreateTile(tileSetup[i][j], i, j, --tilePosOffset[i]);
                        }
                        else
                        {
                            CreateTile(GetRandomCharacter(), i, j, --tilePosOffset[i]);
                        }
                    }
                }
            }
        }

        //3
        for (int i = 0; i < colCount; i++)
        {
            tilePosOffset[i] = -2;
        }
        for (int i = 0; i < rowCount; i++)
        {
            for (int j = 0; j < colCount; j++)
            {
                if (GetDropSection(i, j) != 3)
                {
                    continue;
                }
                if (tiles[i][j] == null)
                {
                    int row = i + 1;
                    while (row < rowCount)
                    {
                        if (tiles[row][j] != null)
                        {
                            tiles[row][j].GetComponent <TileBehaviour>().row = i;
                            tiles[i][j]   = tiles[row][j];
                            tiles[row][j] = null;
                            break;
                        }
                        row++;
                    }
                    if (shouldGenerateTile && row == rowCount)
                    {
                        if (i < tileSetup.Length && j < tileSetup[i].Length)
                        {
                            CreateTile(tileSetup[i][j], i, j, --tilePosOffset[j]);
                        }
                        else
                        {
                            CreateTile(GetRandomCharacter(), i, j, --tilePosOffset[j]);
                        }
                    }
                }
            }
        }

        //4
        for (int i = 0; i < rowCount; i++)
        {
            tilePosOffset[i] = -2;
        }
        for (int j = colCount - 1; j >= 0; j--)
        {
            for (int i = 0; i < rowCount; i++)
            {
                if (GetDropSection(i, j) != 4)
                {
                    continue;
                }
                if (tiles[i][j] == null)
                {
                    int col = j - 1;
                    while (col >= 0)
                    {
                        if (tiles[i][col] != null)
                        {
                            tiles[i][col].GetComponent <TileBehaviour>().col = j;
                            tiles[i][j]   = tiles[i][col];
                            tiles[i][col] = null;
                            break;
                        }
                        col--;
                    }
                    if (shouldGenerateTile && col == -1)
                    {
                        if (i < tileSetup.Length && j < tileSetup[i].Length)
                        {
                            CreateTile(tileSetup[i][j], i, j, --tilePosOffset[i]);
                        }
                        else
                        {
                            CreateTile(GetRandomCharacter(), i, j, --tilePosOffset[i]);
                        }
                    }
                }
            }
        }


        //WordChecker.GetInstance().FindLinkableCharactersForEmptySlots(tiles);
        WordChecker.GetInstance().FindAllLinkableCharacter(tiles);
    }