示例#1
0
    private void PickAndSetCard(HandDeck playerHandDeck)
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);

            if (hit.collider != null)
            {
                var card      = hit.collider.gameObject;
                var cardName  = card.name.Split(' ')[0];
                var cardPower = GetCardPower(card);

                var oldPos = card.transform.position;
                playerCard = card;
                card.transform.position = new Vector2(2.5f, -1);

                playerHandDeck.cards.Remove(card);

                if (CheckIfHaveTwenty(playerHandDeck, cardName, cardPower))
                {
                    playerScoreSum += 20;
                }

                CardGenerator.GenerateCard(playerHandDeck, oldPos);
            }
            isPlayerTurn = false;
        }
    }
        public override void Modify(CharacterViewModel model)
        {
            Layer  thumbLayer  = CardGenerator.GenerateThumbnail(model.Character);
            Bitmap thumbBitmap = CardGenerator.Resample(thumbLayer, 74, 90, InterpolationMode.HighQualityBicubic);

            Layer cardLayer = CardGenerator.GenerateCard(model.Character);

            Bitmap cardBitmap = CardGenerator.Resample(cardLayer, 200, 300, InterpolationMode.Bilinear);

            MemoryStream streamThumb = new MemoryStream();

            thumbBitmap.Save(streamThumb, ImageFormat.Png);
            model.Character.SetThumbnail(streamThumb.ToArray());

            MemoryStream streamCard = new MemoryStream();

            cardBitmap.Save(streamCard, ImageFormat.Png);
            model.Character.SetCard(streamCard.ToArray());
        }
示例#3
0
    private void ComputerPickAndSetCard(HandDeck computerHandDeck)
    {
        if (playerCard != null && computerHandDeck.ContainsCard(playerCard.name.Split(' ')[0]))
        {
            GameObject card = computerHandDeck.cards.Where(c => c.gameObject.name.Split(' ')[0] == playerCard.gameObject.name.Split(' ')[0]).FirstOrDefault();

            var oldPos = card.transform.position;
            computerCard = GameObject.Find(card.gameObject.name + "(Clone)");

            computerCard.transform.position = new Vector2(2.5f, 1);

            computerHandDeck.cards.Remove(card);
            var cardName  = computerCard.name.Split(' ')[0];
            var cardPower = GetCardPower(computerCard);
            if (CheckIfHaveTwenty(playerHandDeck, cardName, cardPower))
            {
                computerScoreSum += 20;
            }
            CardGenerator.GenerateCard(computerHandDeck, oldPos);
        }
        else
        {
            if (computerHandDeck.ContainsCard(Dealer.instance.trumpCard.name.Split(' ')[0]))
            {
                GameObject card = computerHandDeck.cards.Where(c => c.gameObject.name.Split(' ')[0] == Dealer.instance.trumpCard.name.Split(' ')[0]).FirstOrDefault();

                var oldPos = card.transform.position;
                computerCard = GameObject.Find(card.gameObject.name + "(Clone)");

                computerCard.transform.position = new Vector2(2.5f, 1);

                computerHandDeck.cards.Remove(card);
                var cardName  = computerCard.name.Split(' ')[0];
                var cardPower = GetCardPower(computerCard);
                if (CheckIfHaveTwenty(playerHandDeck, cardName, cardPower))
                {
                    computerScoreSum += 20;
                }
                CardGenerator.GenerateCard(computerHandDeck, oldPos);
                isPlayerTurn = true;
            }
            else
            {
                int        random = Random.Range(0, computerHandDeck.cards.Count);
                GameObject card   = computerHandDeck.cards[random];

                var oldPos = card.transform.position;
                computerCard = GameObject.Find(card.gameObject.name + "(Clone)");

                computerCard.transform.position = new Vector2(2.5f, 1);

                computerHandDeck.cards.Remove(card);

                var cardName  = computerCard.name.Split(' ')[0];
                var cardPower = GetCardPower(computerCard);
                if (CheckIfHaveTwenty(playerHandDeck, cardName, cardPower))
                {
                    computerScoreSum += 20;
                }
                CardGenerator.GenerateCard(computerHandDeck, oldPos);
                isPlayerTurn = true;
            }
        }
    }