Ejemplo n.º 1
0
    public void createCards()
    {
        int numPairs = numberOfPairs * 2;

        cards     = new CardHandler[numPairs];
        pairArray = new CardModel[numPairs];
        for (int x = 0; x < numberOfPairs; x++)
        {
            pairArray[x] = cardPossibleValues[x];
            pairArray[x + numberOfPairs] = cardPossibleValues[x];
        }
        Shuffle(pairArray);

        //
        for (int i = 0; i < numPairs; i++)
        {
            GameObject  cardGameObject = (GameObject)Instantiate(tilePrefab, Vector3.zero, Quaternion.identity);
            CardHandler card           = cardGameObject.GetComponent <CardHandler>();
            //Canvas elements must be part of a Canvas chain
            card.transform.parent        = this.transform;
            card.transform.localPosition = new Vector3(0, 0, 0);           //-i*0.01f);
            card.gameHandler             = this;
            card.setModel(pairArray[i]);

            if (startFlipped)
            {
                card.startFlipped();
            }
            cards[i] = card;
        }
    }
Ejemplo n.º 2
0
 public void PlaceCardInSlot(CardHandler card)
 {
     if (isActivator)
     {
         Debug.Log("Slotted card " + card.name);
     }
 }
Ejemplo n.º 3
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        if (dragDisabled == false)
        {
            draggedItem = this;


            icon = new GameObject();
            icon.transform.SetParent(canvas.transform);
            icon.name = "Icon";
            Image myImage = transform.GetChild(0).gameObject.GetComponent <Image>();
            myImage.raycastTarget = false;
            Image iconImage = icon.AddComponent <Image>();
            iconImage.raycastTarget = false;
            iconImage.sprite        = myImage.sprite;
            RectTransform iconRect = icon.GetComponent <RectTransform>();
            RectTransform myRect   = GetComponent <RectTransform>();
            iconRect.pivot     = new Vector2(0.5f, 0.5f);
            iconRect.anchorMin = new Vector2(0.5f, 0.5f);
            iconRect.anchorMax = new Vector2(0.5f, 0.5f);
            iconRect.sizeDelta = new Vector2(myRect.rect.width, myRect.rect.height);
            if (OnItemDragStartEvent != null)
            {
                OnItemDragStartEvent(this);
            }
            gameObject.transform.GetChild(0).gameObject.SetActive(false);
            gameObject.transform.GetChild(1).gameObject.SetActive(false);
        }
    }
Ejemplo n.º 4
0
    public CardHandler.HandValue EvaluatePower()
    {
        List <Card> powerCards = m_powerCards.Select(cui => cui.m_card).ToList();

        CardHandler.HandValue powerValue = CardHandler.EvaluateCards(powerCards);
        //Debug.Log( "Power type " + powerValue.m_type + " Value " + powerValue.m_highCard );
        return(powerValue);
    }
Ejemplo n.º 5
0
    private void OnDeclineClicked()
    {
        cardHandler.EnableAllHandCards(true);

        CardHandler.EnableDragHandler(_currentDraggedCard, _cardInPlace);
        DragHandler.draggedCard.transform.SetParent(_currentPlayerHandCards.transform);
        SetChoiceButtons(false);
    }
Ejemplo n.º 6
0
    public CardHandler.HandValue EvaluateDirection()
    {
        List <Card> directionCards = m_directionCards.Select(cui => cui.m_card).ToList();

        CardHandler.HandValue dirValue = CardHandler.EvaluateCards(directionCards);
        //Debug.Log( "Direction type " + dirValue.m_type + " Value " + dirValue.m_highCard );
        return(dirValue);
    }
Ejemplo n.º 7
0
    public CardHandler.HandValue EvaluateHeight()
    {
        List <Card> heightCards = m_heightCards.Select(cui => cui.m_card).ToList();

        CardHandler.HandValue heightValue = CardHandler.EvaluateCards(heightCards);
        //Debug.Log( "Height type " + heightValue.m_type + " Value " + heightValue.m_highCard );
        return(heightValue);
    }
Ejemplo n.º 8
0
 void Start()
 {
     getCardHandler        = GameObject.FindGameObjectWithTag("Hand");
     cardHandler           = getCardHandler.GetComponent <CardHandler>();
     getCurrentCardHandler = GameObject.FindGameObjectWithTag("CurrentCard");
     currentCardHandler    = getCurrentCardHandler.GetComponent <CardHandler>();
     slateHandler          = FindObjectOfType <SlateHandler>();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Create new instance of class
        /// </summary>
        /// <param name="c">Card to display</param>
        public CardDialog(Card c)
        {
            InitializeComponent();
            this.DataContext = this;

            _CardHandler = CardHandler.Instance;
            CurrentCard  = c;
        }
Ejemplo n.º 10
0
    public void putEverythingBack()
    {
        firstCard.flipBack();
        secondCard.flipBack();

        firstCard  = null;
        secondCard = null;
    }
Ejemplo n.º 11
0
    private void Awake()
    {
        cardHandler = GameObject.Find("CardHandler").GetComponent <CardHandler>();
        dropdown    = GetComponent <Dropdown>();

        dropdown.onValueChanged.AddListener(delegate {
            DropdownValueChanged(dropdown);
        });
    }
Ejemplo n.º 12
0
        public void WhenThereAreNotFiveCards_ThrowNotEnoughCardsException()
        {
            var cardHandler        = new CardHandler(_mockedRuleChecker);
            var cardsToBeProcessed = new List <Card>
            {
                new Card(Suit.Heart, Value.Ace)
            };

            Assert.Throws <NotEnoughCardsException>(() => cardHandler.ProcessCards(cardsToBeProcessed));
        }
Ejemplo n.º 13
0
 public MieJiVerifier(Player p, ICard c, CardHandler handler)
 {
     existingCard   = c;
     existingTarget = p;
     this.handler   = handler;
     MaxCards       = 0;
     MinCards       = 0;
     MaxPlayers     = Int16.MaxValue;
     MinPlayers     = 1;
 }
Ejemplo n.º 14
0
 void Start()
 {
     player         = player.GetComponent <PlayerController>();
     bolt           = card.GetComponent <CardHandler>();
     player.curMana = player.totalMana;
     bolt.dmg       = 1;
     bolt.cost      = 1;
     bolt.crit      = 50f;
     deck[0]        = bolt;
 }
Ejemplo n.º 15
0
    //THIS DOES NOT WORK!
    //Addressables are based on their file type!
    public void DoItAddrWrong()
    {
        var ao = Addressables.LoadAssetAsync <CardHandler>(betterStuffName);

        ao.Completed += (handle) => {
            CardHandler stuffPrefab = handle.Result;
            GameObject.Instantiate(stuffPrefab, stuffParent);
        };
        //Addressables.InstantiateAsync<CardHandler>(stuffName,stuffParent);
    }
Ejemplo n.º 16
0
 public QiaoShuiVerifier(List <Player> p, ICard c, CardHandler handler)
 {
     existingCard    = c;
     existingTargets = p;
     this.handler    = handler;
     MaxCards        = 0;
     MinCards        = 0;
     MaxPlayers      = 1;
     MinPlayers      = 1;
 }
Ejemplo n.º 17
0
    private int SetRandomCardNumber()
    {
        int randomIndex = UnityEngine.Random.Range(0, (int)GameCore.drawnNumbers.Count - 1);
        int drawnNumber = GameCore.drawnNumbers[randomIndex];

        CardHandler.UpdateListOfCards(randomIndex);

        _cardNumber = drawnNumber;
        return(drawnNumber);
    }
Ejemplo n.º 18
0
    public void addCard(CardHandler handler)
    {
        var cardObject = Instantiate(manager.produceCard(handler.getCard()),
                                     new Vector2(), Quaternion.identity);

        cardObject.transform.SetParent(cardsGrid.transform, false);
        cardObject.transform.localScale = Vector3.one;

        cardObject.GetComponent <CardHandler>().setCardHandler(handler);
        deckObjects.Add(cardObject);
    }
Ejemplo n.º 19
0
        public static byte[] GetSMResponse(Apdu apdu, byte[] resp, BSO encOut, BSO sigOut, byte[] random)
        {
            TLV       respTLV   = new TLV();
            ByteArray ClearData = new ByteArray(resp).Sub(0, resp.Length - 2);

            byte[] CypherTextObject = null;
            if (encOut == null && sigOut == null)
            {
                if (ClearData.Size != 0)
                {
                    respTLV[0x81] = ClearData;
                }
            }
            else
            {
                if (encOut != null)
                {
                    respTLV[0x87]    = new ByteArray(1).Append(CardHandler.encrypt3DES(encOut.Data, ClearData));
                    CypherTextObject = respTLV[0x87];
                }
                else
                {
                    if (ClearData.Size != 0)
                    {
                        respTLV[0x81] = ClearData;
                    }
                }
                if (sigOut != null)
                {
                    if (random == null)
                    {
                        throw new ISO7816Exception(Error.ConditionsOfUseNotSatisfied);
                    }
                    var MACObject = new ByteArray(random);
                    MACObject = MACObject.Append(ByteArray.ANSIPad(new ByteArray(apdu.GetBytes()).Left(4)));
                    TLV MacTLV = new TLV();
                    if (CypherTextObject != null)
                    {
                        MacTLV[0x87] = CypherTextObject;
                    }
                    else
                    {
                        MacTLV[0x81] = ClearData;
                    }
                    MACObject = MACObject.Append(MacTLV.GetBytes());
                    var mac = CardHandler.getMAC(sigOut.Data, ByteArray.ANSIPad(MACObject));
                    respTLV[0x8e] = mac;
                }
            }
            ByteArray smResp = new ByteArray(respTLV.GetBytes());

            smResp = smResp.Append(new byte[] { resp[resp.Length - 2], resp[resp.Length - 1] });
            return(smResp);
        }
Ejemplo n.º 20
0
 public bool isWon()
 {
     for (int i = 0; i < cards.Length; i++)
     {
         CardHandler card = cards [i];
         if (card.isMatched == false)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 21
0
    public void onCardDestroy(int id)
    {
        for (int i = 0; i < cardObjects.Count; i++)
        {
            CardHandler cardHandler = cardObjects[i].GetComponent <CardHandler>();

            if (cardHandler.getCardId() == id)
            {
                cardObjects.RemoveAt(i);
            }
        }
    }
Ejemplo n.º 22
0
 public SingleCardDiscardVerifier(CardMatcher m = null, CardHandler handler = null)
 {
     Match = m;
     if (handler != null)
     {
         possibleMatch = new List <CardHandler>();
         possibleMatch.Add(handler);
     }
     else
     {
         possibleMatch = null;
     }
 }
Ejemplo n.º 23
0
 public DummyShaVerifier(Player t, CardHandler shaType, CardAttribute helper = null)
 {
     target      = t;
     type        = shaType;
     this.helper = helper;
     dummyCards  = new List <Card>()
     {
         new Card()
         {
             Type = shaType, Place = new DeckPlace(null, DeckType.None)
         }
     };
 }
Ejemplo n.º 24
0
    public void addCard(CardHandler handler)
    {
        var cardObject = Instantiate(manager.produceCard(handler.getCard()),
                                     new Vector2(), Quaternion.identity);

        cardObject.transform.SetParent(cartGrid.transform, false);
        cardObject.transform.localScale = Vector3.one;

        cardObject.GetComponent <CardHandler>().setCardHandler(handler);
        cartObjects.Add(cardObject);

        priceTotal    += getPrice(handler.getCardType());
        priceText.text = $"${priceTotal}";
    }
Ejemplo n.º 25
0
        private static void runCardHandler()
        {
            CardHandler handler = new CardHandler();

            handler.CountCards();
            handler.CardWithNumber(350);
            handler.CardsStartingWith("A");
            handler.CardsStartingWithUnique("A");
            handler.CovertedManaCostGreaterThen6();
            handler.allCreatureCardsWithRarity("Rare");
            handler.allPosibleTypes();
            //handler.TranslationsOrderByNumberTop(3);
            handler.InPrintings("USG");
        }
Ejemplo n.º 26
0
        //a round of hearts diffinetion
        public Round PlayRound(Round round)
        {
            RandomGenerator random = new RandomGenerator();
            //Shuffling CardDeck
            CardHandler cardHandler = new CardHandler();

            cardHandler.ShuffleCards(round.CardDeck);
            Round playedRound = new Round();

            // Dealing Cards to players
            DealCards(round.PlayerA, round.PlayerB, round.PlayerC, round.PlayerD, round.CardDeck);

            Card     firstCardOfRound = FindClubs2(round.PlayerA, round.PlayerB, round.PlayerC, round.PlayerD, round.CardDeck);
            CardDeck cardsPlayed      = new CardDeck();

            cardsPlayed.cardDeck.Clear();
            int counter = 1;

            while (counter != 52)
            {
                playedRound = ExecuteRound(round.PlayerA, round.PlayerB, round.PlayerC, round.PlayerD, firstCardOfRound);
                counter     = counter + 3;
                //Choose a random card for the player to lay

                if (counter < 52)
                {
                    int randomIndex = random.RandomNumber(0, playedRound.PlayerWhoLostRound.PlayerCards.Count - 1);
                    firstCardOfRound = playedRound.PlayerWhoLostRound.PlayerCards[randomIndex];
                    if (playedRound.PlayerWhoLostRound.PlayerName == round.PlayerA.PlayerName)
                    {
                        cardsPlayed.cardDeck.Add(FindAndPlayCard(round.PlayerA, firstCardOfRound));
                    }
                    else if (playedRound.PlayerWhoLostRound.PlayerName == round.PlayerB.PlayerName)
                    {
                        cardsPlayed.cardDeck.Add(FindAndPlayCard(round.PlayerB, firstCardOfRound));
                    }
                    else if (playedRound.PlayerWhoLostRound.PlayerName == round.PlayerC.PlayerName)
                    {
                        cardsPlayed.cardDeck.Add(FindAndPlayCard(round.PlayerC, firstCardOfRound));
                    }
                    else if (playedRound.PlayerWhoLostRound.PlayerName == round.PlayerD.PlayerName)
                    {
                        cardsPlayed.cardDeck.Add(FindAndPlayCard(round.PlayerD, firstCardOfRound));
                    }
                    counter = counter + 1;
                }
            }
            return(round);
        }
Ejemplo n.º 27
0
    public void onCardDestroy(int id)
    {
        for (int i = 0; i < cardObjects.Count; i++)
        {
            CardHandler cardHandler = cardObjects[i].GetComponent <CardHandler>();

            if (cardHandler.getCardId() == id)
            {
                manager.addToDeck(cardHandler);
                cardObjects.RemoveAt(i);

                resetTimer();
            }
        }
    }
Ejemplo n.º 28
0
 private void ResetConditions()
 {
     if (icon != null)
     {
         Destroy(icon);
     }
     if (OnItemDragEndEvent != null)
     {
         OnItemDragEndEvent(this);
     }
     draggedItem = null;
     icon        = null;
     gameObject.transform.GetChild(0).gameObject.SetActive(true);
     gameObject.transform.GetChild(1).gameObject.SetActive(true);
 }
Ejemplo n.º 29
0
        public static string Translate(CardHandler cardHandler)
        {
            if (cardHandler == null)
            {
                return(string.Empty);
            }
            string key  = string.Format("Card.{0}.Name", cardHandler.Name);
            string name = Application.Current.TryFindResource(key) as string;

            if (name == null)
            {
                return(string.Empty);
            }
            return(name);
        }
Ejemplo n.º 30
0
    void Awake()
    {
        s = this;

        if (GS.a == null)
        {
            FindObjectOfType <GS> ().Awake();
        }

        if (GS.a.autoSetUpBoard)
        {
            SetUpGrid(GS.a.gridSettings);
        }
        //print (DataHandler.s);
        //print (DataHandler.s.myPlayerinteger);
    }
    public void OnFingerDown( int fingerIndex, Vector2 fingerPos )
    {
        CardHandler preCard = curCard;
        Camera uiCam = CameraManager.instance.uiCamera;
        if (uiCam != null)
        {
            Ray ray = uiCam.ScreenPointToRay(fingerPos);
            if (Physics.Raycast(ray, Mathf.Infinity, 1 << (int)eLayerName.UI))
            {
                return;
            }
        }

        GameObject obj = PickObject(fingerPos);
       
        if (obj != null && obj.layer == (int)eLayerName.Card)
        {            
            Debug.Log("Touch Down " + fingerPos);        
            CardHandler card = obj.GetComponent<CardHandler>();
            
            curCard = card;
            if (preCard != null && curCard != preCard )
                preCard.OnEndFocus();
            if (card.playerType == ePlayerType.Player)
            {
                curCard.OnClick();
            }
            else
            {

            }
        }
        else if (preCard != null)
        {
            preCard.OnEndFocus();
        }
    }
Ejemplo n.º 32
0
    public void ResetLocalVars()
    {
        GameObject[] test = GameObject.FindGameObjectsWithTag("CardHandler");
        CardHandler handler = new CardHandler();

        //setting local variables back when going back to Collection
        foreach (GameObject ga in test)
        {
            if (ga.GetComponent<CardHandler>())
            {
                handler = ga.GetComponent<CardHandler>();
            }

            if (handler.mainPanel != null && mainPanel == null)
            {
                smallCardTemplate = handler.smallCardTemplate;
                mediumCardTemplate = handler.mediumCardTemplate;
                mainPanel = handler.mainPanel;
                sidePanel = handler.sidePanel;
                largeCardInScene = handler.largeCardInScene;
                Destroy(handler.gameObject);
            }
        }
    }
Ejemplo n.º 33
0
    void Start()
    {
        if (!instance)
           {
           instance = this;
           }

           if (cardDictionary.Count < 1)
           {
           LoadAllCards();
           }

           LoadGotCards();

           int i = 0;
           foreach (Sprite s in raritySprites)
           {
           rarityImages.Add(rarities[i],s);
           i++;
           }

           DisplayCards(GetCards(Element.All));
    }
Ejemplo n.º 34
0
        public void Init()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());
            ninject = new StandardKernel(new BindingsModule());

            mockChanceDeck = fixture.Create<Mock<Deck>>();
            mockChestDeck = fixture.Create<Mock<Deck>>();

            mockDeckFactory = fixture.Create<Mock<DeckFactory>>();
            mockDeckFactory.Setup(x => x.BuildChanceDeck()).Returns(mockChanceDeck.Object);
            mockDeckFactory.Setup(x => x.BuildCommunitiyChestDeck()).Returns(mockChestDeck.Object);

            ninject.Rebind<IDeckFactory>().ToConstant(mockDeckFactory.Object).InSingletonScope();

            cardHandler = ninject.Get<CardHandler>();
        }