Пример #1
0
        /* void sendDiceNumber(BasePlayer player, int number)
         * {
         *   LudoDelegate.showDice(player.getUser(), number);
         *
         * }
         */

        void onNumberSelection(int number, string player, int goti1)
        {
            try
            {
                if (PlayerPrefs.GetInt(LudoTags.GAME_TYPE) == LudoTags.OFFLINE)
                {
                    if (player.Equals(playerList[currentPlayer].getUser()))
                    {
                        playerList[currentPlayer].moveGotibySelection(number, goti1);
                        responded = true;
                    }
                }
                else
                {
                    if (player.Equals(playerList[currentPlayer].getUser()))
                    {
                        appwarp.userSelectGoti(goti1, number);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Debug.Log(ex.Message);
            }
            LudoDelegate.stopAnimation();
        }
Пример #2
0
        public void MoveGoti(int gotiNumber, int from, int to)
        {
            GotiScript obj = this.getGotiByNumber(gotiNumber);

            if (obj != null)
            {
                obj.moveGoti(from, to);
            }
            LudoDelegate.stopAnimation();
        }
Пример #3
0
        IEnumerator startOffline()
        {
            yield return(new WaitForSeconds(1));

            playerList[0].setPlayer(PlayerPrefs.GetString(GetPlayerDetailsTags.PLAYER_NAME), "1", false, PlayerPrefs.GetString(GetPlayerDetailsTags.PLAYER_IMAGE));
            playerList[1].setPlayer("Computer", "2", true, "2");

            for (; currentPlayer < playerList.Length; currentPlayer++)
            {
                if (playerList[currentPlayer].isActive)
                {
                    playerList[currentPlayer].resetTurnNumber();
                    sendTurn(playerList[currentPlayer]);
throwDice:
                    responded     = false;
                    this.reChance = false;
                    int number = Random.Range(1, 8);
                    number = number > 6 ? 6 : number;

                    if (playerList[currentPlayer].isComputer)
                    {
                        playerList[currentPlayer].playerTurn(number, false);
                        yield return(new WaitForSeconds(0.2f));

                        playerList[currentPlayer].startDiceAnimation(number);
                        yield return(new WaitForSeconds(1));

                        playerList[currentPlayer].TurnValue.Add("" + number);
                        playerList[currentPlayer].addNumberInTurn(number);
                        if (number == 6)
                        {
                            if (playerList[currentPlayer].totalTurnNumber() < 18)
                            {
                                goto throwDice;
                            }
                        }
                        if (playerList[currentPlayer].totalTurnNumber() < 18)
                        {
                            if (playerList[currentPlayer].isGotiReadyForMove())
                            {
                                Debug.Log("Computer is thinking " + playerList[currentPlayer].TurnValue.ToString());
                                while (playerList[currentPlayer].TurnValue.Count > 0)
                                {
                                    yield return(new WaitForSeconds(0.5f));

                                    int num = int.Parse(playerList[currentPlayer].TurnValue[0]);
                                    gotiAnimationComplete = false;

                                    Debug.Log(playerList[currentPlayer].getName() + " move Goti for " + num);
                                    if (playerList[currentPlayer].MoveGotiByAI(num))
                                    {
                                        yield return(new WaitUntil(() => gotiAnimationComplete));

                                        if (gotiAnimationComplete)
                                        {
                                            Debug.Log("Goti Animation is done");
                                        }
                                    }
                                    if (playerList[currentPlayer].removeNumber(num))
                                    {
                                        Debug.Log("number is remove " + playerList[currentPlayer].TurnValue.ToString());
                                    }
                                    if (checkForGotiCut())
                                    {
                                        this.reChance = true;
                                    }
                                    LudoDelegate.stopAnimation();
                                }
                            }
                        }
                    }
                    else
                    {
                        playerList[currentPlayer].playerTurn(number, true);
                        yield return(new WaitUntil(() => responded));

                        if (responded)
                        {
                            Debug.Log("Responded For Dice " + playerList[currentPlayer].getName());

                            if (number == 6)
                            {
                                if (playerList[currentPlayer].totalTurnNumber() < 18)
                                {
                                    goto throwDice;
                                }
                                else
                                {
                                    if (currentPlayer == playerList.Length - 1)
                                    {
                                        currentPlayer = -1;
                                    }
                                    continue;
                                }
                            }
askForGoti:
                            if (playerList[currentPlayer].isGotiReadyForMove())
                            {
                                responded = false;


                                yield return(new WaitUntil(() => responded));

                                if (responded)
                                {
                                    responded = false;
                                    Debug.Log("Responded For Goti " + playerList[currentPlayer].getName());
                                    gotiAnimationComplete = false;
                                    yield return(new WaitUntil(() => gotiAnimationComplete));

                                    if (gotiAnimationComplete)
                                    {
                                        Debug.Log("Goti Animation is done");
                                    }

                                    if (checkForGotiCut())
                                    {
                                        this.reChance = true;
                                    }
                                    if (playerList[currentPlayer].TurnValue.Count > 0)
                                    {
                                        goto askForGoti;
                                    }
                                }
                            }
                            else
                            {
                                Debug.Log("Goti is not ready");
                            }
                        }
                    }
                    if (this.reChance)
                    {
                        Debug.Log("Get Rechance " + playerList[currentPlayer].getName());
                        goto throwDice;
                    }
                }

                if (playerList[currentPlayer].checkWinner())
                {
                    this.winner(playerList[currentPlayer]);
                    break;
                }

                if (!checkGameValidation())
                {
                    winnerLastPlayer();
                    break;
                }


                if (currentPlayer == playerList.Length - 1)
                {
                    currentPlayer = -1;
                }
                yield return(new WaitForSeconds(1));
            }
        }