예제 #1
0
        /// <summary>
        /// Generates a new random integer and compares it to the user's guess.
        /// Increments the RollCounter, Guesses, and WinRatio values. Then updates the values in the form.
        /// </summary>
        /// <param name="sender">Event Sender</param>
        /// <param name="e">Event Object</param>
        private void RollButton_Click(object sender, EventArgs e)
        {
            //Generate random number from 1-6
            int roll = r.Next(6) + 1;
            //Holds the last randomly generated roll in for loop so the "rolling" simulation does not show the same # twice in a row
            int prev = 0;

            //Simulate rollinng of the dice
            for (int i = 0; i < 5; i++)
            {
                int value = r.Next(6) + 1;
                while (value == prev)
                {
                    value = r.Next(6) + 1;
                }
                DiceImage.Image = DetermineDiceImage(r.Next(6) + 1);
                DiceImage.Refresh();
                DiceImage.Visible = true;
                Thread.Sleep(500);
                prev = value;
            }
            DiceImage.Image = DetermineDiceImage(roll);
            DiceImage.Refresh();
            DiceImage.Visible = true;
            //Increment the number rolled by 1 as well as what the user guessed by 1
            RollCounter[roll - 1]++;
            Guesses[Convert.ToInt32(GuessEntry.Text) - 1]++;
            //If they won increment 0 by 1 else increment 1 by 1
            WinRatio[Convert.ToInt32(GuessEntry.Text) == roll ? 0 : 1]++;
            ResultsMessage.Text = Convert.ToInt32(GuessEntry.Text) == roll ? "You Win!" : "You Lost!";
            //Update the screen
            UpdateScreenValues();
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            int clickedPoint = RegisterInput();

            switch (State)
            {
            case GameState.Animating:
                if (!Board.InAnimation)
                {
                    if (NotifyPropertyChanged.Count != 0)
                    {
                        PlayAnimation(NotifyPropertyChanged[0]);
                    }
                    else
                    {
                        BeginTurn();
                    }
                }
                break;

            case GameState.PickChecker:
                if (MovableCheckers.Contains(clickedPoint))
                {
                    PickChecker(clickedPoint);
                }
                break;

            case GameState.PickDestination:
                if ((clickedPoint == SelectedPoint && !SelectedPoint.Equals(CurrentPlayer.GetBar())) || InputManager.Instance.GamePadButtonPressed(Buttons.B))
                {     // Cancel selected checker
                    BeginTurn();
                    AudioManager.Instance.PlaySound("MenuClick");
                }
                else if (ViewInterface.GetLegalMovesForCheckerAtPosition(SelectedPoint).Contains(clickedPoint))
                {
                    MoveChecker(clickedPoint);
                }
                break;
            }

            base.Update(gameTime);
            Image.Update(gameTime);
            GamePadArrow.Update(gameTime);
            Board.Update(gameTime);
            if (OptionScreen.ShowPips.SwitchedOn)
            {
                WhitePips.Text = "White: " + Model.GetGameBoardState().pip(White);
                BlackPips.Text = "Black: " + Model.GetGameBoardState().pip(Black);
                WhitePips.Update(gameTime);
                BlackPips.Update(gameTime);
            }
            foreach (Image DiceImage in DiceImages)
            {
                DiceImage.Update(gameTime);
            }
        }
예제 #3
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     Image.Draw(spriteBatch);
     GamePadArrow.Draw(spriteBatch);
     Board.Draw(spriteBatch);
     if (OptionScreen.ShowPips.SwitchedOn)
     {
         WhitePips.Draw(spriteBatch);
         BlackPips.Draw(spriteBatch);
     }
     foreach (Image DiceImage in DiceImages)
     {
         DiceImage.Draw(spriteBatch);
     }
 }
예제 #4
0
 public override void UnloadContent()
 {
     base.UnloadContent();
     Image.UnloadContent();
     GamePadArrow.UnloadContent();
     if (OptionScreen.ShowPips.SwitchedOn)
     {
         WhitePips.UnloadContent();
         BlackPips.UnloadContent();
     }
     foreach (Image DiceImage in DiceImages)
     {
         DiceImage.UnloadContent();
     }
 }
예제 #5
0
 /// <summary>
 /// Zeros out the Arrays as well as emptying out the messages that start out blank on the screen.
 /// Updates the current values on the screen.
 /// </summary>
 /// <param name="sender">Event Sender</param>
 /// <param name="e">Event Object</param>
 private void ResetButton_Click(object sender, EventArgs e)
 {
     //Zero out arrays
     Array.Clear(RollCounter, 0, RollCounter.Length);
     Array.Clear(Guesses, 0, Guesses.Length);
     Array.Clear(WinRatio, 0, WinRatio.Length);
     //Clear out the various messages as well as the input box.
     GuessEntry.Text     = "";
     ResultsMessage.Text = "";
     ErrorMessage.Text   = "";
     //Reset the dice picture
     DiceImage.Image = Properties.Resources.die1;
     DiceImage.Refresh();
     DiceImage.Visible = true;
     //Call the method to empty the counters and statistics.
     UpdateScreenValues();
 }
예제 #6
0
        private void GenerateDiceImages()
        {
            foreach (Image DiceImage in DiceImages)
            {
                DiceImage.UnloadContent();
            }
            DiceImages.Clear();

            for (int i = 0; i < DiceRolls.Count; i++)
            {
                DiceImages.Add(new Image()
                {
                    Path = "Images/" + DiceRolls[i], Scale = new Vector2(DiceScale, DiceScale), Position = new Vector2(DiceXPositions[i], Board.midY)
                });
            }
            foreach (Image DiceImage in DiceImages)
            {
                DiceImage.LoadContent();
            }
        }