コード例 #1
0
 private void DropConnection(ServerStatusHandler.ClientMessage clientMessage)
 {
     clientMessage.ServerStatus.Send(
         new ServerMessage
         <ServerStatusHandler.EmptyInfo>(ServerToClientStatuses.DropConnection, new ServerStatusHandler.EmptyInfo()));
     clientMessage.ServerStatus.DropConnection();
 }
コード例 #2
0
        private void OnQuestion(ServerStatusHandler.ClientMessage obj)
        {
            // TODO : Process the question
            var processedCard = ProcessQuestion(obj.Data);
            var player        = Game.GetPlayer(obj.ID);

            // get the hand of that player
            var askedPlayer = Game.GetPlayer(processedCard.id);

            if (askedPlayer == null)
            {
                throw new Exception("Couldn't find the player.");
            }

            var card = askedPlayer.CardsInHand.FirstOrDefault(x =>
                                                              x.ServerCard.cardName.ToLower() == processedCard.name.ToLower() &&
                                                              x.ServerCard.category.ToString().ToLower() == processedCard.category.ToLower());

            currentDisplayTime = 0;
            askedCorner        = player.PlayerCorner;
            responseCorner     = askedPlayer.PlayerCorner;
            question           = $"{askedPlayer.Name},\nHeb jij van {processedCard.category},\n{processedCard.name}?";

            bool foundCard = card != null;

            if (foundCard)
            {
                askedPlayer.RemoveCard(card);
                player.AddCard(card);

                card.ShowOnCenter(player);

                response = "yep verdomme man";

                AnnouncePlayerTurnStart();
            }
            else
            {
                // if the card has NOT been found, just start the next turn I guess? OH! And give the player a card!

                var poppedCard = Game.PopCard();
                if (poppedCard != null)
                {
                    player.AddCard(poppedCard);
                }
                Game.SortCardsOnTable(); // sort the cards on the table.

                response = "haha nee";

                StartNextTurn();
            }
        }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: Nibkat/gamelab
        public void TryStartGame(ServerStatusHandler.ClientMessage message)
        {
            if (Game.PlayersConnected.Count < 2)
            {
                return;
            }

            WebServer.Unsubscribe(ClientToServerStatus.StartGame, TryStartGame);

            // Announce that the game has started !

            WebServer.SendToAll(new ServerMessage <ServerStatusHandler.EmptyInfo>(ServerToClientStatuses.StartGame,
                                                                                  new ServerStatusHandler.EmptyInfo()));

            // Switch to the game scene ( epic )
            SwitchScene(typeof(CardGameScene));
        }