예제 #1
0
        public void SetTrick(ITrick trick)
        {
            _trick       = trick;
            _playedIndex = 0;
            _offset      = -400;
            if (!IsTrickSet)
            {
                Table.PlayedCards = new AndroidCard[trick.Count()];
                IsTrickSet        = true;
            }

            var score  = trick.TrickValue();
            var winner = trick.TheWinnerPlayer();

            _roundStats[0].Text = "Trick Score: " + score.ToString();
            _roundStats[1].Text = "Round Winner: " + winner.Name;
            foreach (var cardPlayerPair in _trick)
            {
                var card = cardPlayerPair.Item2;
                if (card == null)
                {
                    continue;
                }
                var cardtexture = Table.GameContent.TextureDict[card];
                var trickCard   = new AndroidCard(cardtexture, card)
                {
                    Position = new Vector2((Table.ScreenWidth / 2 + _offset), Table.ScreenHeight / 4.0f)
                };
                _offset          += 150;
                trickCard.State   = StateType.Playing;
                trickCard.IsTrick = true;
                Table.PlayedCards[_playedIndex++] = trickCard;
            }
        }
예제 #2
0
 public void AddCardToHand(AndroidCard card)
 {
     if (card == null)
     {
         return;
     }
     PlayableCards[_handCount] = card;
     _handCount++;
 }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            foreach (var component in _components)
            {
                component.Update(gameTime);
            }
            foreach (var card in Table.BlindList)
            {
                card.State = StateType.Picking;
                if (_numCardsSelected > 2)
                {
                    card.IsSelected = false;
                    _numCardsSelected--;
                }
                if (card.IsSelected)
                {
                    _blindCard = card;
                    _numCardsSelected++;
                }
                card.Update(gameTime);
            }
            foreach (var player in Table.PlayerGraphicsDict)
            {
                if (!(player.Key is LocalPlayer))
                {
                    continue;
                }
                var playerCards = player.Value.PlayableCards;
                if (playerCards == null)
                {
                    continue;
                }
                foreach (var card in playerCards)
                {
                    card.State = StateType.Picking;
                    if (_numCardsSelected > 2)
                    {
                        card.IsSelected = false;
                        _numCardsSelected--;
                    }

                    if (card.IsSelected)
                    {
                        _handCard = card;
                        _numCardsSelected++;
                    }
                    card.Update(gameTime);
                }
            }
        }
예제 #4
0
        public void SetTrick(ITrick trick)
        {
            _trick       = trick;
            _playedIndex = 0;
            _offset      = -400;

            if (!IsTrickSet)
            {
                Table.PlayedCards = new AndroidCard[trick.Count()];
                IsTrickSet        = true;
            }
            if (!LeaderboardSet)
            {
                SetScoreboard();
                LeaderboardSet = true;
            }

            foreach (var cardPlayerPair in _trick)
            {
                var card = cardPlayerPair.Item2;
                if (card == null)
                {
                    continue;
                }
                var cardtexture = Table.GameContent.TextureDict[card];
                var trickCard   = new AndroidCard(cardtexture, card)
                {
                    Position = new Vector2((Table.ScreenWidth / 2 + _offset), Table.ScreenHeight / 4.0f)
                };
                _offset          += 150;
                trickCard.State   = StateType.Playing;
                trickCard.IsTrick = true;
                var player = cardPlayerPair.Item1;
                _leaderboardpanel[_playedIndex].PlayerName = player.Name;
                _leaderboardpanel[_playedIndex].Text       = "Card Played: ";
                _leaderboardpanel[_playedIndex].Card       = trickCard;

                Table.PlayedCards[_playedIndex++] = trickCard;
            }
        }
예제 #5
0
        public AndroidPlayState(AndroidSheepGame table, GraphicsDevice graphicsDevice, GameContent gameContent) : base(table, graphicsDevice, gameContent)
        {
            _selectedPlayCard = null;
            _wantsToPlay      = false;
            IsTrickSet        = false;
            _areBarsSet       = false;
            LeaderboardSet    = false;
            AndroidButton rankInfo = new AndroidButton(Table.GameContent.Ranks, Table.GameContent.Font)
            {
                Position = new Vector2(0, Table.ScreenHeight / 2 - 100)
            };

            _pickerInfo = new AndroidButton(Table.GameContent.Button3, Table.GameContent.Font)
            {
                Position = new Vector2(Table.ScreenWidth * 0.8f, Table.ScreenHeight * 0.25f)
            };
            _components = new List <AndroidButton>()
            {
                rankInfo,
                _pickerInfo
            };
        }
예제 #6
0
 public override void Update(GameTime gameTime)
 {
     foreach (var player in Table.PlayerGraphicsDict)
     {
         if (!(player.Key is LocalPlayer))
         {
             continue;
         }
         var playerCards = player.Value.PlayableCards;
         if (playerCards == null)
         {
             continue;
         }
         foreach (var card in playerCards)
         {
             if (card.Played)
             {
                 _selectedPlayCard = card;
             }
             card.State = StateType.Playing;
             card.Update(gameTime);
         }
     }
 }
예제 #7
0
        private string Prompt(PromptType promptType, Dictionary<PromptData, object> data)
        {
            string prompt = "";
            ITrick trick = null;
            IPlayer player = null;
            IPlayer picker = null;
            switch (promptType)
            {
                case PromptType.CardsDealt:
                    PlayerGraphicsDict = new Dictionary<IPlayer, AndroidPlayer>();
                    var blinddata = (IBlind)data[PromptData.Blind];
                    foreach (var addPlayer in _table.Players)
                    {
                        AndroidPlayer hostGraphics = new AndroidPlayer(addPlayer);
                        PlayerGraphicsDict.Add(addPlayer, hostGraphics);
                    }
                    var blindLoc = 250;
                    var blindIndex = 0;
                    foreach (var addBlind in blinddata)
                    {
                        var cardtexture = GameContent.TextureDict[addBlind];
                        var cardGraphics = new AndroidCard(cardtexture, addBlind)
                        {
                            IsBlind = true,
                            Position = new Vector2(blindLoc, ScreenHeight / 4.0f)
                        };
                        BlindList[blindIndex] = cardGraphics;
                        blindIndex++;
                        blindLoc += 500;
                    }
                    foreach (var playerPair in PlayerGraphicsDict)
                    {
                        var playerGraphicsHand = playerPair;
                        var playerHand = playerPair.Key.Hand;
                        var screen = ScreenWidth / 2 - 500;
                        foreach (var card in playerHand)
                        {
                            var cardtexture = GameContent.TextureDict[card];
                            var cardGraphics = new AndroidCard(cardtexture, card)
                            {
                                Position = new Vector2(screen, ScreenHeight - 200)
                            };
                            playerGraphicsHand.Value.AddCardToHand(cardGraphics);
                            screen += 150;
                        }
                    }
                    ChangeState(new AndroidPreGameState(this, _graphics.GraphicsDevice, GameContent));
                    State = StateType.PreGame;
                    
                    break;
                    
                case PromptType.Pick:
                    ChangeState(_blindState);
                    State = StateType.Blind;
                    prompt = _blindState.PickingPrompt();
                    _blindState.Prompt = "";
                    break;

                case PromptType.BotPlayCard:
                    break;

                case PromptType.PlayCard:
                    State = StateType.Playing;                   
                    picker = (IPlayer)data[PromptData.Picker];
                    player = (IPlayer)data[PromptData.Player];
                    trick = (ITrick)data[PromptData.Trick];
                    ChangeState(_playingState);
                    _playingState.SetTrick(trick);
                    _playingState.SetPicker(picker);
                    var cards = (List<ICard>)data[PromptData.Cards];
                    PlayableCards = new List<AndroidCard>();
                    PlayerGraphicsDict.TryGetValue(player, out var playergraphics);
                    foreach (var card in cards)
                    {
                        if (playergraphics == null) continue;
                        foreach (var cardgraphics in playergraphics.PlayableCards)
                        {
                            if (!card.Equals(cardgraphics.Card)) continue;
                            PlayableCards.Add(cardgraphics);
                            cardgraphics.IsPlayable = true;
                            break;
                        }
                    }
                    prompt = _playingState.PickingPrompt();
                    if (prompt != "")
                    {
                        _playingState.IsTrickSet = false;
                        _playingState.LeaderboardSet = false;
                    }

                    break;

                case PromptType.PickBlind:
                    State = StateType.Picking;
                    player = (IPlayer)data[PromptData.Player];
                    var blind = (IBlind)data[PromptData.Blind];
                    _pickingState.AssignBlind(blind);
                    _pickingState.AssignPlayer(player);
                    ChangeState(_pickingState);
                    prompt = _pickingState.PickingPrompt();
                    _pickingState.Prompt = "";
                    break;

                case PromptType.RoundOver:
                    trick = ((IRound)data[PromptData.Round]).Trick;
                    ChangeState(_roundOverState);
                    State = StateType.RoundOver;
                    _roundOverState.SetTrick(trick);
                    prompt = _roundOverState.PickingPrompt();
                    if (prompt != "")
                    {
                       _roundOverState = new AndroidRoundOverState(this, _graphics.GraphicsDevice, GameContent);
                    }
                    break;

                case PromptType.GameOver:
                    ChangeState(_gameOverState);
                    State = StateType.GameOver;
                    var game = (IGame)data[PromptData.Game];
                    _gameOverState.SetGame(game);
                    _gameOverState.SetSharedSheepTable(_table);
                    _gameOverState.SetScoreSheet(_table.ScrSheet);
                    prompt = _gameOverState.PickingPrompt();
                    break;

                case PromptType.TableOver:
                    ChangeState(_tableOverstate);
                    State = StateType.TableOver;
                    _tableOverstate.SetSharedSheepTable(_table);
                    _tableOverstate.SetScoreSheet(_table.ScrSheet);
                    prompt = _tableOverstate.PickingPrompt();
                    if (prompt == "done")
                        this.Exit();
                    else if (prompt == "playAgain")
                    {
                        _titleState = new AndroidTitleScreen(this, _graphics.GraphicsDevice, GameContent);
                        ChangeState(_titleState);
                    }
                    break;

                case PromptType.CallUp:
                    prompt = "Would you like to call up? (yes/no): ";
                    break;

                case PromptType.CalledUp:
                    prompt = string.Format("\nPicker called up to {0}\n", _table.Games.Last().PartnerCard);
                    break;

                default:
                    return "";
            }
            return prompt;
        }
예제 #8
0
        public string PickingPrompt()
        {
            Prompt = "";
            if (_isDone)
            {
                Prompt += "done";
            }
            else if (_numCardsSelected == 2 && _wantsToSwap)
            {
                int         cardOne    = 0;
                int         cardTwo    = 0;
                IHand       playerHand = Player.Hand;
                AndroidCard newBlind   = null;
                AndroidCard newHand    = null;
                foreach (var card in Blind)
                {
                    if (_blindCard.Card.Equals(card))
                    {
                        _blindCard.ChangeSelectionPicking();
                        newHand = new AndroidCard(_blindCard.Texture, _blindCard.Card)
                        {
                            Position = new Vector2(_handCard.Position.X, _handCard.Position.Y + 40),
                            State    = _handCard.State,
                            IsBlind  = true
                        };
                        break;
                    }
                    cardOne++;
                }
                foreach (var card in playerHand)
                {
                    if (_handCard.Card.Equals(card))
                    {
                        _handCard.ChangeSelectionPicking();
                        newBlind = new AndroidCard(_handCard.Texture, _handCard.Card)
                        {
                            Position = new Vector2(_blindCard.Position.X, _blindCard.Position.Y),
                            State    = _blindCard.State,
                            IsBlind  = false
                        };
                        break;
                    }
                    cardTwo++;
                }

                Prompt = $"{cardOne} {cardTwo}";
                foreach (var component in _components)
                {
                    component.Color = Color.White;
                }
                Table.BlindList[cardOne] = newBlind;
                _graphicsPlayer.PlayableCards[cardTwo] = newHand;
                _numCardsSelected = 0;
                _handCard         = null;
                _blindCard        = null;
                _wantsToSwap      = false;
            }

            _isDone = false;
            return(Prompt);
        }
예제 #9
0
        public string PickingPrompt()
        {
            _prompt      = "";
            _playedIndex = 0;

            foreach (var player in Table.PlayerGraphicsDict)
            {
                if (!(player.Key is LocalPlayer))
                {
                    continue;
                }
                var playerCards = player.Value.PlayableCards;
                if (playerCards == null)
                {
                    continue;
                }
                _playedIndex = 0;
                foreach (var card in playerCards)
                {
                    if (card.Played)
                    {
                        _selectedPlayCard = card;
                    }
                    _playedIndex++;
                }
            }

            if (_selectedPlayCard == null)
            {
                return(_prompt);
            }
            {
                _playedIndex = 0;
                foreach (var card in Table.PlayableCards)
                {
                    if (card.Equals(_selectedPlayCard))
                    {
                        _prompt = _playedIndex.ToString();
                        break;
                    }
                    _playedIndex++;
                }
                foreach (var player in Table.PlayerGraphicsDict)
                {
                    if (!(player.Key is LocalPlayer))
                    {
                        continue;
                    }
                    var           playerCards      = player.Value.PlayableCards;
                    AndroidCard[] newPlayableCards = new AndroidCard[playerCards.Length - 1];
                    if (playerCards == null)
                    {
                        continue;
                    }
                    _playedIndex = 0;
                    foreach (var card in playerCards)
                    {
                        if (!card.Played)
                        {
                            newPlayableCards[_playedIndex] = card;
                            _playedIndex++;
                        }
                        else
                        {
                            card.Played       = false;
                            _selectedPlayCard = null;
                        }
                    }
                    player.Value.PlayableCards = newPlayableCards;
                    foreach (var card in playerCards)
                    {
                        card.IsPlayable = false;
                    }
                }
            }
            return(_prompt);
        }