예제 #1
0
        /// <summary>
        /// Method that will be called when a word is placed
        /// </summary>
        private void PlaceWord()
        {
            if (!PlaceBtn.IsActive())
            {
                ShowPlayerWhyInactive();
                return;
            }

            // Alleen wanneer mag versturen
            bool canMove = GameInstance.instance.IsMultiplayer ? (bool)PhotonNetwork.LocalPlayer.CustomProperties["CanMove"] : Player.CanMove;

            if (!canMove || !PlacedLetters.Any(x => x.LetterBlock != null))
            {
                return;
            }

            string madeWord = "";

            foreach (LetterBlock block in PlacedLetters.Select(x => x.LetterBlock).ToList())
            {
                if (block == null)
                {
                    continue;
                }
                madeWord += block.GetLetter();
            }
            if (!TheLetterManager.CheckWord(madeWord, out long points, PlacedLetters, Player))
            {
                return;
            }
            int bestWordIndex = Player.BestWordsThisGame.Count(word => word.points > points);

            Player.BestWordsThisGame.Insert(bestWordIndex, new Word(madeWord, points));
            if (DoubleWordValue)
            {
                points *= 2;
            }
            if (TripleWordValue)
            {
                points *= 3;
            }
            DoubleWordValue      = false;
            TripleWordValue      = false;
            Player.EarnedPoints += points;

            if (madeWord.Count() == 12)
            {
                Player.WordsWithTwelveLetters++;
            }

            //TheLetterManager.PlaceWordInGameBoard(PlacedLetters.Select(x => x.LetterBlock).ToList()); Verplaatsen naar TheLetterManager
            DynamicUi.PlayerManagerClass.NextTurn();
            PlaceWordInGameBoard(points);
            RemoveAllLettersFromPlayerBoard();
            ChangeFixedLetters(madeWord);
            GameBoardWordContainer.transform.parent.transform.parent.GetComponent <GameboardScroll>().ScrollDownBar();
            Player.IncreaseWordCount();
            SetPlaceBtnActivity(false);
            BoosterText.text = "";
        }
예제 #2
0
 /// <summary>
 /// Set the material of the placebutton to show the user when it's (in)active
 /// </summary>
 /// <param name="SetActive"></param>
 private void SetPlaceBtnActivity(bool SetActive)
 {
     if (SetActive)
     {
         PlaceBtn.GetComponent <CanvasRenderer>().SetMaterial(PlaceButtonActiveMaterial, 0);
         PlaceBtn.GetComponent <Button>().interactable = true;
     }
     else
     {
         PlaceBtn.GetComponent <CanvasRenderer>().SetMaterial(PlaceButtonInactiveMaterial, 0);
         PlaceBtn.GetComponent <Button>().interactable = false;
     }
 }