Example #1
0
    //get a list of cards filtered by type (soldiers, crops, spells)
    public List <CardAsset> GetCardOfType(CardTypeAsset asset)
    {
        //return GetCards (false, asset);
        var cards      = from card in allCardsArray where card.cardTypeAsset == asset select card;
        var returnList = cards.ToList <CardAsset> ();

        returnList.Sort();

        return(returnList);
    }
Example #2
0
    private void ShowCards(int pageIndex = 0, bool includeAllCards = true, CardTypeAsset asset = null)
    {
        //saving infomation about the cards that we are showing to the players on this page
        _pageIndex       = pageIndex;
        _includeAllCards = includeAllCards;
        _asset           = asset;

        List <CardAsset> CardsOnThisPage = PageSelection(pageIndex, includeAllCards, asset);

        //clear created cards list
        ClearCreatedCards();

        if (CardsOnThisPage.Count == 0)
        {
            return;
        }

        for (int i = 0; i < CardsOnThisPage.Count; i++)
        {
            GameObject newMenuCard;
            if (CardsOnThisPage [i].TypeOfCard == TypesOfCards.Soldier)
            {
                //it is a soldier
                newMenuCard = Instantiate(soldierMenuPrefab, Slots [i].position, Quaternion.identity) as GameObject;
            }
            else if (CardsOnThisPage [i].TypeOfCard == TypesOfCards.Spell)
            {
                //it is a spell
                newMenuCard = Instantiate(spellMenuPrefab, Slots [i].position, Quaternion.identity) as GameObject;
            }
            else
            {
                //it is a crop
                newMenuCard = Instantiate(cropMenuPrefab, Slots [i].position, Quaternion.identity) as GameObject;
            }
            newMenuCard.transform.SetParent(this.transform);

            createdCards.Add(newMenuCard);

            OneCardManager manager = newMenuCard.GetComponent <OneCardManager> ();
            manager.cardAsset = CardsOnThisPage [i];
            manager.ReadCardFromAsset();

            AddCardToDeck addCardComponent = newMenuCard.GetComponent <AddCardToDeck> ();
            addCardComponent.SetCardAsset(CardsOnThisPage [i]);
            addCardComponent.UpdateQuantity();
        }
    }
Example #3
0
    //the general function that will filters the cards
    public List <CardAsset> GetCards(bool includeAllCards = true, CardTypeAsset asset = null)
    {
        //initially select all cards
        var cards = from card in allCardsArray
                    select card;

        if (!includeAllCards)
        {
            cards = cards.Where(card => card.cardTypeAsset == asset);
        }

        var returnList = cards.ToList <CardAsset> ();

        returnList.Sort();

        return(returnList);
    }
Example #4
0
    //return a list with assets of cards that we have to show on page with pageIndex
    // selects cards that satisfy all parameters
    private List <CardAsset> PageSelection(int pageIndex = 0, bool includeAllCards = true, CardTypeAsset asset = null)
    {
        List <CardAsset> returnList = new List <CardAsset> ();

        //obatain cards from collection that satisfy all the selected criteria
        List <CardAsset> cardsToChooseFrom = CardCollection.Instance.GetCards(includeAllCards, asset);

        //if there are enough cards so that we can show some cards on page with pageIndex
        //otherwise an empty list will be returned
        if (cardsToChooseFrom.Count > pageIndex * Slots.Length)
        {
            //check for 2 conditions
            //i < cardsToChooseFrom.Count - pageIndex * Slots.Length checks that we did not run out of cards on the last page
            //i < Slots.Length checks that we have reached the limit of cards to display on one page
            for (int i = 0; (i < cardsToChooseFrom.Count - pageIndex * Slots.Length && i < Slots.Length); i++)
            {
                returnList.Add(cardsToChooseFrom [pageIndex * Slots.Length + i]);
            }
        }

        return(returnList);
    }