Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        canFlip = true;
        panelWin.SetActive(false);
        panelPause.SetActive(false);
        remainingMatchesText.text = "Remaining Matches: " + remainingMatches;
        Vector2 startPos = mainCard.gameObject.transform.position;
        int[] numbers = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6 };

        numbers = Shuffle(numbers);
        for (int i = 0; i < cols; i++)
        {
            for(int j=0; j < rows; j++)
            {
                CardController card;
                if(i == 0 && j == 0)
                {
                    card = mainCard;
                }
                else
                {
                    card = Instantiate(mainCard) as CardController;
                }

                int index = j * cols + i;
                //Debug.Log("number:" + numbers[index]);
                int id = numbers[index];
                mainCard.ChangeSprite(id, images[id]);
                Debug.Log(card._cardId);
                float posX = (colOffset * i) + startPos.x;
                float posY = (rowOffset * j) + startPos.y;
                card.transform.position = new Vector2(posX, posY);
            }
        }
    }