예제 #1
0
        protected virtual void OnTurnConfirmedSelectedNumber()
        {
            //gameDataManager.RemoveCardValueFromPlayer(currentTurnPlayer, (byte)selectedRank);
            //TakeCardFromPileIfNeeded();
            if (currentTurnPlayer == localPlayer)
            {
                SetMessage($"Throw {selectedRank} to {currentTurnTargetPlayer.PlayerName}...");
            }
            else
            {
                SetMessage($"{currentTurnPlayer.PlayerName} has throwed {selectedRank}...");
            }

            //byte cardValueFromTargetPlayer = gameDataManager.TakeOneCardValueWithRankFromPlayer(currentTurnPlayer, selectedCard.Rank);

            //selectedCardValue = selectedCards[0].Value;
            //List<Byte> selectedCardValues = GetSelectedCardValues();
            //selectedCardValues;
            if (selectedCardValues.Count > 0)
            {
                //currentTurnPlayer.PutCardInStack(cardAnimator, selectedCard);
                bool senderIsLocalPlayer = currentTurnPlayer == localPlayer;

                String actionResult = currentTurnPlayer.SendDisplayingCardToStack(cardAnimator, selectedCardValues, senderIsLocalPlayer);

                if (actionResult == "")
                {
                    gameDataManager.RemoveCardValuesFromPlayer(currentTurnPlayer, selectedCardValues);   //selectedCard

                    if (cardAnimator.isTop4CardsAreSameRank())
                    {
                        cardAnimator.burnStackToDeathPile();
                        gameState = GameState.TurnSelectingNumber;
                    }
                    else if (Card.GetRank(selectedCardValues[0]) == Ranks.Ten || Card.GetRank(selectedCardValues[0]) == Ranks.Eight)
                    {
                        gameState = GameState.TurnSelectingNumber;
                    }

                    else
                    {
                        gameState = GameState.TurnStarted;
                    }

                    TakeCardFromPileIfNeeded();
                }
                else
                {
                    if (currentTurnPlayer.IsAI)
                    {
                        SetMessage("Take all the cards from the pile");

                        OnTakeStackCards();
                        gameState = GameState.TurnSelectingNumber;
                        GameFlow();
                    }
                    else
                    {
                        SetMessage(actionResult);

                        gameState = GameState.TurnSelectingNumber;
                        //GameFlow();
                    }
                }
            }
            else
            {
                SetMessage("Take all the cards from the pile");

                OnTakeStackCards();
                gameState = GameState.TurnSelectingNumber;
                GameFlow();
            }

            ResetSelectedCard();
        }