示例#1
0
    private void OnDiceRolled(int diceRoll)
    {
        bool isRollToGetPawnOut = rulesManager.IsDiceRollToGetOut(diceRoll);

        switch (rulesManager.CheckRulesOnDiceRoll(diceRoll))
        {
        case RulesManager.DiceRollStates.Highlight:
            if (isRollToGetPawnOut)
            {
                CurrentPlayer.HighlightAllPawnsInStart(GetSelectedPawnOutOfStart);
            }
            CurrentPlayer.HighlightPawnsInOpenTraveledMax(rulesManager.GetTilesTraveledMaxToAllowMove(diceRoll),
                                                          (pawnID) => { MoveSelectedPawn(pawnID, diceRoll); });
            break;

        case RulesManager.DiceRollStates.Move:     // Will always be only one move possible
            if (isRollToGetPawnOut && CurrentPlayer.CountPawnsInStart() > 0)
            {
                CurrentPlayer.GetLastPawnOutOfStart(OnMoveEnded);
            }
            else
            {
                CurrentPlayer.MakeOnlyPossibleMove(diceRoll, OnMoveEnded);
            }
            break;

        case RulesManager.DiceRollStates.EndTurn:
            EndTurnAfter(Constants.DiceRoll.WaitForDiceDisplayDuration);
            break;
        }
    }