示例#1
0
        /// <summary>
        /// Drop Card on drop zone
        /// </summary>
        /// <param name="card"></param>
        /// <param name="moveCard">card's value</param>
        /// <param name="player"></param>
        public void Drop(CardBehaviour moveCard, NetworkPlayerView player)
        {
            if (droppedCards.ContainsKey(moveCard))
            {
                return;
            }

            droppedCards.Add(moveCard, player);
            SetParent(moveCard.transform, player);
        }
示例#2
0
        public override GameObject InstantiateCardForPlayerHand(Card card)
        {
            GameObject cardObject = Instantiate(CardPrefab, LocalPlayerHand.CardHolder);

            cardObject.transform.position = transform.position;
            CardBehaviour cardBehaviour = cardObject.GetComponent <CardBehaviour>();

            cardBehaviour.name = card.ToString();
            cardBehaviour.Init(card);
            return(cardObject);
        }
示例#3
0
        public bool TryToDropCard(CardBehaviour card, NetworkPlayerView player)
        {
            Card[] cardsOnTable = droppedCards.Keys.Select(behaviour => behaviour.Card).ToArray();

            bool isCardValid = RoundRules.IsDroppedCardValid(card.Card, player.NetworkPlayer.PlayerCards, player.NetworkPlayer.RoundTrump, cardsOnTable);

            Debug.Log($"TryToDropCard: isCardValid{isCardValid} _isCardInDropZone{_isCardInDropZone} card:{card.Card} PlayerCards:{player.NetworkPlayer.PlayerCards.ToStringAll()} Trump:{player.NetworkPlayer.RoundTrump} cardsOnTable:{cardsOnTable.ToStringAll()}");


            if (isCardValid && _isCardInDropZone)
            {
                Drop(card, player);
                LocalPlayerView.NetworkPlayer.EndMakeMove(card.Card);
                return(true);
            }



            return(false);
        }
示例#4
0
 private void DisplayPlayerMakeMove(Card moveCard)
 {
     if (moveCard != null)            // is not reset of card
     {
         if (!IsLocalPlayerView)
         {
             UnityEngine.Debug.Log("DisplayPlayerMakeMove");
             CardBehaviour createdCard = ((RemotePlayerCardsView)PlayersHand).InstantiateCardToDisplayRemotePlayerMove(moveCard);
             Dropzone.Drop(createdCard, this);
         }
         else
         {
             var localCards = ((LocalPlayerCardsView)PlayersHand);
             if (localCards.deckDictionary.ContainsKey(moveCard))
             {
                 CardBehaviour createdCard = localCards.deckDictionary[moveCard];
                 Dropzone.Drop(createdCard, this);
             }
         }
     }
 }
示例#5
0
        public CardBehaviour InstantiateCardToDisplayRemotePlayerMove(Card card)
        {
            GameObject cardObject = Instantiate(RealCardPrefab, RemotePlayerHand);

            cardObject.transform.localPosition = new Vector3(0, 0, 0);
            CardBehaviour cardBehaviour = cardObject.GetComponent <CardBehaviour>();

            cardBehaviour.Init(card);

            RectTransform cardRec = cardObject.GetComponent <RectTransform>();

            if (transform.tag == "Robot1")
            {
                cardRec.pivot = new Vector2(0, 0);
            }
            else
            {
                cardRec.pivot = new Vector2(1, 0);
            }

            return(cardBehaviour);
        }
示例#6
0
        /// <summary>
        /// Reset drop zone cards, do last hand and hand to winner animation
        /// </summary>
        /// <param name="handWinner"></param>
        /// <returns></returns>
        private IEnumerator ResetDropZone(NetworkPlayerView handWinner)
        {
            Debug.Log("ResetDropZone");
            Transform            lastHand = LastHandPanel.transform;
            List <CardBehaviour> cards    = droppedCards.Keys.ToList();
            Dictionary <CardBehaviour, Transform> lastCards = new Dictionary <CardBehaviour, Transform>();

            CardBehaviour playerCard = cards.Find(x => (droppedCards[x].tag == "Player"));
            CardBehaviour r1Card     = cards.Find(x => (droppedCards[x].tag == "Robot1"));
            CardBehaviour r2Card     = cards.Find(x => (droppedCards[x].tag == "Robot2"));

            droppedCards.Clear();

            int   j    = 0;
            float time = 0;

            bool lastMoveEnd = true;

            if (playerCard != null)
            {
                LocalNetworkPlayer networkPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <LocalNetworkPlayer>();
                if (networkPlayer != null && networkPlayer.badCard != null)
                {
                    foreach (Transform card in transform)
                    {
                        if (card.GetComponent <CardBehaviour>().Card.CompareTo(networkPlayer.badCard.GetComponent <CardBehaviour>().Card) == 0)
                        {
                            lastCards.Add(card.GetComponent <CardBehaviour>(), lastHand.GetChild(j++));
                            break;
                        }
                    }
                }
                else
                {
                    lastCards.Add(playerCard, lastHand.GetChild(j++));
                }

                lastMoveEnd = false;
            }

            if (r1Card != null)
            {
                lastMoveEnd = false;
                lastCards.Add(r1Card, lastHand.GetChild(j++));
            }

            if (r2Card != null)
            {
                lastMoveEnd = false;
                lastCards.Add(r2Card, lastHand.GetChild(j));
            }

            StartCoroutine(AnimationToHandWinner(new List <CardBehaviour>(lastCards.Keys), handWinner.transform.GetChild(0).GetChild(1)));

            yield return(new WaitForSeconds(1.3f));

            while (time < 0.2f)
            {
                time += Time.deltaTime;

                foreach (var card in lastCards.Keys)
                {
                    Transform zone = lastCards[card];

                    float currentScale = Mathf.Lerp(1, 0, time / 0.2f);
                    zone.localScale = new Vector3(currentScale, zone.localScale.y, zone.localScale.z);
                }

                yield return(null);
            }

            time = 0;
            bool flag = false;

            while (time < 0.2f)
            {
                time += Time.deltaTime;

                foreach (var card in lastCards.Keys)
                {
                    Transform zone = lastCards[card];

                    if (flag == false)
                    {
                        zone.GetComponent <Image>().sprite         = card.CardImg.sprite;
                        zone.GetComponent <Image>().color          = Color.white;
                        zone.GetComponent <Image>().preserveAspect = true;
                    }

                    float currentScale = Mathf.Lerp(0, 1, time / 0.2f);
                    zone.localScale = new Vector3(currentScale, zone.localScale.y, zone.localScale.z);
                }

                flag = true;
                yield return(null);
            }

            while (lastMoveEnd != true)
            {
                yield return(null);
            }

            ResetHandDropes();
            Debug.Log("ResetDropZone END.");
        }