Exemplo n.º 1
0
    private void StartNextSet()
    {
        Debug.Log("Starting Set" + setNumber);
        for (int i = 0; i < players.Count; i++)
        {
            players[i].ClearDeck();
            players[i].SetShowCard(false);
            players[i].ClearPreviousRoundScores();
        }
        DealtDeck.Clear();
        DiscardedDeck.Clear();

        for (int i = 0; i < players.Count; i++)
        {
            GameView.Instance.LoadClearMethod(i);
        }
        roundCounter = 1;
        ScoreBoard.Instance.ClearText();
        CardDistributionAnimation.instance.SetIsCardDistributionCompleted(false);
        DistributeCards();
        UnityMainThreadDispatcher.Schedule(
            CardDistributionAnimation.instance.PlayCardDistributionAnimationRoutine(true)
            , 0.5f);
        Debug.Log("Next Set Started");
    }
Exemplo n.º 2
0
 public void RestartGame()
 {
     UnityMainThreadDispatcher.Schedule(() =>
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene("Game");
     }, 0.5f);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Method to remove all the touched cards of Player
 /// deck if they belong to removable rules,
 /// and add them to discarded deck
 /// and add top card of discarded deck to Player deck
 /// </summary>
 /// <param name="player"></param>
 /// <param name="tempLongTouchedList"></param>
 public void MultiCardDiscardedDeckSwap(Player player, Deck tempLongTouchedList)
 {
     Debug.Log("Multi Card Discarded Deck Swap Started");
     if (HandCombination.IsStraight(player, tempLongTouchedList) == true || HandCombination.isThreeOfKind(player, tempLongTouchedList) == true)
     {
         tempLongTouchedList.SortByRankAsc();
         Card temp = DiscardedDeck.Deal();
         int  i    = 0;
         int  size = tempLongTouchedList.CardsCount();
         while (i < size)
         {
             Card removeCard = player.RemoveCard(tempLongTouchedList.GetCardByIndex(i));
             DiscardedDeck.Add(removeCard);
             i++;
             UnityMainThreadDispatcher.Schedule(SingleSwapAnimationFromDiscardedDeck(PlayerUIMapping.Instance.cardholder[currentPlayerIndex], removeCard,
                                                                                     CardDistributionAnimation.instance.playersPosition[currentPlayerIndex], false), 0.1f);
         }
         UnityMainThreadDispatcher.Schedule(SingleSwapAnimationFromDiscardedDeck(PlayerUIMapping.Instance.cardholder[currentPlayerIndex], null,
                                                                                 CardDistributionAnimation.instance.playersPosition[currentPlayerIndex], true), 0.1f);
         player.AddToHand(temp);
         tempLongTouchedList.Clear();
         GameView.Instance.isClearMethodCompleted = false;
         UnityMainThreadDispatcher.Schedule(() => GameView.Instance.LoadClearMethod(), Constants.clearMethodDelay);
         //UnityMainThreadDispatcher.Instance().Enqueue(SwitchTurnToNextPlayer(false, Constants.turnPlayerDelay));
         UnityMainThreadDispatcher.Schedule(() => SwitchTurnToNextPlayer(false, Constants.turnPlayerDelay), 0.5f);
     }
     Debug.Log("Multi Card Discarded Deck Swap Completed");
 }
Exemplo n.º 4
0
    /// <summary>
    /// Method to swap card between Dealt Deck
    /// and Player touched card
    /// </summary>
    /// <param name="player"></param>
    /// <param name="touchedCard"></param>
    public void SingleSwapFromDealtDeck(Player player, Card touchedCard)
    {
        Debug.Log("Inside Single Swap Dealt Deck Method");
        Card temp = DealtDeck.Deal();

        Debug.Log("Dealt Deck touched card" + temp.GetCardImageName());
        UnityMainThreadDispatcher.Schedule(SingleSwapAnimationFromDealtDeck(PlayerUIMapping.Instance.cardholder[currentPlayerIndex], touchedCard,
                                                                            CardDistributionAnimation.instance.playersPosition[currentPlayerIndex], true), 0.1f);
        //UnityMainThreadDispatcher.Instance().Enqueue(SingleSwapAnimationFromDealtDeck(PlayerUIMapping.Instance.cardholder[currentPlayerIndex], touchedCard,
        //    CardDistributionAnimation.instance.playersPosition[currentPlayerIndex], true));
        Debug.Log("Card to be swapped " + touchedCard.GetCardImageName());
        Card temp1 = player.RemoveCard(touchedCard);

        player.AddToHand(temp);
        DiscardedDeck.Add(temp1);
        this.touchedCard = null;
        if (DealtDeck.CardsCount() == 0)
        {
            Debug.Log("Dealt Deck empty refilling");
            RefillDeck();
        }
        UnityMainThreadDispatcher.Schedule(() => GameView.Instance.LoadClearMethod(), Constants.clearMethodDelay);
        UnityMainThreadDispatcher.Schedule(() => SwitchTurnToNextPlayer(false, Constants.turnPlayerDelay), 0.5f);
        //  UnityMainThreadDispatcher.Instance().Enqueue(SwitchTurnToNextPlayer(false, Constants.turnPlayerDelay));
        Debug.Log("Single Swap Dealt Deck Method Completed");
    }
Exemplo n.º 5
0
        public override void NotifyPlayerForTurn()
        {
            Debug.Log("Inside Notify AIPlayer For Turn Method for " + name);

            UnityMainThreadDispatcher.Schedule(() =>
            {
                ChoseActionToPlayAndInformListeners();
            },
                                               2.0f);
        }
Exemplo n.º 6
0
 public void StartGame()
 {
     currentPlayerIndex = rnd.Next(0, 6);
     if (DataManager.currentGameMode == GameMode.Computer)
     {
         UnityMainThreadDispatcher.Schedule(() =>
         {
             players[currentPlayerIndex].NotifyPlayerForTurn();
         }
                                            , 1.0f);
     }
     else
     {
         players[currentPlayerIndex].timeRemaining = Constants.maxTimer;
         Timer = true;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Method to start next round and switch turn to next player
 /// </summary>
 private void NextRound()
 {
     Debug.Log("Inside Next Round Logic Method, current round counter is " + roundCounter + " and set counter is" + setNumber);
     if (roundCounter <= Constants.totalrounds)
     {
         Debug.Log("Inside total round if case");
         UnityMainThreadDispatcher.Schedule(
             CardDistributionAnimation.instance.PlayCardDistributionAnimationRoutine(false)
             , 0.5f);
         UnityMainThreadDispatcher.Schedule(() => StartNextRound(), 0.5f);
         UnityMainThreadDispatcher.Schedule(() => SwitchTurnToNextPlayer(true, Constants.turnPlayerDelay), 0.5f);
     }
     else if (setNumber <= Constants.totalmatch)
     {
         Debug.Log("Inside total sets if case");
         UnityMainThreadDispatcher.Schedule(() => StartNextSet(), 0.5f);
         UnityMainThreadDispatcher.Schedule(() => SwitchTurnToNextPlayer(true, Constants.turnPlayerDelay), 0.5f);
     }
     else
     {
         Debug.Log("Game Over");
     }
 }
Exemplo n.º 8
0
    /// <summary>
    /// Method to determine winner player when minium is called
    /// and execute next round start instructions
    /// </summary>
    /// <param name="currentPlayer">Current player</param>

    public void CallMinium(Player currentPlayer)
    {
        Debug.Log("Inside Call Minium Method");
        Player winnerPlayer = null;;

        ShowMessage("Minimum!", currentPlayerIndex);
        UnityMainThreadDispatcher.Schedule(() =>
        {
            winnerPlayer = MinimumPlayer(currentPlayer);
        }
                                           , 1.0f);

        UnityMainThreadDispatcher.Schedule(() =>
        {
            ShowMessage("Winner!", players.IndexOf(winnerPlayer));
        }
                                           , 1.0f);
        UnityMainThreadDispatcher.Schedule(() =>
        {
            scoreboardPopup.ShowPopup();
        }
                                           , 5.0f);
        UnityMainThreadDispatcher.Schedule(() =>
        {
            scoreboardPopup.HidePopup();
        }
                                           , 5.0f);
        UnityMainThreadDispatcher.Schedule(() =>
        {
            NextRound();
        }
                                           , 1.0f);
        //UnityMainThreadDispatcher.Instance().Enqueue(SwitchTurnToNextPlayer(true, Constants.turnPlayerDelay));

        Debug.Log("Call Minimum Completed");
    }