private void Start() { // Get References ui_manager = FindObjectOfType <UIManager>(); // Set Windowskin and Text Color panel.sprite = ui_manager.GetCurrentMenuSkin(); text_field.color = ui_manager.GetBestTextColor(panel); if (ui_manager.IsDarkBG(panel)) { sel_arrow.enabled = false; } else { sel_arrow_white.enabled = false; } // Initialize View Settings choices = text_field.text.Split('\n'); text_field.text = null; BuildChoicePanel(); // Ready for Interaction choice_package = ui_manager.choice_package; current_selection = choice_package.starting_choice; SetPointerStartPos(); finished = false; }
public Choice ShowChoices(ChoicePackage choice_package) { // Create choice panel choice_panel = GameObject.Instantiate(prefab_choice_panel, canvas.transform); this.choice_package = choice_package; // Show choices text Text text_field = choice_panel.GetComponentInChildren <Text>(); text_field.text = string.Join("\n", choice_package.choices); return(choice_panel.GetComponent <Choice>()); }
private IEnumerator ShowPokemonChoices(Pokemon.Pokemon pokemon) { // Lock control and modify view awaiting_input = false; message_panel.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, MESSAGE_PANEL_SHORT_WIDTH); message_text_field.text = SELECT_MESSAGE; // Determine choices to show List <string> valid_choices = new List <string>(); valid_choices.Add(SELECT_OPTIONS[0]); if (party.size > 1) { valid_choices.Add(SELECT_OPTIONS[1]); } if (pokemon.egg_steps == 0) { valid_choices.Add(SELECT_OPTIONS[2]); } valid_choices.Add(SELECT_OPTIONS[3]); ChoicePackage choice_package = new ChoicePackage(valid_choices.ToArray(), 0, valid_choices.Count - 1); // Show choices Choice choice = ui_manager.ShowChoices(choice_package); Image choice_panel = choice.GetComponent <Image>(); choice_panel.rectTransform.Translate(Vector3.down * CHOICE_MENU_OFFSET); // Hide choices yield return(new WaitUntil(() => choice.finished)); PartySelectChoices selection = (PartySelectChoices)Enum.Parse(typeof(PartySelectChoices), valid_choices[choice.chosen_selection], true); GameObject.Destroy(choice.gameObject); // Act on selection switch (selection) { case PartySelectChoices.Summary: open_screen = ui_manager.ShowSummaryScreen(); SummaryScreen summary = open_screen.GetComponent <SummaryScreen>(); summary.pokemon_selection = current_selection; summary.in_pc = false; summary.learning_move = false; yield return(new WaitUntil(() => open_screen == null)); StartCoroutine(ShowPokemonChoices(pokemon)); break; case PartySelectChoices.Swap: InitiateSwap(current_selection); break; case PartySelectChoices.Item: Debug.Log("Open bag to give item"); EndPokemonChoices(); // TODO: replace this with giving item break; default: EndPokemonChoices(); break; } }