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; } }
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)); } }
public void EndBidding(BidSuit result) { if (SelectedBiddingSuit == null) //not allowed to change decision { SelectedBiddingSuit = result; } PlayerState = PlayerState.WaitOtherPlayerBidding; CmdEndBidding(result); }
private void CmdEndBidding(BidSuit result) { if (SelectedBiddingSuit == null) //is in time (server doesn't pass this player) { SelectedBiddingSuit = result; } PlayerState = PlayerState.WaitOtherPlayerBidding; RpcEndBidding(result); }
private void Awake() { for (int i = 0; i < BitSuitsButtons.Length; i++) { BidSuit buttonSuit = (BidSuit)i; BitSuitsButtons[i].onClick.AddListener(() => NotifySuitSelected(buttonSuit)); } scale = transform.localScale; }
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); } }
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; }
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]; }
private void LeaveSelected(BidSuit suit) { PlayerView.BiddingPanel.BidSuitSelected.RemoveAllListeners(); PlayerView.BiddingPanel.Hide(); PlayerView.NetworkPlayer.EndMakeMoveWithPass(); }
private void BiddingSuitSelected(BidSuit suit) { PlayerView.BiddingPanel.BidSuitSelected.RemoveAllListeners(); PlayerView.BiddingPanel.Hide(); PlayerView.NetworkPlayer.EndBidding(suit); }
private void NotifySuitSelected(BidSuit suit) { AudioManager.Instance.PlaySound(Resources.Load <AudioClip>("Audio/Sounds/Game Button Click Sound")); BidSuitSelected.Invoke(suit); }
public static Suit ToSuit(this BidSuit biddingSuit) { return((Suit)(int)((biddingSuit == BidSuit.SNIP) ? BidSuit.SPADE : biddingSuit)); }
public void BiddingCompleted(NetworkPlayer firstMovePlayer, NetworkPlayer wonBiddingPlayer, BidSuit trump) { Debug.Log($"BiddingCompleted. Player {firstMovePlayer.gameObject} won."); RoundState.RunState(firstMovePlayer, wonBiddingPlayer, trump.ToSuit(), GamePlayers.ToArray()); }
/// <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; } } }