private void OptionsEvents(DialogueBase db) { DialogueOptions dialogueOptions = db as DialogueOptions; for (int i = 0; i < optionsAmaount; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).gameObject.GetComponent <Text>().text = dialogueOptions.optionsInfo[i].buttonName; UnityEventHandler myEventHandler = optionButtons[i].GetComponent <UnityEventHandler>(); myEventHandler.eventHandler = dialogueOptions.optionsInfo[i].myEvent; if (dialogueOptions.optionsInfo[i].nextDialogue != null) { myEventHandler.myDialogueBase = dialogueOptions.optionsInfo[i].nextDialogue; } else { myEventHandler.myDialogueBase = null; } if (dialogueOptions.optionsInfo[i].optionsImage != null) { newoptionsImage.sprite = dialogueOptions.optionsInfo[i].optionsImage; } else { newoptionsImage.sprite = null; } } }
static void Main(string[] args) { DialogueManager manager = new DialogueManager(); DialogueNode starting = manager.startingDialouge; Conversation convo = new Conversation(new string[] { "derek", "player" }, starting); while (!convo.conversationEnded) { if (convo.CurrentDialouge.GetType() == (typeof(DialogueOptions))) { DialogueOptions newDialogue = (DialogueOptions)convo.CurrentDialouge; Dialogue[] nodes = new Dialogue[100]; int i = 1; foreach (KeyValuePair <string, Dialogue> option in newDialogue.Options) { Console.WriteLine(i + ": " + option.Key); nodes[i] = option.Value; i++; } Console.WriteLine("-----------------------------------------------"); int selection = int.Parse(Console.ReadLine()); Console.WriteLine("-----------------------------------------------"); Console.WriteLine(convo.GetCurrentSpeaker() + ": " + nodes[selection].phrase); Console.WriteLine("-----------------------------------------------"); convo.ChooseOption(nodes[selection]); } else { Console.WriteLine(convo.GetCurrentSpeaker() + ": " + convo.ContinueConversaton()); Console.WriteLine("-----------------------------------------------"); } } }
private void OptionsParser(DialogueBase db) { if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; optionsAmount = dialogueOptions.optionsInfo.Length; questionText.text = dialogueOptions.questionText; for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); } for (int i = 0; i < optionsAmount; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).GetComponent <Text>().text = dialogueOptions.optionsInfo[i].buttonName; UnityEventHandler myEventHandler = optionButtons[i].GetComponent <UnityEventHandler>(); myEventHandler.eventHandler = dialogueOptions.optionsInfo[i].myEvent; if (dialogueOptions.optionsInfo[i].nextDialogue != null) { myEventHandler.myDialogue = dialogueOptions.optionsInfo[i].nextDialogue; } else { myEventHandler.myDialogue = null; } } } else { isDialogueOption = false; } }
private void OptionsParser(DialogueBase db) { if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialgoueOption = db as DialogueOptions; numOfOptions = dialgoueOption.optionsInfo.Length; questionText.text = dialgoueOption.questionText; // optionButtons[0].GetComponent<Button>().Select(); //select option with keyboard for (int i = 0; i < numOfOptions; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = dialgoueOption.optionsInfo[i].buttonName; MissionHandler handleEvent = optionButtons[i].GetComponent <MissionHandler>(); handleEvent.EventHandler = dialgoueOption.optionsInfo[i].missionEvent; } } else { isDialogueOption = false; } }
public void EnqueueDialogue(DialogueBase db) { if (inDialogue || QuestManager.instance.InQuestUI) { return; } EndBool = false; buffer = true; inDialogue = true; StartCoroutine(BufferTimer()); dialogueBox.SetActive(true); dialogueInfo.Clear(); currentDialogue = db; if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; optionsAmount = dialogueOptions.optionsInfo.Length; questionText.text = dialogueOptions.questionText; for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); } for (int i = 0; i < optionsAmount; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).gameObject.GetComponent <TextMeshProUGUI>().text = dialogueOptions.optionsInfo[i].buttonName; UnityEventHandler myEventHandler = optionButtons[i].GetComponent <UnityEventHandler>(); myEventHandler.eventHandler = dialogueOptions.optionsInfo[i].myEvent; if (dialogueOptions.optionsInfo[i].nextDialogue != null) { myEventHandler.myDialogue = dialogueOptions.optionsInfo[i].nextDialogue; } else { myEventHandler.myDialogue = null; } } } else { isDialogueOption = false; } foreach (DialogueBase.NPCInfo info in db.dialogueInfo) { dialogueInfo.Enqueue(info); } totalLineCount = dialogueInfo.Count; DequeueDialogue(); }
public void SetDialogueAction(EventManager.DialogueAction action) { DialogueOptions newDialogue = new DialogueOptions(action.ToString()); if (allOptions == null) { allOptions = new Dictionary <EventManager.DialogueAction, DialogueOptions>(); } allOptions.Add(action, newDialogue); }
public TextBoxFlyout( string caption, MessageBoxImage image, DialogueOptions options = DialogueOptions.None, double?maxWidth = null) { InitializeComponent(); // texts this.LabelCaption.Content = caption; // dialogue width if (maxWidth.HasValue && maxWidth.Value > 200) { OuterGrid.MaxWidth = maxWidth.Value; } // options this.Options = options; // image this.ImageIcon.Source = null; if (image == MessageBoxImage.Error) { this.ImageIcon.Source = new BitmapImage( new Uri("/AasxIntegrationBaseWpf;component/Resources/msg_error.png", UriKind.RelativeOrAbsolute)); } if (image == MessageBoxImage.Hand) { this.ImageIcon.Source = new BitmapImage( new Uri("/AasxIntegrationBaseWpf;component/Resources/msg_hand.png", UriKind.RelativeOrAbsolute)); } if (image == MessageBoxImage.Information) { this.ImageIcon.Source = new BitmapImage( new Uri("/AasxIntegrationBaseWpf;component/Resources/msg_info.png", UriKind.RelativeOrAbsolute)); } if (image == MessageBoxImage.Question) { this.ImageIcon.Source = new BitmapImage(new Uri( "/AasxIntegrationBaseWpf;component/Resources/msg_question.png", UriKind.RelativeOrAbsolute)); } if (image == MessageBoxImage.Warning) { this.ImageIcon.Source = new BitmapImage(new Uri( "/AasxIntegrationBaseWpf;component/Resources/msg_warning.png", UriKind.RelativeOrAbsolute)); } // focus this.TextBoxText.Text = ""; this.TextBoxText.Focus(); this.TextBoxText.Select(0, 999); FocusManager.SetFocusedElement(this, this.TextBoxText); }
public void EnqueueDialogue(DialogueBase db) { if (stillTyping) { return; } else { stillTyping = true; } DialogueBox.SetActive(true); DialogueInfo.Clear(); if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; optionsAmount = dialogueOptions.OptionsInfo.Length; QuestionText.text = dialogueOptions.QuestionText; for (int i = 0; i < OptionButtons.Length; i++) { OptionButtons[i].SetActive(false); } for (int i = 0; i < optionsAmount; i++) { OptionButtons[i].SetActive(true); OptionButtons[i].transform.GetChild(0).gameObject.GetComponent <TMP_Text>().text = dialogueOptions.OptionsInfo[i].ButtonName; UnityEventHandler myEventHandler = OptionButtons[i].GetComponent <UnityEventHandler>(); myEventHandler.EventHandler = dialogueOptions.OptionsInfo[i].MyEvent; if (dialogueOptions.OptionsInfo[i].nextDialogue != null) { myEventHandler.MyDialogue = dialogueOptions.OptionsInfo[i].nextDialogue; } else { myEventHandler.MyDialogue = null; } } } else { isDialogueOption = false; } foreach (DialogueBase.Info info in db.DialogueInfo) { DialogueInfo.Enqueue(info); } DequeueDialogue(); }
public void EnqueueDialogue(Dialogue db) { if (inDialogue) { return; } inDialogue = true; dialogueBox.SetActive(true); dialogueInfo.Clear(); if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; optionsAmount = dialogueOptions.optionsInfo.Length; questionText.text = dialogueOptions.questionText; for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); //makes all options buttons inactive at start } for (int i = 0; i < optionsAmount; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).gameObject.GetComponent <Text>().text = dialogueOptions.optionsInfo[i].buttonName; UnityEventHandler myEventHandler = optionButtons[i].GetComponent <UnityEventHandler>(); myEventHandler.eventHandler = dialogueOptions.optionsInfo[i].myEvent; if (dialogueOptions.optionsInfo[i] != null) //checks if there is another dialogue option { myEventHandler.myDialogue = dialogueOptions.optionsInfo[i].nextDialogue; //queues next dialogue } else { myEventHandler.myDialogue = null; } } } else { isDialogueOption = false; } foreach (Dialogue.Info info in db.dialogueInfo) { dialogueInfo.Enqueue(info); } DequeueDialogue(); }
public AnyUiDialogueDataTextBox( string caption = "", double?maxWidth = null, AnyUiMessageBoxImage symbol = AnyUiMessageBoxImage.None, DialogueOptions options = DialogueOptions.None, string text = null) : base(caption, maxWidth) { this.Symbol = symbol; this.Options = options; if (text != null) { this.Text = text; } }
//options rangées private void OptionsParser(DialogueBase db) { if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; optionsAmount = dialogueOptions.optionsInfo.Length; questionText.text = dialogueOptions.questionText; boolIndex = dialogueOptions.boolIndex; //on désactive tous les boutons for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); } //puis on active ceux qu'on utilise for (int i = 0; i < optionsAmount; i++) { optionButtons[i].SetActive(true); // vérifier qu'il n'y a qu'un seul enfant Text par button optionButtons[i].transform.GetChild(0).gameObject.GetComponent <Text>().text = dialogueOptions.optionsInfo[i].buttonName; //on équivaut UnityEvent et myEvent UnityEventHandler myEventHandler = optionButtons[i].GetComponent <UnityEventHandler>(); myEventHandler.eventHandler = dialogueOptions.optionsInfo[i].myEvent; //active myButton //vérifie s'il y a un dialogue dans la liste if (dialogueOptions.optionsInfo[i].nextDialogue != null) { //crée un nouveau dialogue myEventHandler.myDialogue = dialogueOptions.optionsInfo[i].nextDialogue; } else { myEventHandler.myDialogue = null; } } } else { isDialogueOption = false; } }
private void OptionsParser(DialogueBase db) { if (db is DialogueOptions) { _isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; _optionsAmount = dialogueOptions.optionsInfo.Length; questionText.text = dialogueOptions.questionText; // Clear previous buttons for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); } for (int i = 0; i < _optionsAmount; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).gameObject.GetComponent <TextMeshProUGUI>().text = dialogueOptions.optionsInfo[i].optionText; OptionButtonEventHandler eventHandler = optionButtons[i].GetComponent <OptionButtonEventHandler>(); eventHandler.buttonEventHandler = dialogueOptions.optionsInfo[i].optionEvent; // If there is a next dialogue to be triggered if (dialogueOptions.optionsInfo[i].nextDialogue != null) { eventHandler.dialogue = dialogueOptions.optionsInfo[i].nextDialogue; } else { eventHandler.dialogue = null; } } } else { _isDialogueOption = false; } }
private void ParseOptions(DialogueBase db) { if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; numOptions = dialogueOptions.optionInfo.Length; optionButtons[0].GetComponent <Button>().Select(); //has the first button automatically selected (won't be highlighted until you move the cursor) for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); //makes sure no buttons are showing } for (int i = 0; i < numOptions; i++) { optionButtons[i].SetActive(true); //activates only the required number of options optionButtons[i].transform.GetChild(0).gameObject.GetComponent <Text>().text = dialogueOptions.optionInfo[i].buttonName; //sets button names UnityEventHandler handler = optionButtons[i].GetComponent <UnityEventHandler>(); //allows access to button trigger to set custom event handler.eventHandler = dialogueOptions.optionInfo[i].myEvent; //hooks up the UnityEventHandler to the button's events and triggers if (dialogueOptions.optionInfo[i].nextDialogue != null) { handler.dialogue = dialogueOptions.optionInfo[i].nextDialogue; //displays option branch dialogue if available } else { handler.dialogue = null; //needs to be null for UnityEventHandler to know what to do with it } } } else { isDialogueOption = false; } }
private void DialogueSettings(DialogueBase db) { if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; optionsAmaount = dialogueOptions.optionsInfo.Length; questionText.text = dialogueOptions.questionText; for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); } //options events OptionsEvents(db); } else { isDialogueOption = false; } }
public override void OnOptions(DialogueOptions options) // Called when an Options section begins { base.OnOptions(options); DestroyButtons(); // Destroy any previous buttons info.text = "Talking to " + activeDialogue.gameObject.name; // Inform the player who the aye talking to text.text = ""; // Nullify any previous Speech data // Loop through the options we have been given for (int i = 0; i < options.options.Count; i++) { // Spawn a button for each option GameObject button = Instantiate(buttonPrefab); button.transform.parent = container.transform; // Display the Option inside the button button.GetComponentInChildren <Text>().text = options.GetOptions[i]; // Tell the button to move forward when clicked int x = i; button.GetComponent <Button>().onClick.AddListener(() => { Iterate(x); }); } }
private void ParseOptions(DialogueBase db) { if (db is DialogueOptions) { isDialogueOption = true; DialogueOptions dialogueOptions = db as DialogueOptions; numOptions = dialogueOptions.optionInfo.Length; optionButtons[0].GetComponent <Button>().Select(); for (int i = 0; i < optionButtons.Length; i++) { optionButtons[i].SetActive(false); } for (int i = 0; i < numOptions; i++) { optionButtons[i].SetActive(true); optionButtons[i].transform.GetChild(0).gameObject.GetComponent <Text>().text = dialogueOptions.optionInfo[i].buttonName; UnityEventHandler handler = optionButtons[i].GetComponent <UnityEventHandler>(); handler.eventHandler = dialogueOptions.optionInfo[i].myEvent; if (dialogueOptions.optionInfo[i].nextDialogue != null) { handler.dialogue = dialogueOptions.optionInfo[i].nextDialogue; } else { handler.dialogue = null; } } } else { isDialogueOption = false; } }
private void SetOptionButton(GameObject button, DialogueOptions options) { button.SetActive(true); button.GetComponent <Text>().text = options.tempText; exit.GetComponent <Button>().onClick.AddListener(delegate { SetSelectedOption(options.destinationNodeID); }); }
public override int GetHashCode() { int hashCode = 0; unchecked { if (unknown != null) { hashCode += 1000000007 * unknown.GetHashCode(); } hashCode += 1000000009 * Type.GetHashCode(); hashCode += 1000000021 * Gender.GetHashCode(); hashCode += 1000000033 * Race.GetHashCode(); hashCode += 1000000087 * Class.GetHashCode(); hashCode += 1000000093 * Magic.GetHashCode(); hashCode += 1000000097 * Level.GetHashCode(); hashCode += 1000000103 * Language.GetHashCode(); hashCode += 1000000123 * Appearance.GetHashCode(); hashCode += 1000000181 * Face.GetHashCode(); hashCode += 1000000207 * InventoryPicture.GetHashCode(); hashCode += 1000000223 * ActionPoints.GetHashCode(); hashCode += 1000000241 * DialogueOptions.GetHashCode(); hashCode += 1000000271 * ResponseOptions.GetHashCode(); hashCode += 1000000289 * TrainingPoints.GetHashCode(); hashCode += 1000000297 * Gold.GetHashCode(); hashCode += 1000000321 * Rations.GetHashCode(); hashCode += 1000000349 * Conditions.GetHashCode(); hashCode += 1000000363 * Strength.GetHashCode(); hashCode += 1000000403 * Intelligence.GetHashCode(); hashCode += 1000000409 * Dexterity.GetHashCode(); hashCode += 1000000411 * Speed.GetHashCode(); hashCode += 1000000427 * Stamina.GetHashCode(); hashCode += 1000000433 * Luck.GetHashCode(); hashCode += 1000000439 * MagicResistance.GetHashCode(); hashCode += 1000000447 * MagicTallent.GetHashCode(); hashCode += 1000000453 * CloseRangeCombat.GetHashCode(); hashCode += 1000000459 * LongRangeCombat.GetHashCode(); hashCode += 1000000483 * CriticalHit.GetHashCode(); hashCode += 1000000513 * Lockpicking.GetHashCode(); hashCode += 1000000531 * LifePoints.GetHashCode(); hashCode += 1000000579 * SpellPoints.GetHashCode(); hashCode += 1000000007 * Age.GetHashCode(); hashCode += 1000000009 * BaseProtection.GetHashCode(); hashCode += 1000000021 * Protection.GetHashCode(); hashCode += 1000000033 * BaseDamage.GetHashCode(); hashCode += 1000000087 * Damage.GetHashCode(); hashCode += 1000000093 * Experience.GetHashCode(); if (Spells != null) { hashCode += 1000000097 * Spells.GetHashCode(); } if (Name != null) { hashCode += 1000000103 * Name.GetHashCode(); } if (SpellStrengths != null) { hashCode += 1000000123 * SpellStrengths.GetHashCode(); } } return(hashCode); }
public void Initialize() { DisplayedOptions = new List <DialogueOption>(DialogueOptions.Where(dialogueOption => dialogueOption.Visible)); }