Ejemplo n.º 1
0
        public void CardListMessage()
        {
            var message = new CardListMessage(new List <NetworkId>()
            {
                NetworkId.Generate(), NetworkId.Generate(), NetworkId.Generate()
            });

            Assert.NotNull(SerializeAndBack(message));
        }
Ejemplo n.º 2
0
        public void DoneClick()
        {
            if (onlyView)
            {
                selectedCards?.Clear();
                gameObject.SetActive(false);
                if (GameController.Instance.SpecialState == SpecialGameState.LookingAtRevealedCards)
                {
                    NetworkManager.Instance.RespondingTo = null;
                }
                GameController.Instance.SpecialState = SpecialGameState.None;
                return;
            }
            else if (energyAmountToSelect > 0)
            {
                var amountSelected = selectedCards.OfType <EnergyCard>().Sum(card => card.GetEnergry().Amount);

                if (amountSelected < energyAmountToSelect)
                {
                    return;
                }

                GameController.Instance.SelectedEnergyForRetreat(selectedCards);
                selectedCards?.Clear();
                gameObject.SetActive(false);
                energyAmountToSelect = 0;

                return;
            }

            if (selectedCards.Count < minCount || selectedCards.Count > limit)
            {
                return;
            }

            var message = new CardListMessage(selectedCards.Select(card => card.Id).ToList());

            NetworkManager.Instance.SendToServer(message, true);

            GameController.Instance.OnCardPicked();

            selectedCards.Clear();
            gameObject.SetActive(false);
        }
Ejemplo n.º 3
0
        private void OnSelectPokemonWithFilter(CardRenderer clickedCard)
        {
            if (currentDeckFilters == null || currentDeckFilters.All(f => f.IsCardValid(clickedCard.card)))
            {
                if (Player.Hand.Contains(clickedCard.card))
                {
                    return;
                }
                else if (minSelectedCardCount == 1 && maxSelectedCardCount == 1)
                {
                    var message = new CardListMessage(new[] { clickedCard.card.Id }.ToList());
                    NetworkManager.Instance.SendToServer(message, true);
                    SpecialState  = SpecialGameState.None;
                    infoText.text = string.Empty;
                    currentDeckFilters.Clear();
                    return;
                }

                ToggleCardSelected(clickedCard);
            }
        }
Ejemplo n.º 4
0
        public void DoneButtonClicked()
        {
            if (gameField.GameState == GameFieldState.GameOver)
            {
                EnableButtons();
                SceneManager.LoadScene("MainMenu");
                return;
            }
            if (gameField.GameState == GameFieldState.BothSelectingBench)
            {
                NetworkManager.Instance.gameService.AddToBench(gameField.Id, myId, selectedCards.OfType <PokemonCard>().Select(card => card.Id).ToList());
                selectedCards.Clear();
            }
            else if (SpecialState == SpecialGameState.SelectingFromList)
            {
                var message = new CardListMessage(selectedCards.Select(card => card.Id).ToList());
                NetworkManager.Instance.SendToServer(message, true);
                SpecialState  = SpecialGameState.None;
                infoText.text = string.Empty;
            }
            else if (SpecialState == SpecialGameState.LookingAtRevealedCards)
            {
                NetworkManager.Instance.RespondingTo = null;
                return;
            }
            else if (SpecialState == SpecialGameState.SelectingOpponentsPokemon ||
                     SpecialState == SpecialGameState.SelectPokemonMatchingFilter)
            {
                if (selectedCards.Count < minSelectedCardCount || selectedCards.Count > maxSelectedCardCount)
                {
                    return;
                }

                foreach (var selectedCard in selectedCards)
                {
                    GetCardRendererById(selectedCard.Id).SetSelected(false);
                }

                var message = new CardListMessage(selectedCards.Select(card => card.Id).ToList());
                NetworkManager.Instance.SendToServer(message, true);
                SpecialState  = SpecialGameState.None;
                infoText.text = string.Empty;
                currentDeckFilters.Clear();
            }
            else if (SpecialState == SpecialGameState.SelectingOpponentsBenchedPokemon ||
                     SpecialState == SpecialGameState.SelectingYourBenchedPokemon ||
                     SpecialState == SpecialGameState.DiscardingCards)
            {
                if (selectedCards.Count < minSelectedCardCount || selectedCards.Count > maxSelectedCardCount)
                {
                    return;
                }

                foreach (var selectedCard in selectedCards)
                {
                    GetCardRendererById(selectedCard.Id).SetSelected(false);
                }

                var message = new CardListMessage(selectedCards.Select(card => card.Id).ToList());
                NetworkManager.Instance.SendToServer(message, true);
                SpecialState  = SpecialGameState.None;
                infoText.text = string.Empty;
                selectedCards.Clear();
                currentDeckFilters.Clear();
            }

            NetworkManager.Instance.RespondingTo = null;
            EnableButtons();
            currentDeckFilters.Clear();
        }