Пример #1
0
    private void AddToDeck()
    {
        if (deck.Count == 0)
        {
            deck.Add(new List <GameObject>());
        }

        List <GameObject> lastRow = deck[deck.Count - 1];

        //last row is full, add new row
        if (lastRow.Count == NUM_COLUMNS)
        {
            deck.Add(new List <GameObject>());
            lastRow = deck[deck.Count - 1];
        }

        //Add currently selected gathering card to deck, replace card in gathering with new card with same name
        lastRow.Add(gathering[currentRow][currentCol]);
        string  magnusName = gathering[currentRow][currentCol].GetComponent <Magnus>().GetName();
        Vector3 magnusPos  = gathering[currentRow][currentCol].transform.position;

        gathering[currentRow][currentCol] = CreateMagnus(magnusName);
        gathering[currentRow][currentCol].transform.position = magnusPos;

        //Proper position for card in deck
        Magnus magnusScript = lastRow[lastRow.Count - 1].GetComponent <Magnus>();
        float  x            = (lastRow.Count - 1) * (magnusScript.GetWidth() + 0.1f) + DECK_LEFT_BOUND;
        float  y;

        if (deck[0].Count == 1)
        {
            y = TOP_BOUND - ((deck.Count - 1) * (magnusScript.GetHeight() + 0.5f));
        }
        //deck section might be scrolled down, so TOP_BOUND is incorrect
        else
        {
            y = deck[0][0].transform.position.y - ((deck.Count - 1) * (magnusScript.GetHeight() + 0.5f));
        }
        lastRow[lastRow.Count - 1].transform.position = new Vector3(x, y, 0);
        if (deck.Count - 1 > topDeckRow + 1)
        {
            magnusScript.Hide();
        }

        deckCount++;
        deckText.text = "Deck: " + deckCount + "/" + MAX_DECK_SIZE;
    }
Пример #2
0
    private void ShiftRows(bool shiftUp)
    {
        if (inGathering)
        {
            for (int row = 0; row < gathering.Count; row++)
            {
                for (int col = 0; col < gathering[row].Count; col++)
                {
                    Magnus magnusScript = gathering[row][col].GetComponent <Magnus>();

                    if (shiftUp)
                    {
                        gathering[row][col].transform.position += new Vector3(0, magnusScript.GetHeight() + 0.5f, 0);
                    }
                    else
                    {
                        gathering[row][col].transform.position -= new Vector3(0, magnusScript.GetHeight() + 0.5f, 0);
                    }
                }
            }
        }
        else
        {
            for (int row = 0; row < deck.Count; row++)
            {
                for (int col = 0; col < deck[row].Count; col++)
                {
                    Magnus magnusScript = deck[row][col].GetComponent <Magnus>();

                    if (shiftUp)
                    {
                        deck[row][col].transform.position += new Vector3(0, magnusScript.GetHeight() + 0.5f, 0);
                    }
                    else
                    {
                        deck[row][col].transform.position -= new Vector3(0, magnusScript.GetHeight() + 0.5f, 0);
                    }
                }
            }
        }
    }