public void TakeCareOfCases()
    {
        // on finish turn
        if (gameManager.SumMovements.IsPlayerDidAllSteps())
        {
            gameManager.PassTurn();
        }
        else
        {
            if (gameManager.CantMove()) // can't moves stones at all
            {
                if (gameManager.isAllPlayersCanRemoved(gameManager.BoardGame, GameManger.PlayerTurn))
                {
                    gameManager.ShowMessagePassTurn = true; //reset
                    gameManager.ShowMessagePassTurn = gameManager.NeedPassTurnMsg();

                    if (gameManager.ShowMessagePassTurn)
                    {
                        gameManager.ShowErrorPassTurn("אין ביכולתך להזיז אף אבן ולכן התור עובר ליריב");
                    }
                }
                else
                {
                    print("never happen");
                    gameManager.ShowErrorPassTurn("אין ביכולתך להזיז אבנים לפי הקוביות הנתונות ולכן התור עובר ליריב");
                }
            }
        }
    }
Esempio n. 2
0
    /*Normal situation - we dont have trapped stones, update the movement of the stone*/
    public void UpdateMoventDiceNormalSituation()
    {
        // using Math.Abs for not checking if the current player is white or black.
        MovementToDecrease = Math.Abs(OnSelected.SelectedPlayer.indexTriangle - TriangleIndex);

        gameManager.CanMoveStonesOnBoard = true;
        UpdateRolling(MovementToDecrease);

        JumpOnOppositeStone();                                                    // check if the participent jump on oppoise stone on the board

        gameManager.BoardGame[OnSelected.SelectedPlayer.indexTriangle - 1].Pop(); // remove from current stack

        UpdateOnSelectedOptionOnStone();
        UpdatePropertiesAfterMovement();

        if (!gameManager.SumMovements.IsPlayerDidAllSteps())  // if player didn't finish his turn beacuse did all steps.
        {
            if (gameManager.isAllPlayersCanRemoved(gameManager.BoardGame, GameManger.PlayerTurn))
            {
                if (gameManager.CantMove())
                {
                    gameManager.ShowMessagePassTurn = true;                          //reset
                    gameManager.ShowMessagePassTurn = gameManager.NeedPassTurnMsg(); // this function check if there is an optional to take out stones by last stack/ stack according to dices

                    if (gameManager.ShowMessagePassTurn)
                    {
                        gameManager.ShowErrorPassTurn("אין ביכולתך להזיז אף אבן ולכן התור עובר לי");
                    }
                }
                OnSelected.SelectedPlayer.PlayerRemoveStones();
            }
            else
            {
                if (gameManager.CantMove())
                {
                    gameManager.ShowErrorPassTurn("אין ביכולתך להזיז אבנים לפי הקוביות הנתונות ולכן התור עובר ליריב"); // if we can't get stones out & can't move at all - show msg
                }
            }
        }
    }
Esempio n. 3
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("אין ביכולתך להזיז אף אבן ולכן התור עובר ליריב");
                            }
                        }
                    }
                }
            }
        }
    }