Exemplo n.º 1
0
        /// <summary>
        ///  Place word in gameboard
        /// </summary>
        /// <param name="word"></param>
        /// <param name="firstLetterIndex"></param>
        /// <param name="secondLetterIndex"></param>
        public void PlacedInBoard(string word, int firstLetterIndex, int secondLetterIndex)
        {
            // Insantiate wordHolder
            GameObject wordHolder = Instantiate(LetterManager.GameBoardWordHolder);

            for (int i = 0; i < 12; i++)
            {
                LetterBlock block = null;
                if (i < word.Length)
                {
                    block = LetterManager.InstantiateLetterButton(word[i], i == firstLetterIndex, i == secondLetterIndex);
                }

                if (block != null)
                {
                    block.GetComponent <Image>().material = block.IsWalkingLetter() ? FixedLetterOtherPlayerMaterial : PlayerLetterOtherPlayerMaterial;
                    block.transform.SetParent(wordHolder.transform, false);
                    block.GetComponent <Button>().interactable = false;
                }
                else
                {
                    GameObject emptyPlaceHolder = Instantiate(LetterManager.PlaceHolderObject);
                    emptyPlaceHolder.transform.SetParent(wordHolder.transform, false);
                }
            }
            wordHolder.transform.SetParent(LetterManager.GameBoardWordContainer.transform, false);
        }