Esempio 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);
        }
Esempio n. 2
0
        /// <summary>
        /// All logic for placing a word
        /// </summary>
        /// <param name="foundWord"></param>
        private void PlaceWord(string foundWord)
        {
            hasFoundWord = false;
            if (foundWord == "")
            {
                Letters = TheLetterManager.GetLetters(TheLetterManager.FirstPlayerLetters.Count()).ToList();
                return;
            }
            playerManager.NextTurn();
            ChangeLetters(foundWord, foundWord.IndexOf(FirstLetter), foundWord.LastIndexOf(SecondLetter));
            long points = TheLetterManager.CalculatePoints(foundWord);

            EarnedPoints += points;
            PlacedInBoard(foundWord, foundWord.IndexOf(FirstLetter), foundWord.LastIndexOf(SecondLetter));
            LetterManager.ChangeFixedLetters(foundWord, true);
            TheLetterManager.PlacedWords.Add(foundWord);
            LetterManager.GameBoardWordContainer.transform.parent.transform.parent.GetComponent <GameboardScroll>().ScrollDownBar();
            int bestWordIndex = BestWordsThisGame.Count(word => word.points > points);

            BestWordsThisGame.Insert(bestWordIndex, new Word(foundWord, points));
        }