IEnumerator TypeAnswer(int selectedOption) { string message = ""; yield return(new WaitForSeconds(1)); for (int i = 3; i < optionButtons[selectedOption].GetComponentInChildren <Text>().text.Length; i++) { AudioSource clickSoundAS = gameObject.AddComponent <AudioSource>(); clickSoundAS.clip = clickSounds[Random.Range(0, clickSounds.Length - 1)]; clickSoundAS.pitch = Random.Range(0.9f, 1f); clickSoundAS.Play(); //yield return new WaitForSeconds(0.03f); message += optionButtons[selectedOption].GetComponentInChildren <Text>().text[i]; messageInput.GetComponentInChildren <Text>().text = message; yield return(new WaitForSeconds(0.07f)); StartCoroutine(ClickSoundASDestroyer(clickSoundAS)); } messageInput.GetComponentInChildren <Text>().text = ""; currentConversation[0].Add(message); currentConversation[1].Add("You"); currentPlayerBubble = NewBubble(playerBubble, "You"); lineText.text = message; // Call the delegate to tell the dialogue system that we've // selected an option. SetSelectedOption(selectedOption); // Now remove the delegate so that the loop in RunOptions will exit SetSelectedOption = null; }
public void ScrollOption(int scroll) { if (openToOptions) { if (accidentPrevention > 0.4f) { if (scroll == 0) { // Call the delegate to tell the dialogue system that we've // selected an option. SetSelectedOption(highlightOption); // Now remove the delegate so that the loop in RunOptions will exit SetSelectedOption = null; } else { highlightOption += scroll; if (highlightOption >= optionCount) { highlightOption = 0; } else if (highlightOption < 0) { highlightOption = optionCount - 1; } //highlight.transform.position = optionButtons[highlightOption].transform.position; } } } }
// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons [i].gameObject.SetActive(true); optionButtons [i].GetComponentInChildren <Text> ().text = optionString; i++; } // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive(false); } }
// Handles selecting one of the options public void SetOption(int selectedOption) { // Runs the delegate for selecting an option SetSelectedOption(selectedOption); // Remove the delegate so that we can continue with the dialogue SetSelectedOption = null; }
// Called by buttons to make a selection. public void SetOption(int selectedOption) { // Call the delegate to tell the dialogue system that we've // selected an option. SetSelectedOption(selectedOption); // Now remove the delegate so that the loop in RunOptions will exit SetSelectedOption = null; }
/// Called by buttons to make a selection. public void SetOption(int selectedOption) { // Call the delegate to tell the dialogue system that we've // selected an option. SetSelectedOption(selectedOption); // Now remove the delegate so that the loop in RunOptions will exit SetSelectedOption = null; m_tradingUIManager.ShowItemButton(false); }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { //Make sure the text is visible lineText.gameObject.SetActive(true); // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Length) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons[i].gameObject.SetActive(true); optionButtons[i].GetComponentInChildren <Text>().text = optionString; i++; } // Record that we're using it SetSelectedOption = optionChooser; //Start UI animation GetComponent <PlayableDirector>().Play(); yield return(new WaitForSeconds(WaitForUITransition)); //Wait for it to play GetComponent <PlayableDirector>().Pause(); //Stop on idle // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } //Play the anim out GetComponent <PlayableDirector>().Play(); //wait again yield return(new WaitForSeconds(WaitForUITransition * 2)); // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive(false); } //Reset playable GetComponent <PlayableDirector>().time = 0; GetComponent <PlayableDirector>().Pause(); }
public void RunOptions (Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Display each option in a button, and make it visible optionStrings = new string[optionsCollection.options.Count]; for(int i=0; i<optionStrings.Length; i++) { optionStrings[i] = optionsCollection.options[i]; } inputOption = -1; this.optionChooser = optionChooser; }
private void RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { optionStrings = new string[optionsCollection.options.Count]; for (int i = 0; i < optionStrings.Length; i++) { optionStrings[i] = optionsCollection.options[i]; } inputOption = -1; this.optionChooser = optionChooser; }
/// Called by buttons to make a selection. public void SetOption(int selectedOption) { // Call the delegate to tell the dialogue system that we've // selected an option. SetSelectedOption(selectedOption); // Now remove the delegate so that the loop in RunOptions will exit SetSelectedOption = null; dialogueContainer.GetComponent <Image>().enabled = true; }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking /*if (optionsCollection.options.Count > optionButtons.Count) { * Debug.LogWarning("There are more options to present than there are" + * "buttons to present them in. This will cause problems."); * }*/ // Display each option in a button, and make it visible // *** Going to try to remove this, and replace it with my menu system. /* * int i = 0; * foreach (var optionString in optionsCollection.options) { * optionButtons [i].gameObject.SetActive (true); * optionButtons [i].GetComponentInChildren<Text> ().text = optionString; * i++; * }*/ // Make an array out of the the options list strings. string[] optionStrings; optionStrings = new string[optionsCollection.options.Count]; int i = 0; foreach (var optionString in optionsCollection.options) { optionStrings [i] = optionString; i++; } // My menu system: GAME_menu_manager.Instance.SetMenu(optionStrings, true, SetOption); // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } // Hide all the buttons /*foreach (var button in optionButtons) { * button.gameObject.SetActive (false); * }*/ }
public void Act(Yarn.OptionChooser chooser) { if (operation_ != null) { operation_.Apply(ref puzzle_); if (puzzle_.solved) { Debug.Log("Puzzle was solved"); chooser(successOption_); return; } // TODO: Failure mode. } chooser(normalOption_); }
// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons [i].gameObject.SetActive(true); optionButtons [i].GetComponentInChildren <Text> ().text = optionString; i++; } // Record that we're using it SetSelectedOption = optionChooser; //set currently selected option in event system events.SetSelectedGameObject(optionButtons[0].gameObject, new BaseEventData(events)); //optionButtons[0].Select(); //print(optionButtons[0].spriteState); // = optionButtons[0].spriteState.highlightedSprite; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { print("events selected" + events.currentSelectedGameObject); yield return(null); } // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive(false); } }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons[i].gameObject.SetActive(true); optionButtons[i].GetComponentInChildren <TextMeshProUGUI>().text = optionString; i++; } // THIS IS A HACK TO MAKE THE FIRST SELECTED BUTTON ACTUALLY APPEAR SELECTED // Deselect and reselect first button to correctly display highlight after enabling parent GO EventSystem es = GameObject.Find("EventSystem").GetComponent <EventSystem>(); es.SetSelectedGameObject(null); es.SetSelectedGameObject(es.firstSelectedGameObject); // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive(false); } }
public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // create the option dialog window, giving it one button for each option //Debug.Log("Running options!"); optionWindow = CreateOptionWindow(optionsCollection); SetSelectedOption = optionChooser; // until an option is chosen, keep the dialogue runner effectively paused // (good thing we don't need to use its paused flag here, eh?) while (SetSelectedOption != null) { yield return(null); } Destroy(optionWindow); // won't need this anymore! optionWindow = null; yield return(null); }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { messageInput.GetComponentInChildren <Text>().text = ""; // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons[i].gameObject.SetActive(true); optionButtons[i].GetComponentInChildren <Text>().text = (i + 1).ToString() + ". " + optionString; i++; } // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { for (int j = 0; j < 3; j++) { if (Input.GetKeyDown((j + 1).ToString()) && optionButtons[j].gameObject.activeInHierarchy) { SetOption(j); //HideOptions(); } } yield return(null); } // Hide all the buttons //HideOptions(); }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } isActive = true; // Display each option in a button, and make it visible int i = 0; bool needItem = false; foreach (var optionString in optionsCollection.options) { optionButtons[i].gameObject.SetActive(true); optionButtons[i].GetComponent <SelectableOption>().UpdateText(optionString); if (optionString.Contains("Item")) { needItem = true; } i++; } m_tradingUIManager.ShowItemButton(needItem); // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive(false); } isActive = false; }
// Called when it is time to present options to the player public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { ChoicePanel.gameObject.SetActive(true); for (int i = 0; i < optionsCollection.options.Count; i++) { string optionString = optionsCollection.options[i]; ChoiceTexts[i].transform.parent.gameObject.SetActive(true); ChoiceTexts[i].text = optionString; } SetSelectedOption = optionChooser; while (SetSelectedOption != null) { yield return(null); } foreach (var button in ChoiceTexts) { button.transform.parent.gameObject.SetActive(false); } }
// Called by buttons to make a selection. public void SetOption(int selectedOption) { // Call the delegate to tell the dialogue system that we've // selected an option. SetSelectedOption (selectedOption); // Now remove the delegate so that the loop in RunOptions will exit SetSelectedOption = null; }
/// <summary> /// Called by buttons to make a selection /// </summary> /// <param name="selectedOption"></param> public void SetOption(int selectedOption) { SetSelectedOption(selectedOption); // Call delegate. Tell dialogue system option was selected. SetSelectedOption = null; // Remove delegate exiting 'RunOptions' loop }
public override System.Collections.IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { if (optionsHandler != null) { optionsHandler(optionsCollection, optionChooser); } if (expectedOptions.Count > 0) { var selection = expectedOptions.Dequeue(); var index = optionsCollection.options.IndexOf(selection); Assert.AreNotEqual(index, -1, "Failed to find option \"{0}\"", selection); Assert.Less(index, optionsCollection.options.Count); optionChooser(index); } yield break; }
// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons [i].gameObject.SetActive (true); optionButtons [i].GetComponentInChildren<Text> ().text = optionString; i++; } // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) do { yield return null; } while (SetSelectedOption != null); // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive (false); } }
/// Show a list of options and wait for input public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { if (optionsCollection.options.Count > 0) { choices.SetActive(true); } // Display each option in a button, and make it visible GameObject[] buttons = new GameObject[optionsCollection.options.Count]; for (int i = 0; i < optionsCollection.options.Count; ++i) { GameObject choice = Instantiate(bookButton); buttons[i] = choice; choice.GetComponent <TextMeshProUGUI>().text = optionsCollection.options[i]; choice.transform.SetParent(choices.transform, false); int o = i; int p = int.Parse(Regex.Match(optionsCollection.options[i], @"urn to page (\d*)").Groups[1].Value); choice.GetComponent <Button>().onClick.AddListener(() => SetOption(o, p)); } SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } // disable interaction foreach (GameObject go in buttons) { go.GetComponent <TextMeshProUGUI>().raycastTarget = false; } // start flips bool flipDir = int.Parse(pageNumberL.text) < page; int numFlips = Mathf.Clamp(Mathf.Abs(int.Parse(pageNumberL.text) - page) / 2, 6, 24); float speed = 12.0f / numFlips; for (int i = 0; i < numFlips; ++i) { GetComponent <PageFlip>().Flip(flipDir, 0.07f * i * speed + Random.Range(0.0f, 0.03f), i == 0 || i == numFlips - 1); } GetComponent <AudioSource>().pitch = Mathf.Clamp(1.0f / (speed), 0.75f, 1.25f) + Random.Range(-.1f, 0.1f); GetComponent <AudioSource>().Play(); // wait until flips are partially done yield return(new WaitForSeconds(1.2f)); // fade out text Color c = pageMat.GetColor(pageMatColorIdx); for (int i = 1; i <= 15; ++i) { c.a = 1.0f - i / 15.0f; pageMat.SetColor(pageMatColorIdx, c); yield return(new WaitForEndOfFrame()); } // clear old page description.text = ""; descriptionContinued.text = ""; pageNumberL.text = ""; pageNumberR.text = ""; // Destroy buttons, hide divider while (choices.transform.childCount > 1) { Transform lastChoice = choices.transform.GetChild(choices.transform.childCount - 1); lastChoice.SetParent(null); Destroy(lastChoice.gameObject); } choices.SetActive(false); }
// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionIndicators.Length) { Debug.LogWarning("There are more options to present than there are" + "indicators to display. This will cause problems."); } PositionBubble(playerName); //show bubble over player because we're deciding dialogue #region ShowOptionUI optionIndicators[0].transform.parent.GetComponent <LayoutElement>().ignoreLayout = false; //make indicator parent respond to layout for (int i = 0; i < optionsCollection.options.Count; i++) //for every dialogue option { optionIndicators[i].SetActive(true); //enable option indicators optionsCollection.options[i] = AddLineBreaks(optionsCollection.options[i]); //add line breaks to the option text } foreach (GameObject arrow in arrows) //enable arrows { arrow.SetActive(true); } stemImage.enabled = false; //disable stem image because we're thinking optionPanelLayout.padding.left = optionPanelLayout.padding.right = Mathf.RoundToInt(layoutPaddings[1].x); optionPanelLayout.padding.top = optionPanelLayout.padding.bottom = Mathf.RoundToInt(layoutPaddings[1].y); #endregion int currentlyDisplayedOption = 0; //keep track of what option we're on DisplayOption(optionsCollection.options[currentlyDisplayedOption], currentlyDisplayedOption); //display first option by default SetSelectedOption = optionChooser; //Record that we're using it bool axisReady = true; //so the joystick has to go back to zero before you can change again yield return(new WaitForSeconds(.1f)); while (SetSelectedOption != null) // Wait until the chooser has been used and then removed (see SetOption below) { #region GetChangeInput float h = Input.GetAxis("Horizontal"); if (h > deadZone && axisReady) { if (currentlyDisplayedOption < optionsCollection.options.Count - 1) { currentlyDisplayedOption++; } else { currentlyDisplayedOption = 0; } DisplayOption(optionsCollection.options[currentlyDisplayedOption], currentlyDisplayedOption); axisReady = false; } else if (h < -deadZone && axisReady) { if (currentlyDisplayedOption < 1) { currentlyDisplayedOption = optionsCollection.options.Count - 1; } else { currentlyDisplayedOption--; } DisplayOption(optionsCollection.options[currentlyDisplayedOption], currentlyDisplayedOption); axisReady = false; } else if (h < deadZone && h > -deadZone && !axisReady) { axisReady = true; } #endregion #region GetSelectInput if (Input.GetButtonDown("Interact")) { SetOption(currentlyDisplayedOption); yield return(null); } #endregion yield return(null); } #region HideOptionUI optionIndicators[0].transform.parent.GetComponent <LayoutElement>().ignoreLayout = true; //make indicator parent not respond to layout for (int i = 0; i < optionsCollection.options.Count; i++) //for every dialogue option { optionIndicators[i].SetActive(false); //disable option indicators } foreach (GameObject arrow in arrows) //enable arrows { arrow.SetActive(false); } stemImage.enabled = true; //disable stem image because we're thinking optionPanelLayout.padding.left = optionPanelLayout.padding.right = Mathf.RoundToInt(layoutPaddings[0].x); optionPanelLayout.padding.top = optionPanelLayout.padding.bottom = Mathf.RoundToInt(layoutPaddings[0].y); #endregion }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { yield break; }
// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { while (!ReadytoShowOptions) { //check again next frame yield return(null); } Debug.Log("This should not be using GameObject.Find - ie"); GameObject.Find("SettingsPlus").GetComponent <UnityEngine.UI.Button> ().interactable = true; lineText.text = ""; DOC.SpreadToAllButtons(optionsCollection.options.Count); // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons[i].gameObject.SetActive(true); optionButtons[i].GetComponentInChildren <Text>().text = optionString; i++; } // Record that we're using it if (!optionsCollection.options[0].ToLower().Contains("ask me")) { SetSelectedOption = DOC.MoveToQuestionSelected; SetSelectedOption += optionChooser; } else { SetSelectedOption = optionChooser; } // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { yield return(null); } if (!optionsCollection.options[0].ToLower().Contains("ask me")) { // Hide all the buttons foreach (var button in optionButtons) { button.GetComponent <DialogueButtonController>().Disable(true); GameObject.Find("SettingsPlus").GetComponent <UnityEngine.UI.Button> ().interactable = false; } } yield return(new WaitWhile(DOC.Busy)); }
private void ClearOptionMap() { SetSelectedOption = null; SetSelectedOptionMap.Clear(); }
public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } List <SelectedOptionAction> actions = new List <SelectedOptionAction>(); int optionIndex = 0; int successIndex = -1; int failureIndex = -1; foreach (var optionString in optionsCollection.options) { switch (optionString.Trim()) { case "SUCCESS": successIndex = optionIndex; break; case "FAILURE": failureIndex = optionIndex; break; } optionIndex++; } optionIndex = 0; foreach (var optionString in optionsCollection.options) { switch (optionString.Trim()) { case "COMMANDS": foreach (BitmaskOperation op in storage.EnabledOperations()) { actions.Add(new SelectedOptionAction(op, ref puzzle_, optionIndex, successIndex, failureIndex)); } break; case "ABORT": actions.Add(new SelectedOptionAction(optionIndex, "Abort")); break; case "SUCCESS": break; case "FAILURE": break; default: actions.Add(new SelectedOptionAction(optionIndex, optionString)); break; } optionIndex++; } if (actions.Count > 0) { int buttonIndex = 0; if (actions.Count > optionButtons.Count) { Debug.LogWarning("Attempting to add options but count is greater than number of buttons!"); } foreach (SelectedOptionAction action in actions) { optionButtons[buttonIndex].gameObject.SetActive(true); optionButtons[buttonIndex].GetComponentInChildren <Text>().text = action.label; SetSelectedOptionMap.Add(buttonIndex, action); buttonIndex++; } } if (optionsCollection.options.Count > 0) { optionButtons[0].GetComponent <Button>().Select(); } SetSelectedOption = optionChooser; while (SetSelectedOption != null) { yield return(null); } DisableButtons(); }
/// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible openToOptions = true; //highlight.gameObject.SetActive(true); highlightOption = 0; accidentPrevention = 0; int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons [i].gameObject.SetActive(true); optionButtons [i].GetComponentInChildren <Text> ().text = optionString; i++; } optionCount = i; // Record that we're using it SetSelectedOption = optionChooser; //highlight.transform.position = optionButtons[highlightOption].transform.position; // Wait until the chooser has been used and then removed (see SetOption below) while (SetSelectedOption != null) { if (accidentPrevention < 0.5f) { accidentPrevention += Time.deltaTime; } //highlight.transform.position = optionButtons[highlightOption].transform.position; for (int x = 0; x < buttonText.Count; x++) { if (x == highlightOption) { //optionButtons[x].image.color = new Color(0.56078f, 0.50196f, 0.92549f); ColorBlock cb = optionButtons[x].colors; cb.normalColor = new Color(0.1553724f, 0.137104f, 0.745283f); //cb.normalColor = Color.red; optionButtons[x].colors = cb; buttonText[x].color = Color.white; } else { //optionButtons[x].image.color = Color.white; ColorBlock cb = optionButtons[x].colors; cb.normalColor = Color.white; optionButtons[x].colors = cb; buttonText[x].color = Color.black; } } //highlight.gameObject.SetActive(true); yield return(null); } // Hide all the buttons openToOptions = false; //highlight.gameObject.SetActive(false); foreach (var button in optionButtons) { button.gameObject.SetActive(false); } }
/// Display the options, and call the optionChooser when done. public abstract IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser);
public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { options.gameObject.SetActive(true); // todo: make sure that the options aren't too big to fit in the box // i don't really know how to check this without actually blitting the // text (if i figure that out, change the convoluted logic in RunCommand) uint numOptions = (uint)optionsCollection.options.Count; if (numOptions > options.Count()) { Debug.LogWarning("Too many options"); } // display all needed options for (int i = 0; i < options.Count(); i++) { DialogueOption option = options.GetOption(i); if (i < numOptions) { option.gameObject.SetActive(true); option.SetText(optionsCollection.options[i]); } else { option.gameObject.SetActive(false); } } // quick explanation of how cursor math works. bottom-most option is // option 0. the one above is option 1 and so on. so with 3 options // where the cursor is currently on the the top-most option: // -> [option 2] // [option 1] // [option 0] // enable and put cursor next to topmost option uint currCursorOption = numOptions - 1; options.PlaceCursor(currCursorOption); while (!Input.GetButtonDown("interact")) { // move cursor if we get an up or down input bool moveCursor = Input.GetButtonDown("vertical"); if (moveCursor) { float updown = Input.GetAxisRaw("vertical"); if (updown == 1) { currCursorOption = (currCursorOption + 1) % numOptions; } else // updown == -1 (can't be 0 if button was pressed) { currCursorOption = (currCursorOption - 1) % numOptions; } options.PlaceCursor(currCursorOption); } yield return(null); } options.gameObject.SetActive(false); optionChooser((int)currCursorOption); yield return(null); }