Exemplo n.º 1
0
 /// <summary>
 /// Raised whenever we've successfully selected a die.
 /// </summary>
 /// <param name="dieIndex">Index of the die that was selected (0-5) from left to right.</param>
 /// <param name="previousStatus">Previous state of the die.</param>
 /// <param name="currentStatus">Current state of the die.</param>
 private void SelectingDieCompleted(int dieIndex, Die.FaceStatus previousStatus, Die.FaceStatus currentStatus)
 {
     // greedyBotLock already locked...
     Utils.OutputLine("SelectingDieCompleted", Utils.OutputLevel.Game);
     if (dieIndex == dieIndexWereSelecting && currentStatus == Die.FaceStatus.Selected)
     {
         if (diceQueue.Count == 0)
         {
             if (!continueRolling)
             {
                 myGameScore   += pointsThisTurn;
                 pointsThisTurn = 0;
                 Utils.OutputLine("OnDieStatusChange: Schedule stop", Utils.OutputLevel.Game);
                 ClickStop();
             }
             else
             {
                 Utils.OutputLine("OnDieStatusChange: Schedule roll", Utils.OutputLevel.Game);
                 ClickRoll();
             }
         }
         else
         {
             Utils.OutputLine("OnDieStatusChange: Schedule select", Utils.OutputLevel.Game);
             SelectDieFromQueue();
         }
     }
     else
     {
         Utils.OutputLine("OnDieStatusChange: Don't care", Utils.OutputLevel.Game);
     }
 }
Exemplo n.º 2
0
 private void DiceChangedHandler(int dieIndex, Die.FaceStatus previousStatus, Die.FaceStatus currentStatus)
 {
     if (DiceStatusChanged != null)
     {
         DiceStatusChanged(dieIndex, previousStatus, currentStatus);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Raised whenever the state of a die has changed.
        /// </summary>
        /// <param name="dieIndex">Die index (0-5) from left to right.</param>
        /// <param name="previousStatus">Previous state of the die.</param>
        /// <param name="currentStatus">New state of the die.</param>
        private void DiceChanged(int dieIndex, Die.FaceStatus previousStatus, Die.FaceStatus currentStatus)
        {
            lock (greedyBotLock)
            {
                Utils.OutputLine("DiceChanged", Utils.OutputLevel.Game);
                if (currentState == State.SelectingDie)
                {
                    SelectingDieCompleted(dieIndex, previousStatus, currentStatus);
                }
                else if (currentState == State.RollingDice)
                {
                    if (!gameComponents.AreDiceReady(expectedDiceStatus))
                    {
                        return;
                    }

                    RollingDiceCompleted();
                }
            }
        }