Ejemplo n.º 1
0
    IEnumerator RollingCoroutine()
    {
        RollCheckIsOccuring = true;
        while (dieScript.rolling)
        {
            yield return(null);
        }
        //source.Play();
        yield return(new WaitForSeconds(2));

        //gcs.MovePlayer(dieScript.value);

        // Hide the menu
        GameGUI.HideRollScreen();

        // Reset the die
        ResetDie();

        // Proceed based on game mode
        Board board = GameData.GetBoard();

        if (GameData.GetGameMode() == GameData.Mode.NormalRoll)
        {
            //GameData.SetGameMode(GameData.Mode.MovingPiece);
            //GameData.GetActivePiece().MoveSpaces(dieScript.value, 0);
            //Debug.Log(GameData.GetCurrPlayer().GetLegalMoves(dieScript.value).Count);
            //GameData.GetCurrPlayer().Move(dieScript.value, 0);

            // Display the player's legal moves
            GameData.GetCurrPlayer().DisplayLegalMoves(dieScript.value);
        }
        if (GameData.GetGameMode() == GameData.Mode.RollSixOrDie)
        {
            // If six, jump to finish, else jump to start
            GameData.SetGameMode(GameData.Mode.MovingPiece);
            if (dieScript.value == 6)
            {
                Tile finishTile = board.GetFinishTile();
                GameData.GetActivePiece().JumpToTile(finishTile);
            }
            else
            {
                Tile startTile = board.GetStartTile();
                GameData.GetActivePiece().JumpToTile(startTile);
            }

            // Check for winner (wait 2 seconds to jump, 2 seconds to settle down)
            StartCoroutine(board.CheckWinner(4));
        }
        if (GameData.GetGameMode() == GameData.Mode.InitialRoll)
        {
            // record die roll
            //board.RecordDieRoll(dieScript.value);
            GameData.GetCurrPlayer().AddToInitialRoll(dieScript.value);

            // next player in queue rolls
            board.RollFromQueue();
        }
        RollCheckIsOccuring = false;
    }
Ejemplo n.º 2
0
    public void DoTieBreakers()
    {
        // checks for ties in dice rolls and does tiebreakers if needed
        bool tied  = false;
        int  index = 0;

        while (!tied && index < players.Count - 1)
        {
            if (players[index].CompareTo(players[index + 1]) > 0)
            {
                // if current player is higher than next player, add 6 to initial roll
                players[index].AddToInitialRoll(6);
            }
            else
            {
                // if tied, add players to roll queue and stop iterating
                nextToRollQueue.Enqueue(players[index]);
                nextToRollQueue.Enqueue(players[index + 1]);
                tied = true;
            }
            index++;
        }

        // add tied players to the queue
        while (index < players.Count - 1 && players[index].CompareTo(players[index + 1]) == 0)
        {
            nextToRollQueue.Enqueue(players[index + 1]);
            index++;
        }

        // reroll if necessary
        if (nextToRollQueue.Count > 0)
        {
            RollFromQueue();
        }
        else
        {
            // hide the roll screen
            GameGUI.HideRollScreen();

            // show the move order screen
            GameGUI.ShowMoveOrderScreen();
        }
    }