예제 #1
0
        public void ChangeBiddingStatus(BidSuit bidType)
        {
            ChangeStatusText(string.Empty);
            BidSuitImg.sprite = null;
            BidSuitImg.color  = Color.clear;
            HandCountText.gameObject.SetActive(false);

            if (bidType == BidSuit.PASS)
            {
                if (!ThisPlayerView.AreOtherPlayersMadeAnyBids)
                {
                    ChangeStatusText("Pass");
                }
                else
                {
                    ChangeStatusText("Take");
                }
            }
            else
            {
                BidSuitImg.sprite         = BidSuitsSprites[(int)bidType - 1];
                BidSuitImg.color          = Color.white;
                BidSuitImg.preserveAspect = true;
            }
        }
예제 #2
0
 public void ChangeAvailableSuits(BidSuit[] availableSuits)
 {
     Debug.Log($"ChangeAvailableSuits: {availableSuits.ToStringAll()}", this);
     for (int i = 0; i < BitSuitsButtons.Length; i++)
     {
         BidSuit buttonSuit = (BidSuit)i;
         BitSuitsButtons[i].gameObject.SetActive(availableSuits.Contains(buttonSuit));
     }
 }
예제 #3
0
 public void EndBidding(BidSuit result)
 {
     if (SelectedBiddingSuit == null)            //not allowed to change decision
     {
         SelectedBiddingSuit = result;
     }
     PlayerState = PlayerState.WaitOtherPlayerBidding;
     CmdEndBidding(result);
 }
예제 #4
0
 private void CmdEndBidding(BidSuit result)
 {
     if (SelectedBiddingSuit == null)            //is in time (server doesn't pass this player)
     {
         SelectedBiddingSuit = result;
     }
     PlayerState = PlayerState.WaitOtherPlayerBidding;
     RpcEndBidding(result);
 }
예제 #5
0
        private void Awake()
        {
            for (int i = 0; i < BitSuitsButtons.Length; i++)
            {
                BidSuit buttonSuit = (BidSuit)i;
                BitSuitsButtons[i].onClick.AddListener(() => NotifySuitSelected(buttonSuit));
            }

            scale = transform.localScale;
        }
예제 #6
0
 public void DisableLeaveButton()
 {
     for (int i = 0; i < BitSuitsButtons.Length; i++)
     {
         BidSuit buttonSuit = (BidSuit)i;
         if (buttonSuit == BidSuit.PASS)
         {
             BitSuitsButtons[i].GetComponentInChildren <Text>().text = "PASS";
         }
         BitSuitsButtons[i].gameObject.SetActive(false);
     }
 }
예제 #7
0
        private void RpcEndBidding(BidSuit result)
        {
            if (isLocalPlayer)
            {
                return;
            }

            Debug.Log($"RpcEndBidding", this);
            if (SelectedBiddingSuit == null)            //not allowed to change decision
            {
                SelectedBiddingSuit = result;
            }
            PlayerState = PlayerState.WaitOtherPlayerBidding;
        }
예제 #8
0
 private void ResetPlayer()
 {
     IsBiddingWinner                    = false;
     SelectedBiddingSuit                = null;
     PlayerCards                        = new Card[0];
     PlayerState                        = PlayerState.Connected;
     AvailableBiddingSuits              = new BidSuit[0];
     TwoBiddingCardsForFirstPlayer      = null;
     TwoExtraCardsSelectedByFirstPlayer = null;
     PlayerMoveCard                     = null;
     RoundParticipation                 = null;
     RoundTrump           = 0;
     WinHandPlayerPlaceId = -1;
     RoundScore           = new RoundScore[0];
 }
예제 #9
0
 private void LeaveSelected(BidSuit suit)
 {
     PlayerView.BiddingPanel.BidSuitSelected.RemoveAllListeners();
     PlayerView.BiddingPanel.Hide();
     PlayerView.NetworkPlayer.EndMakeMoveWithPass();
 }
예제 #10
0
 private void BiddingSuitSelected(BidSuit suit)
 {
     PlayerView.BiddingPanel.BidSuitSelected.RemoveAllListeners();
     PlayerView.BiddingPanel.Hide();
     PlayerView.NetworkPlayer.EndBidding(suit);
 }
예제 #11
0
 private void NotifySuitSelected(BidSuit suit)
 {
     AudioManager.Instance.PlaySound(Resources.Load <AudioClip>("Audio/Sounds/Game Button Click Sound"));
     BidSuitSelected.Invoke(suit);
 }
예제 #12
0
 public static Suit ToSuit(this BidSuit biddingSuit)
 {
     return((Suit)(int)((biddingSuit == BidSuit.SNIP) ? BidSuit.SPADE : biddingSuit));
 }
예제 #13
0
파일: GameCircle.cs 프로젝트: Hayq/Porjects
        public void BiddingCompleted(NetworkPlayer firstMovePlayer, NetworkPlayer wonBiddingPlayer, BidSuit trump)
        {
            Debug.Log($"BiddingCompleted. Player {firstMovePlayer.gameObject} won.");

            RoundState.RunState(firstMovePlayer, wonBiddingPlayer, trump.ToSuit(), GamePlayers.ToArray());
        }
예제 #14
0
        /// <summary>
        /// Variants of complete:
        /// 1. one of players selected bid and 2 other selected PASS
        /// 2. all selected PASS.
        /// </summary>
        /// <param name="shuffledPlayerList"></param>
        /// <returns></returns>
        private IEnumerator MainBidding(NetworkPlayer[] shuffledPlayerList)
        {
            BidSuit previousBiggestSuit = BidSuit.PASS;            //nobody made any bid by default

            while (true)
            {
                foreach (NetworkPlayer player in shuffledPlayerList)
                {
                    Debug.Log("MainBidding. " + player.gameObject.ToString(), player);

                    //previous player selected max available bit
                    if (previousBiggestSuit == BidSuit.SNIP)
                    {
                        //player.SelectedBiddingSuit = BidSuit.PASS; //all next player passes
                        continue;
                    }

                    if (player.SelectedBiddingSuit != null && player.SelectedBiddingSuit == previousBiggestSuit)
                    {
                        //that player, who selected biggest bid in previous iteration,
                        //just waits until other players make bigger bid in this
                        continue;
                    }

                    var allVariants = EnumExtender.GetAllVariants <BidSuit>();

                    //it's forbiden to take SPADE before you have 2 extra cards (in second bidding)
                    BidSuit[] forbiddenChoices = { BidSuit.SPADE };

                    if (previousBiggestSuit != BidSuit.PASS)
                    {
                        //next bid must be bigger than previous
                        forbiddenChoices = allVariants
                                           .Where(suit => suit <= previousBiggestSuit && suit != BidSuit.PASS)
                                           .ToArray();
                    }

                    var availableChoices = allVariants.Except(forbiddenChoices).ToArray();

                    yield return(StartCoroutine(MakeBidding(player, availableChoices)));

                    if (player.SelectedBiddingSuit.Value > previousBiggestSuit)                     //player made bigger bid
                    {
                        previousBiggestSuit = player.SelectedBiddingSuit.Value;
                    }
                }

                if (IsTwoPassBids(shuffledPlayerList))
                {
                    break;                               //2 or more player selected PASS
                }
                if (previousBiggestSuit == BidSuit.SNIP) //selected max possible bid
                {
                    ////all player pass to that one who selected SNIP
                    //foreach (NetworkPlayer player in shuffledPlayerList)
                    //	if (player.SelectedBiddingSuit != BidSuit.SNIP)
                    //		player.SelectedBiddingSuit = BidSuit.PASS;
                    break;
                }
            }
        }