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; }
private void ShowCurrentRows() { for (int row = 0; row < gathering.Count; row++) { bool showRow = (row == topGatheringRow) || (row == topGatheringRow + 1); for (int col = 0; col < gathering[row].Count; col++) { Magnus magnus = gathering[row][col].GetComponent <Magnus>(); if (showRow) { magnus.Show(); } else { magnus.Hide(); } } } for (int row = 0; row < deck.Count; row++) { bool showRow = (row == topDeckRow) || (row == topDeckRow + 1); for (int col = 0; col < deck[row].Count; col++) { Magnus magnus = deck[row][col].GetComponent <Magnus>(); if (showRow) { magnus.Show(); } else { magnus.Hide(); } } } }