Exemple #1
0
    void Start()
    {
        GlobalFunctions.isLoading = false;
        if (canvas != null)
        {
            if (canvas.activeInHierarchy)
            {
                canvas.SetActive(false);
            }
        }
        if (GameOverCanvas != null)
        {
            if (GameOverCanvas.activeInHierarchy)
            {
                GameOverCanvas.SetActive(false);
            }
        }
        customStyle = GlobalFunctions.getMenuButtonStyle();
        rules       = EasyLevelRules.LoadLevels(level);
        cardList.Clear();
        canSelect = true;
        clicks    = 0;
        for (int x = rules.maxCards; x > 0; x--)
        {
            string cardToUse = "card" + RNG.Next(1, CONSTANTS.TOTAL_CARD_NUMBERS).ToString();
            //To Avoid Repeated Images
            while (cardList.FindAll(find => find.name == cardToUse).Count != 0)
            {
                cardToUse = "card" + RNG.Next(1, CONSTANTS.TOTAL_CARD_NUMBERS).ToString();
            }

            EasyCard firstCard = new EasyCard();
            firstCard.id       = x.ToString();
            firstCard.name     = cardToUse;
            firstCard.backface = Resources.Load(CONSTANTS.get("CARD_IMG") + "cardback") as Texture2D;
            firstCard.image    = Resources.Load(CONSTANTS.get("CARD_IMG") + cardToUse) as Texture2D;
            firstCard.moveBackContent();
            firstCard.moveContent();
            firstCard.setTexture();
            addCardRandomly(firstCard);

            EasyCard secondCard = new EasyCard();
            secondCard.id       = x.ToString();
            secondCard.name     = cardToUse;
            secondCard.backface = Resources.Load(CONSTANTS.get("CARD_IMG") + "cardback") as Texture2D;
            secondCard.image    = Resources.Load(CONSTANTS.get("CARD_IMG") + cardToUse) as Texture2D;
            secondCard.moveBackContent();
            secondCard.moveContent();
            addCardRandomly(secondCard);
        }
    }
Exemple #2
0
 //Adds The Card Given to the Deck of cards randomly
 public void addCardRandomly(EasyCard card)
 {
     if (cardList.Count > 0)
     {
         int max   = cardList.Count;     //Set the max number for the randomization
         int min   = 0;                  //The min number for the randomization
         int index = RNG.Next(min, max); //Randomize a number that will be the index of the card in the deck
         cardList.Insert(index, card);   //Insert the card in the deck with index given
     }
     else
     {
         cardList.Add(card);
     }
 }