Пример #1
0
 public void OnEndTurn()
 {
     if (CurrentTiles.Count > 0)
     {
         if (CheckWords())
         {
             _turnsSkipped = 0;
             CurrentTurn++;
             var points = CountPoints();
             Player1.ChangeBox(7 - Player1.CurrentLetters.Count);
             CurrentTiles     = new List <TileLAN>();
             CurrentDirection = Direction.None;
             IsFirstTurn      = false;
             if (_timerEnabled)
             {
                 TimeRemaining = (float)_timerLength + 1;
             }
             Player1.ChangePlayer(PlayerNumber == 1 ? 2 : 1, points);
             if (Player1.CurrentLetters.Count == 0)
             {
                 Player1.EndGame();
             }
         }
         else
         {
             Controller.ShowNotExistError();
         }
     }
     else
     {
         Controller.ShowZeroTilesError();
     }
     _wordsFound = new List <TileLAN>();
 }
Пример #2
0
 private void Update()
 {
     if (_gameStarted && Player1 == null)
     {
         Controller.ShowConnectionError();
     }
     Controller.SetSkipButtonActive(CurrentTiles.Count == 0);
     if (Input.GetKeyDown(KeyCode.A) && Player1 != null)
     {
         Player1.EndGame();
     }
     if (_timerEnabled)
     {
         TimeRemaining -= Time.deltaTime;
         if (Player1 == null)
         {
             return;
         }
         var value = Player1.isServer ? (int)TimeRemaining : (int)TimeRemaining - 2;
         if (value < 0)
         {
             value = 0;
         }
         TimerText.text = value.ToString();
         if (TimeRemaining < 0)
         {
             OnEndTimer();
         }
     }
     if (Player1 == null && PlayerToSendCommands != null && GameObject.FindGameObjectsWithTag("Player").Length > 1)//Do not touch. It's a feature
     {
         foreach (var o in GameObject.FindGameObjectsWithTag("Player"))
         {
             if (o.GetComponent <LetterBoxLAN>() == PlayerToSendCommands)
             {
                 continue;
             }
             Player1      = o.GetComponent <LetterBoxLAN>();
             _gameStarted = true;
             break;
         }
     }
     else if (Player1 != null)
     {
         Controller.SetChangeButtonActive(Player1.AllLetters.Count > 0 && Player1.CanChangeLetters);
     }
 }