示例#1
0
    IEnumerator Wait()
    {
        yield return(new WaitForSeconds(3f));

        int startGame = gameManager.GetPlayerStartGame(gameManager.dices[0].diceCount, gameManager.dices[1].diceCount);

        if (GameManger.PlayerTurn == null)
        {
            switch (startGame)
            {
            case 0:
                startGame  = -1;
                TextToShow = "תיקו! הגרל קובייה מחדש";
                RollBtn.gameObject.SetActive(true);

                break;

            case 1:
                startGame             = -1;
                GameManger.PlayerTurn = "Black";
                TextToShow            = "שחקן 1 - שחור מתחיל את המשחק, הגרל קוביה";
                foreach (Dice d in gameManager.dices)
                {
                    d.isDiceLand = true;
                }
                RollBtn.gameObject.SetActive(false);

                break;

            case 2:
                startGame             = -1;
                GameManger.PlayerTurn = "White";
                TextToShow            = "שחקן 2 - לבן מתחיל את המשחק, הגרל קובייה";
                foreach (Dice d in gameManager.dices)
                {
                    d.isDiceLand = true;
                }
                RollBtn.gameObject.SetActive(false);

                break;
            }
            Instruction.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = TextToShow;
            LeanTween.moveY(Instruction.gameObject, 900f, 1f);
            foreach (GameObject text in gameManager.textBlackWhite)
            {
                text.SetActive(true);
            }
        }
        ShowVisibleDiceUI();

        if (GameManger.PlayerTurn != null)
        {
            if (gameManager.IsBothDicesLandAndRoll())
            {
                if (!gameManager.SumMovements.IsPlayerDidAllSteps())
                {
                    // after rolling check if there is an option to move a stone, while we don't have anything onPlayerTrapped Array.
                    if (gameManager.CantMove())
                    {
                        if (!gameManager.isAllPlayersCanRemoved(gameManager.BoardGame, GameManger.PlayerTurn))
                        {
                            gameManager.ShowErrorPassTurn("אין ביכולתך להזיז אבנים לפי הקוביות הנתונות ולכן התור עובר ליריב");
                        }
                        else
                        {
                            int[] indexDices = { 0, 0, 0, 0 };
                            int   index      = 0;
                            foreach (int diceCount in gameManager.dicesCount)
                            {
                                if (diceCount > 0)
                                {
                                    indexDices[index] = gameManager.GetIndexCountOnRemovingStones(GameManger.PlayerTurn, index);
                                    if (gameManager.BoardGame[indexDices[index]].Count > 0)
                                    {
                                        if (gameManager.BoardGame[indexDices[index]].Peek().PlayerType == GameManger.PlayerTurn)
                                        {
                                            gameManager.ShowMessagePassTurn = false;
                                            break;
                                        }
                                        else
                                        {
                                            gameManager.TakeCareOnNotOnStackAsDice(indexDice, OnSelected.SelectedPlayer.PlayerType, OnSelected.SelectedPlayer);
                                            if (gameManager.RectanglesShowTakeOut[0].activeInHierarchy || gameManager.RectanglesShowTakeOut[1].activeInHierarchy)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        gameManager.TakeCareOnNotOnStackAsDice(indexDice, OnSelected.SelectedPlayer.PlayerType, OnSelected.SelectedPlayer);
                                        if (gameManager.RectanglesShowTakeOut[0].activeInHierarchy || gameManager.RectanglesShowTakeOut[1].activeInHierarchy)
                                        {
                                            break;
                                        }
                                    }
                                }
                                index++;
                            }
                            if (gameManager.ShowMessagePassTurn)
                            {
                                gameManager.ShowErrorPassTurn("אין ביכולתך להזיז אף אבן ולכן התור עובר ליריב");
                            }
                        }
                    }
                }
            }
        }
    }