Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.34 KB | None | 0 0
  1. public void GamePlay()
  2.         {
  3.             currentPlayer = Players[currentPlayerIndex];
  4.  
  5.             if (IsPlayerOut(currentPlayer) == false)
  6.             {
  7.                 if (Players[currentPlayerIndex].CurrentlyHasTurn == true)
  8.                 {
  9.                     if (currentPlayer.NeedsUserInput == true)
  10.                         HumanTurn(currentPlayer);
  11.                     else
  12.                         ComputerTurn(currentPlayer);
  13.                 }
  14.             }
  15.             else
  16.             {
  17.                 currentPlayerIndex++;
  18.             }
  19.             GamePlay();            
  20.         }
  21.  
  22.         public void HumanTurn(Player player)
  23.         {
  24.             #region Highlight and enable matching cards
  25.  
  26.             if (firstLoop == false)
  27.             {
  28.                 player.CurrentlyHasTurn = true;
  29.  
  30.                 foreach (Card card in player.PlayerHand)
  31.                 {
  32.                     if (CheckCards(card) == true)
  33.                     {
  34.                         HighlightCard(player, card);
  35.                         playableCards.Add(card);
  36.                     }
  37.                 }
  38.  
  39.                 foreach (var gridViewChild in player.PlayerGrid.Items)
  40.                 {
  41.                     if (gridViewChild is Border)
  42.                     {
  43.                         var border = gridViewChild as Border;
  44.                         var borderChild = border.Child;
  45.  
  46.                         if (borderChild is Button)
  47.                         {
  48.                             var button = borderChild as Button;
  49.                             if (playableCards.Contains(button.Tag as Card))
  50.                             {
  51.                                 ToggleButton(button);
  52.                             }
  53.                         }
  54.                     }
  55.                 }
  56.                 firstLoop = true;
  57.             }
  58.             #endregion
  59.  
  60.             if (playableCards.Count == 0)
  61.             {
  62.                 CantPlayCards(player);
  63.             }
  64.             else
  65.             {
  66.                 if (ClickedCard != null)
  67.                 {
  68.                     PlayCard(player, ClickedCard);
  69.                     ClickedCard = null;
  70.                     player.CurrentlyHasTurn = false;
  71.                     playableCards.Clear();
  72.                     currentPlayerIndex++;
  73.                 }
  74.             }
  75.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement