Example #1
0
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                EscapeMenu.SetActive(!EscapeMenu.activeSelf);
            }

            if (gameField == null)
            {
                return;
            }

            CurrentGameState = gameField.GameState;

            if (SpecialState != SpecialGameState.None)
            {
                return;
            }

            switch (gameField.GameState)
            {
            case GameFieldState.WaitingForConnection:
                infoText.text = "Waiting for opponent to connect";
                break;

            case GameFieldState.WaitingForRegistration:
                infoText.text = "Waiting for opponent to register";
                break;

            case GameFieldState.BothSelectingActive:
                infoText.text = "Select your active Pokémon";
                break;

            case GameFieldState.BothSelectingBench:
                infoText.text = "Select Pokémon to add to your bench";
                break;

            default:
                break;
            }

            EnableButtons();
        }
Example #2
0
        public void OnInfoUpdated(GameFieldInfo gameInfo, string textInfo)
        {
            OpponentPlayer.DiscardPile       = gameInfo.Opponent.CardsInDiscard;
            OpponentPlayer.PrizeCards        = gameInfo.Opponent.PrizeCards;
            OpponentPlayer.ActivePokemonCard = (PokemonCard)gameInfo.Opponent.ActivePokemon;
            OpponentPlayer.BenchedPokemon    = gameInfo.Opponent.BenchedPokemon;
            opponentInfoHandler.UpdateWithInfo(gameInfo.Opponent);

            if (OpponentPlayer != null && OpponentPlayer.ActivePokemonCard != null)
            {
                SetActivePokemon(opponentActivePokemon, OpponentPlayer.ActivePokemonCard);
            }

            Player.DiscardPile       = gameInfo.Me.CardsInDiscard;
            Player.PrizeCards        = gameInfo.Me.PrizeCards;
            Player.ActivePokemonCard = (PokemonCard)gameInfo.Me.ActivePokemon;
            Player.BenchedPokemon    = gameInfo.Me.BenchedPokemon;
            playerInfoHandler.UpdateWithInfo(gameInfo.Me);

            if (Player != null && Player.ActivePokemonCard != null)
            {
                SetActivePokemon(playerActivePokemon, Player.ActivePokemonCard);
            }

            IsMyTurn            = gameInfo.ActivePlayer.Equals(myId);
            CurrentGameState    = gameInfo.CurrentState;
            gameField.GameState = CurrentGameState;
            stadiumCard.SetCard(gameInfo.StadiumCard, false, false);
            gameField.StadiumCard = gameInfo.StadiumCard;

            if (!string.IsNullOrWhiteSpace(textInfo))
            {
                infoText.text = textInfo;
            }
            else
            {
                infoText.text = IsMyTurn ? "Your Turn!" : "Opponents turn";
            }

            SetInfoAndEnableButtons();
        }
Example #3
0
        private void CreateState()
        {
            var cards = new List <GameCard>();

            for (int i = 0; i < Constants.NumberOfCards; i++)
            {
                cards.Add(new GameCard
                {
                    Id       = i,
                    IsThrown = true,
                });
            }

            var state = new GameFieldState
            {
                Cards   = cards.ToArray(),
                Players = Array.Empty <Player>()
            };

            _memoryCache.Set(Constants.GameFieldStateKey, state);
        }
Example #4
0
        public void OnGameUpdated(object message, NetworkId messageId)
        {
            var gameMessage = message is GameFieldMessage ? ((GameFieldMessage)message).Game : (GameField)message;

            Debug.Log("Game updated, handling message");

            GameFieldState oldState = gameField.GameState;

            gameField = gameMessage;

            if (gameField.GameState == GameFieldState.WaitingForConnection)
            {
                return;
            }

            IsMyTurn     = gameField.ActivePlayer.Id.Equals(myId);
            SpecialState = SpecialGameState.None;
            selectColorPanel.gameObject.SetActive(false);
            selectedCards.Clear();
            selectFromListPanel.SetActive(false);

            SetInfoAndEnableButtons();

            Player me       = gameField.Players.First(p => p.Id.Equals(myId));
            Player opponent = gameField.Players.First(p => !p.Id.Equals(myId));

            playerHand.SetHand(me.Hand);

            SetActivePokemon(playerActivePokemon, me.ActivePokemonCard);
            SetActivePokemon(opponentActivePokemon, opponent.ActivePokemonCard);

            SetBenchedPokemon(playerBench, me.BenchedPokemon);
            SetBenchedPokemon(opponentBench, opponent.BenchedPokemon);

            stadiumCard.SetCard(gameField.StadiumCard, false, false);

            EnableButtons();
        }