/// <summary> /// /// Initialises the tutor draw UI /// /// </summary> public void InitTutorDraw(CardFunctionUI _cardFunctionUI) { CardFunctionUI = _cardFunctionUI; //Sets the list of dropdown fields and input fields dropdownFields = new List <TMP_Dropdown> { rarityDropdown, classDropdown, tagDropdown, resourceDropdown, typeDropdown, costFilterDropdown, attackFilterDropdown, healthFilterDropdown, rangeFilterDropdown, speedFilterDropdown, spellRangeFilterDropdown, durabilityFilterDropdown }; inputFields = new List <TMP_InputField> { nameInput, costInput, attackInput, healthInput, rangeInput, speedInput, spellRangeInput, durabilityInput, }; //Initialises the dropdowns on the UI GeneralUIExtensions.InitDropdownOfType(rarityDropdown, new List <Rarity> { Rarity.Default, Rarity.Deleted, Rarity.Hero, Rarity.NPCHero }, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(classDropdown, new List <Classes.ClassList> { Classes.ClassList.Default }, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(tagDropdown, new List <Tags> { Tags.Default }, DEFAULT_DROPDOWN_STRING, true); GeneralUIExtensions.InitDropdownOfType(resourceDropdown, new List <CardResources> { }, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(typeDropdown, new List <CardTypes> { CardTypes.Default }, DEFAULT_DROPDOWN_STRING); var removedIntValueFilter = new List <IntValueFilter> { IntValueFilter.None }; GeneralUIExtensions.InitDropdownOfType(costFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(attackFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(healthFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(rangeFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(speedFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(spellRangeFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(durabilityFilterDropdown, removedIntValueFilter, DEFAULT_DROPDOWN_STRING); }
/// <summary> /// /// Initialises the tutor draw UI /// /// </summary> public void InitGenerateCard(CardFunctionUI _cardFunctionUI, Classes.ClassList playerClass) { CardFunctionUI = _cardFunctionUI; PlayerClass = playerClass; ClearEnchantmentFields(); unitEnchantmentArea.SetActive(false); //Sets the list of dropdown fields and input fields dropdownFields = new List <TMP_Dropdown> { classDropdown, tagDropdown, resourceDropdown, typeDropdown, positionDropdown, modifyCostDropdown, }; inputFields = new List <TMP_InputField> { nameInput, numToGenerateInput, createdByInput, modifyCostInput, }; //Initialises the dropdowns on the UI GeneralUIExtensions.InitDropdownOfType(classDropdown, new List <Classes.ClassList> { Classes.ClassList.Default }, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(tagDropdown, new List <Tags> { Tags.Default }, DEFAULT_DROPDOWN_STRING, true); GeneralUIExtensions.InitDropdownOfType(resourceDropdown, new List <CardResources> { }, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(typeDropdown, new List <CardTypes> { CardTypes.Default }, DEFAULT_DROPDOWN_STRING); GeneralUIExtensions.InitDropdownOfType(positionDropdown, new List <DeckPositions>()); GeneralUIExtensions.InitDropdownOfType(modifyCostDropdown, new List <CardResources> { }, MODIFY_COST_DEFAULT_DROPDOWN_STRING); }
/// <summary> /// /// Button click event for confirming the given filter and attempting to draw a card /// /// </summary> public void ConfirmDraw() { //Sets the name filter to the name input TutorDrawFilter.Name = nameInput.text; //Determines if the is created filter is turned on. If not sets the value to null if (isCreatedOn) { TutorDrawFilter.ScenarioCreated = isCreatedToggle.isOn; } else { TutorDrawFilter.ScenarioCreated = null; } //Applies the dropdown filter to each of the relevant dropdowns ApplyDropdownFilter <Rarity>(rarityDropdown, TutorDrawFilter); ApplyDropdownFilter <Classes.ClassList>(classDropdown, TutorDrawFilter); ApplyDropdownFilter <Tags>(tagDropdown, TutorDrawFilter); ApplyDropdownFilter <CardResources>(resourceDropdown, TutorDrawFilter); ApplyDropdownFilter <CardTypes>(typeDropdown, TutorDrawFilter); ApplyDropdownFilter <IntValueFilter>(costFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.Cost); ApplyDropdownFilter <IntValueFilter>(attackFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.Attack); ApplyDropdownFilter <IntValueFilter>(healthFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.Health); ApplyDropdownFilter <IntValueFilter>(rangeFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.Range); ApplyDropdownFilter <IntValueFilter>(speedFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.Speed); ApplyDropdownFilter <IntValueFilter>(spellRangeFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.SpellRange); ApplyDropdownFilter <IntValueFilter>(durabilityFilterDropdown, TutorDrawFilter, CardListFilter.IntFilterTypes.Durability); int?choiceValue = 1; if (int.TryParse(isChoiceNumberInput.text, out int result) && isChoiceNumberInput.text != "0") { choiceValue = Mathf.Max(1, result); } choiceValue = isChoiceToggle.isOn ? choiceValue : null; //Attempt the draw using the constructed filter. If failed to draw with the given filter adds the clarifier to the title if (!CardFunctionUI.TutorDraw(TutorDrawFilter, choiceValue)) { titleText.text = $"{titleText.text} (Failed)"; } }
/// <summary> /// /// Button click event for confirming the given filter and attempting to generate a card /// /// </summary> public void ConfirmGeneration() { //In order to submit, needs to have a created by string. Doesn't confirm if there is no text, and displays error to player if (!string.IsNullOrWhiteSpace(createdByInput.text)) { //Sets the name filter to the name input GenerationFilter.Name = nameInput.text; GenerationFilter.IncludeUncollectables = includeUncollectablesToggle.isOn; GenerationFilter.IsUnique = isUnique.isOn; if (!string.IsNullOrWhiteSpace(numToGenerateInput.text) && numToGenerateInput.text != "0") { GenerationFilter.NumToGenerate = Mathf.Max(1, int.Parse(numToGenerateInput.text)); } else { GenerationFilter.NumToGenerate = 1; } //Applies the dropdown filter to each of the relevant dropdowns ApplyDropdownFilter <Classes.ClassList>(classDropdown, GenerationFilter); ApplyDropdownFilter <Tags>(tagDropdown, GenerationFilter); ApplyDropdownFilter <CardResources>(resourceDropdown, GenerationFilter); ApplyDropdownFilter <CardTypes>(typeDropdown, GenerationFilter); if (int.TryParse(modifyCostInput.text, out int result) && modifyCostInput.text != "0") { GenerationFilter.CostModification = result; if (modifyCostDropdown.captionText.text == MODIFY_COST_DEFAULT_DROPDOWN_STRING) { GenerationFilter.ResourceModification = null; } else { GenerationFilter.ResourceModification = (CardResources)Enum.Parse(typeof(CardResources), modifyCostDropdown.captionText.text); } } else { GenerationFilter.CostModification = null; GenerationFilter.ResourceModification = null; } //If the card type is a unit, constructs the enchantment and adds it to the filter for generation if (GenerationFilter.CardType == CardTypes.Unit) { var enchantment = new UnitEnchantment() { Status = UnitEnchantment.EnchantmentStatus.Permanent, Source = createdByInput.text }; GetStatModifier(enchantment, Unit.StatTypes.Attack, attackModTypeDropdown, attackValueInput); GetStatModifier(enchantment, Unit.StatTypes.MaxHealth, healthModTypeDropdown, healthValueInput); GetStatModifier(enchantment, Unit.StatTypes.Range, rangeModTypeDropdown, rangeValueInput); GetStatModifier(enchantment, Unit.StatTypes.Speed, speedModTypeDropdown, speedValueInput); GetStatModifier(enchantment, Unit.StatTypes.Empowered, empoweredModTypeDropdown, empoweredValueInput); if (enchantment.ValidEnchantment) { GenerationFilter.Enchantment = enchantment; } } ClearEnchantmentFields(); //Attempts the generation of cards. For deck generation, includes the position to place the generated card bool successfulGeneration; if (CardGenerationType == CardGenerationTypes.Deck) { var position = (DeckPositions)Enum.Parse(typeof(DeckPositions), positionDropdown.captionText.text); successfulGeneration = CardFunctionUI.ConfirmCardGeneration(GenerationFilter, isChoice.isOn, createdByInput.text, position); } else { successfulGeneration = CardFunctionUI.ConfirmCardGeneration(GenerationFilter, isChoice.isOn, createdByInput.text); } //If failed the generation, displays this in the title if (!successfulGeneration) { titleText.text = $"{defaultTitleText} (Failed)"; } } else { createdByInput.placeholder.color = new Color(0.8f, 0.0f, 0.0f, 0.5f); titleText.text = $"{defaultTitleText} (Input Created By)"; } }