/// <summary> /// /// Initialises the editing of a deck /// /// </summary> public void EditDeck(int deckId, Classes.ClassList selectedDeckClass, DeckListObject _activeDeckObject) { //Sets the properties of the deck currently being edited DeckEditId = deckId; activeDeckObject = _activeDeckObject; activeDeckObject.deckDetailsArea.SetActive(true); //Locks the deck scrolling deckScrollArea.vertical = false; //Hides all deck objects in the deck list except the one being edited for (int deckIndex = 0; deckIndex < deckListObjects.Count; deckIndex++) { if (deckListObjects[deckIndex].GetComponent <DeckListObject>().deckData.Id != deckId) { deckListObjects[deckIndex].SetActive(false); } } //Filters the card library to only show cards which are available to the selected decks class libraryUI.ApplyClassPlayableFilter(selectedDeckClass); lootButton.interactable = true; upgradeButton.interactable = true; }
/// <summary> /// /// Refreshes the deck list. This will reset the UI on a deck being edited as well /// /// </summary> public void RefreshDeckList(int?editDeckId = null, bool resourceFilter = true) { newDeckPage.SetActive(false); lootGenerator.SetActive(false); upgradeManager.SetActive(false); //Unlocks the deck scrolling deckScrollArea.vertical = true; DeckEditId = null; lootButton.interactable = false; lootGenerator.SetActive(false); upgradeButton.interactable = false; upgradeManager.SetActive(false); //Resets the filter to not filter cards to be playable by a class. The if statement should only not be entered during the original initialisation of the UI //i.e. In start on this script. This is because the filter object in the library UI doesn't exist yet as it is also created in start. if (resourceFilter) { libraryUI.ApplyClassPlayableFilter(); } //Clears the deck list of objects GameManager.DestroyAllChildren(deckListParent); deckListObjects.Clear(); DeckListObject editDeckObject = null; DeckData editDeck = null; //Initialise and create the objects in the deck list var deckList = GameManager.instance.deckManager.GetPlayerDecks(); foreach (var deck in deckList) { var deckListObject = Instantiate(deckListObjectPrefab, deckListParent.transform); deckListObject.name = $"Deck: {deck.Name}"; var deckListScript = deckListObject.GetComponent <DeckListObject>(); deckListScript.InitDeckListObject(deck, _deckListUI: this); deckListObjects.Add(deckListObject); if (editDeckId.HasValue && deck.Id == editDeckId) { editDeckObject = deckListScript; editDeck = deck; } } if (editDeckId.HasValue) { EditDeck(editDeckId.Value, editDeck.DeckClass, editDeckObject); } }