Ejemplo n.º 1
0
        private void RpcPlayCard(int[] cardsPlayedInRound, Suit playedSuit, Suit trumpSuit)
        {
            if (!isLocalPlayer)
            {
                return;
            }
            DebugConsole.Log(Name + " received prompt to play a card");
            _isMyPlayTurn     = true;
            _currentRoundInfo = new RuleHelpers.RoundInfo
            {
                CardsPlayedInRound = FindObjectsOfType <MBCard>().Where(a => cardsPlayedInRound.Contains(a.ID)).Select(a => (ICard)a).ToList(),
                PlayedSuit         = playedSuit,
                TrumpSuit          = trumpSuit
            };

            if (_bot)
            {
                _isMyPlayTurn = false;
                CmdPickedCard(HandCards.First(a => RuleHelpers.IsValidPlay(a, HandCards.Except(_playedCards).ToList(), _currentRoundInfo)).ID);
            }
        }
Ejemplo n.º 2
0
        private void Start()
        {
            Id   = (int)netId.Value;
            Name = "Player " + Id;
            if (OnPlayerJoined != null)
            {
                OnPlayerJoined(this);
            }

            _organizer = new CardOrganizer(isLocalPlayer, 10, .5f, .45f, 0);

            BidGui.OnBidSubmitted += bid =>
            {
                if (!_isMyTurnToBid || !isLocalPlayer)
                {
                    return;
                }
                CmdBid(bid);
                _isMyTurnToBid = false;
                FindObjectOfType <BidGui>().Hide();
            };

            SeatManager.OnClickedSit += pos =>
            {
                if (isLocalPlayer)
                {
                    IsSeated  = true;
                    _position = (int)pos;
                    CmdSit(pos);
                    Camera.main.transform.rotation = Quaternion.LookRotation(Vector3.forward, -RuleHelpers.GetHandPosition(pos));
                }
            };
            FourPlayerGameManager.OnScoreUpdate += (i, score) =>
            {
                RpcGotScores(i, score);
            };
            Interactable.OnCardEvent += (type, card) =>
            {
                if (!_isMyPlayTurn || !isLocalPlayer || _playedCards.Contains(card))
                {
                    return;
                }
                switch (type)
                {
                case Interactable.CardEventType.MouseOver:
                    if (RuleHelpers.IsValidPlay(card, HandCards.Except(_playedCards).ToList(), _currentRoundInfo))
                    {
                        card.Movable.Grow();
                    }
                    break;

                case Interactable.CardEventType.MouseExit:
                    card.Movable.Shrink();
                    break;

                case Interactable.CardEventType.MouseDown:
                    if (RuleHelpers.IsValidPlay(card, HandCards.Except(_playedCards).ToList(), _currentRoundInfo))
                    {
                        _isMyPlayTurn = false;
                        CmdPickedCard(card.ID);
                    }
                    else
                    {
                        DebugConsole.Log(card + " is not a valid play");
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            };
        }