//Shifts cards in hand over to make space for newly drawn card. private void ShiftCards(int start, int end) { for (int i = start; i <= end; i++) { Magnus magnusScript = cards[i].GetComponent <Magnus>(); cards[i].transform.position = cards[i].transform.position - new Vector3(magnusScript.GetWidth(), 0, 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; }