Example #1
0
    void CheckAnswer(string[] userInput, bool fromLocalUser)
    {
        string userAnswer = GetUserAnswer();

        if (userAnswer == currentTile.GetCurrentAnswer(currentDirectionIsAcross) && !currentTile.DidSolveCurrentAnswer(currentDirectionIsAcross))
        {
            Debug.Log("send the correct answer to the other players");
            //Debug.Log("the user has input the correct answer");
            //put the correct answer in the user grid and select the next tile
            UpdateUserGrid();
            int offset = 1;
            if (!currentDirectionIsAcross)
            {
                offset = (int)Mathf.Sqrt(tiles.Length);
            }

            string[] tempFriendlyGrid = CopyGrid(localPlayerGrid);

            for (int j = 0; j < currentUserInput.Length; j++)
            {
                int index = currentTile.index + j * offset;
                if (userGrid[index] == "")
                {
                    tempFriendlyGrid[index] = currentUserInput[j];
                }
            }

            networkingLogic.UpdateBoard(tempFriendlyGrid, enemyPlayerGrid, neutralGrid);


            TileLogic nextTile = currentTile;
            for (int i = 0; i < tiles.Length; i++)
            {
                TileLogic tl = tiles[(currentTile.index + i + 1) % tiles.Length];
                if (tl != null)
                {
                    //if the tile has as grid number and can be selected
                    if (tl.clueNumber > 0 && (!tl.didSolveAcross || !tl.didSolveDown))
                    {
                        nextTile = tl;
                        break;
                    }
                }
            }

            DidSelectTile(nextTile);
        }
        else
        {
            if (!canInteract)
            {
                Debug.Log("dont do the animation or set the delay");
            }
            else
            {
                StartCoroutine(ReselectTileWithDelay(currentUserInput, fromLocalUser));
            }
            //ShowWordSelected(currentTile, currentDirectionIsAcross); // reselect the current tile to show the user that the answer is wrong
        }
    }