public void Update() { Console.Clear(); Console.WriteLine("Доступные команды >> ShowAll|Start[int]"); var splitedComand = Console.ReadLine()?.Split(' '); string command = splitedComand[0]; int posArg = Convert.ToInt32(splitedComand[1]); switch (command) { case "ShowAll": Console.WriteLine(); Console.WriteLine("Список доступных диалогов:"); Console.WriteLine(new string('-', 15)); foreach (var dialogInfo in _collection.GetNames()) { Console.WriteLine($"{dialogInfo.Key} - {dialogInfo.Value}"); } Console.ReadLine(); break; case "Start": _dialogGui = new DialogGui(_collection.GetDialog(posArg)); Console.WriteLine(); Console.WriteLine("Режим диалога"); Console.WriteLine(new string('-', 15)); _dialogGui.Update(); break; } }
/// <summary> /// Shows the dialog with the given ID. /// </summary> /// <param name="id"></param> public void ShowDialog(string id) { // Clear all the old options foreach (Transform child in dialogOptionsGo.transform) { Destroy(child.gameObject); } // Get the Dialog and its' options. Dialog dialog = dialogCollection.GetDialog(id); DialogOption[] options = dialog.DialogOptions; dialogText.text = dialog.Text; // Create the options for the dialog. for (int i = 0; i < options.Length; i++) { DialogOption option = options[i]; // Button as parent holding image. GameObject optionGoButton = new GameObject(); optionGoButton.name = "OptionGoButton" + option.Number; // Every single option needs its own gameObject. GameObject optionGo = new GameObject(); optionGo.name = "OptionGo" + option.Number; // Set the options as a child under the dialogOptionsGo, the text as a child of the button. optionGo.transform.parent = optionGoButton.transform; optionGoButton.transform.parent = dialogOptionsGo.transform; // Add some shadow and outline to the text for readability Shadow shadow = optionGo.AddComponent <Shadow>(); shadow.effectDistance = new Vector2(2.0f, -2.0f); Outline outline = optionGo.AddComponent <Outline>(); outline.effectDistance = new Vector2(1.0f, -1.0f); // Add the text to the optionGo Text optionText = optionGo.AddComponent <Text>(); optionText.name = "OptionText" + option.Number; optionText.text = option.Text; optionText.font = dialogFont; optionText.fontSize = 24; optionText.verticalOverflow = VerticalWrapMode.Overflow; // Align the text and adjust the size optionText.alignment = TextAnchor.UpperCenter; RectTransform rectTransform = optionText.rectTransform; rectTransform.sizeDelta = new Vector2(1000, optionText.fontSize); // Add the button for the option and adjust the size Button button = optionGoButton.AddComponent <Button>(); Image optionImage = optionGoButton.AddComponent <Image>(); RectTransform rectTransformButton = optionImage.rectTransform; rectTransformButton.localPosition = new Vector3(0, -i * optionText.fontSize, 0); rectTransformButton.sizeDelta = new Vector2(1000, optionText.fontSize); // Adjust button image and colors optionImage.sprite = buttonSprite; button.targetGraphic = optionImage; ColorBlock buttonColors = button.colors; buttonColors.normalColor = new Color(1.0f, 0.8f, 0.0f, 0.0f); buttonColors.highlightedColor = new Color(1.0f, 0.8f, 0.0f, 1.0f); buttonColors.pressedColor = new Color(0.8f, 0.8f, 0.8f, 1.0f); buttonColors.disabledColor = new Color(0.6f, 0.6f, 0.6f, 0.5f); button.colors = buttonColors; button.onClick.AddListener(delegate { DialogOptionOnClick(option); }); } // Raise the DialogOpenEvent Eventhandler.Instance.DialogOpenEvent.Invoke(dialog); dialogCanvasGo.SetActive(true); MouseManager.Instance.MouseActive = true; }