예제 #1
0
파일: Card.cs 프로젝트: Nibkat/gamelab
        public void Quartet(Player.Corner corner, Vector2 wantedPosition)
        {
            Task.Factory.StartNew(() =>
            {
                // Sorry for this stupid hack but this will take care that it's in the correct state and doesn't 
                // show the card to all the players in a big size instead, but gets it in a row!
                k = true;
                
                Hidden = false;
                lerpSpeed *= 2;
                
                SetWantedPosition(wantedPosition);

                Task.Delay(5000).Wait();

                Vector2 cornerPosition = new Vector2();
                bool right, down;
                string cornerstring = corner.ToString().ToLower();
                right = cornerstring.Contains("right");
                down = cornerstring.StartsWith("down");

                if (right) cornerPosition.X = Screen.Width;
                else cornerPosition.X = -Width;

                if (down) cornerPosition.Y = Screen.Height;
                else cornerPosition.Y = -Height;
                
                SetWantedPosition(cornerPosition);
                SetWantedSize(new Vector2(0));

                Task.Delay(4000).Wait();

                SceneManager.CurrentScene.Destroy(this);
            });
        }
예제 #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();
            }
        }