public void OnEnable() { container = (DialogContainer)target; list = new ReorderableList(container.Properties, typeof(DialogProperty), false, true, true, true); list.drawElementCallback += OnDrawElement; list.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Properties"); }
public void OpenDialog(UserControl ctrl, string title, bool controlsvisible = true) { DialogContainer.DialogContent = ctrl; DialogContainer.DialogControlsVisibility = controlsvisible ? Visibility.Visible : Visibility.Collapsed; DialogContainer.Title = title; DialogContainer.Open(); }
static void GetIDCount() { DialogContainer dialogContainer = new DialogContainer(); Type[] dialogTypes = { typeof(Dialog) }; XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer), dialogTypes); FileStream fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "dialogs.xml"), FileMode.Open); dialogContainer = (DialogContainer)serializer.Deserialize(fs); fs.Close(); int minId = 0; foreach (Dialog dialog in dialogContainer.Dialogs) { if (dialog.ID == minId) { minId = dialog.ID + 1; } } currentId = minId; }
public void Run() { configuration = new Configuration(); dialogContainer = new DialogContainer(); statistics = new Statistics(configuration); statistics.ReportSessionStart(); toolsView = new ToolsView(dialogContainer, statistics); int storedGameLevel; if (Int32.TryParse(configuration.GetValue(GameLevelConfigurationKey), out storedGameLevel)) { gameLevel = storedGameLevel; } else { gameLevel = DefaultLevel; firstTime = true; } Document.Body.AppendChild(toolsView.HtmlElement); Document.Body.AppendChild(dialogContainer.HtmlElement); Window.AddEventListener("hashchange", e => OnHashChanged()); Window.AddEventListener("resize", e => UpdateLayout()); Window.AddEventListener("unload", e => statistics.ReportSessionEnd()); CreateInitialGame(); }
public AnswerConditionRenderer(DialogAnswer answer) { this.answer = answer; container = answer.parent; list = new ReorderableList(answer.conditions, typeof(DialogAnswerCondition), false, true, true, true); list.drawElementCallback += OnDrawElement; list.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Conditions"); }
public override void OnInspectorGUI() { container = (DialogContainer)target; container.DialogName = EditorGUILayout.TextField("DialogName:", container.DialogName); list.DoLayoutList(); container.Statements.ForEach((s) => s?.OnGUI()); }
public static DialogContainer Load(TextAsset _xml) { XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer)); StringReader reader = new StringReader(_xml.text); DialogContainer dialogs = serializer.Deserialize(reader) as DialogContainer; reader.Close(); return(dialogs); }
internal static void Subscribe(DialogContainer container, Type senderType) { _Listeners.Add(new Tuple <DialogContainer, Type>(container, senderType)); while (_DialogsOnQueue.Count > 0) { container.DisplayDialogAsync(_DialogsOnQueue[0].Item2); _DialogsOnQueue.RemoveAt(0); } }
protected void AddDialog() { try { DialogContainer dialog = new DialogContainer(); Add(dialog); } catch (Exception ex) { Console.WriteLine(""); } }
private void OnSelectionChange() { AssetDatabase.SaveAssets(); var x = Selection.GetFiltered(typeof(DialogContainer), SelectionMode.Editable); if (x.Length == 0) { return; } ActiveContainer = (DialogContainer)x[0]; graph.OnSelectionChange(); Repaint(); }
private void SaveContainerDialogs(DialogContainer container, string folder) { foreach (var dialog in container.Dialogs.GetDialogs()) { var filePath = Path.GetFullPath(Path.Combine(folder, $"{dialog.Id}.dialog")); File.WriteAllText(filePath, JsonConvert.SerializeObject(dialog, serializerSettings)); if (dialog is DialogContainer container2) { SaveContainerDialogs(container2, folder); } } }
// Use this for initialization void Start() { Type[] dialogTypes = { typeof(Dialog), typeof(TextDialog), typeof(Action), typeof(DialogFight) }; XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer), dialogTypes); TextReader textReader = new StreamReader(Application.streamingAssetsPath + "/dialogs.xml"); dialogContainer = (DialogContainer)serializer.Deserialize(textReader); textReader.Close(); dialogElement.gameObject.SetActive(false); actionsElement.gameObject.SetActive(false); }
// Use this for initialization void Start() { DialogContainer dc = DialogContainer.Load(path); foreach (DialogsClass dialog in dc.dialogs) { //print(dialog.name); //print(dialog.sentenceNumber); //print(dialog.mood); //print(dialog.dialog); NPCLoader(dialog.name, dialog.sentenceNumber, dialog.mood, dialog.dialog); } }
public void Setup(bool won) { GetPersistData(); didP1Win = won; playeractor = CreateActor(PD.GetPlayerSpritePath(PD.p1Char), new Vector3(-2.1f, 0.2f), false, true, true); playeractor.SetScale(0.4f); opponentactor = CreateActor(PD.GetPlayerSpritePath(PD.p2Char), new Vector3(2.1f, 0.2f), true, true, true); opponentactor.SetScale(0.4f); tbox = (DialogContainer)gameObject.AddComponent("DialogContainer"); tbox.Setup(new Vector3(0.0f, -1.4f), true); isFirstLoad = true; PD.sounds.SetSoundVolume(PD.GetSaveData().savedOptions["vol_s"] / 350.0f); setText(); }
public static DialogContainer Load(string path) { TextAsset _xml = Resources.Load <TextAsset>(path); XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer)); StringReader reader = new StringReader(_xml.text); DialogContainer dialogs = serializer.Deserialize(reader) as DialogContainer; reader.Close(); return(dialogs); }
//!Zapisuje graf do pliku. public void save(string fileName) { if (edges.Count == 0) { return; } DialogContainer dialogContainer = ScriptableObject.CreateInstance <DialogContainer>(); //Tworzy plik zapisu. List <Edge> connectedPorts = new List <Edge>(); foreach (Edge edge in edges) { if (edge.input.node != null) { connectedPorts.Add(edge); } } foreach (DialogNode node in nodes) //Tworzy obiekty reprezentujące węzły do zapisu. { if (node.IsRoot) { continue; } NodeDataContainer data = new NodeDataContainer(node.Guid, node.DialogLine, node.Speaker, node.ExitLine, node.IsChoice, node.IsLeaf, node.IsEnding, node.ChoiceOutcomes, node.GetPosition().position); dialogContainer.NodeData.Add(data); } foreach (Edge edge in connectedPorts) //Tworzy obiekty reprezentujące połączenia i przypisuje je do odpowiednich węzłów. { DialogNode outputNode = (DialogNode)edge.output.node; DialogNode inputNode = (DialogNode)edge.input.node; NodeConnection connection = new NodeConnection(outputNode.Guid, edge.output.portName, inputNode.Guid); dialogContainer.Connections.Add(connection); if (edge.output.portName == "root") { dialogContainer.FirstNodeGuid = inputNode.Guid; } else { dialogContainer.NodeData.Find(x => x.Guid == outputNode.Guid).OutputPorts.Add(connection); } } AssetDatabase.CreateAsset(dialogContainer, "Assets/Resources/Dialogs/Trees/" + fileName + ".asset"); //Zapisuje plik jako asset. AssetDatabase.SaveAssets(); }
//!Przygotowuje kolkejne drzewo dialogowe. private void getNextTree() { if (dialogTrees.Count != 0) { currentTree = dialogTrees[0]; dialogTrees.Remove(currentTree); currentNode = currentTree.getFirstNode(); choiceButtons[0].onClick.RemoveAllListeners(); choiceButtons[0].onClick.AddListener(delegate { makeChoice(0); }); } else { currentTree = null; currentNode = null; } }
public void Start() { StateControllerInit(false); playeractor = CreateActor(PD.GetPlayerSpritePath(PD.p1Char), new Vector3(-5.15f, 1.0f)); PD.GetNextOpponent(); opponentactor = CreateActor(PD.GetPlayerSpritePath(PD.p2Char), new Vector3(5.15f, 1.0f), true); skipMenuIsUp = false; XmlNodeList dialogs = GetXMLHead("/" + playeractor.GetPath(PD.p1Char == PersistData.C.FuckingBalloon), "dialogs").SelectNodes("dialog"); XmlNode dialog = dialogs[PD.GetPuzzleLevel()]; dialogArr = dialog.SelectNodes("line"); rawInput = GetInputHandler(); dialogueBox = gameObject.AddComponent <DialogContainer>(); dialogueBox.Setup(new Vector3(0.0f, -3.5f)); bool isBossChar = PD.p1Char == PersistData.C.White || PD.p1Char == PersistData.C.September; curFrame = (!isBossChar && (PD.level == 6 || PD.level == 8))?0:2; StartFrame(curFrame); skipButtonSheet = Resources.LoadAll <Sprite>(SpritePaths.ShortButtons); skipButton = GetGameObject(new Vector3(8.3f, -4.75f), "Skip", skipButtonSheet[0], true, "Pause HUD Buttons"); FontData font = PD.mostCommonFont.Clone(); font.scale = 0.045f; XmlNode top = GetXMLHead(); skipText = GetMeshText(new Vector3(8.3f, -4.61f), GetXmlValue(top, "skip"), font).gameObject; skipText.renderer.sortingLayerName = "Pause HUD Text"; mouseObjects.Add(skipButton); mouseObjects.Add(skipText); skipMenu = GetGameObject(new Vector3(0.0f, 0.0f), "Skip Menu", Resources.Load <Sprite>(SpritePaths.CutsceneSkipBox), false, "HUDText"); string f = string.Format(GetXmlValue(top, "skipmessage"), "\r\n", PD.controller.GetFriendlyActionName(InputMethod.Action.launch), PD.controller.GetFriendlyActionName(InputMethod.Action.pause)); font.scale = 0.08f; font.layerName = "Reference"; skipMenuText = GetMeshText(new Vector3(0.0f, 0.5f), f, font); skipMenuText.text = new WritingWriter().GetWrappedString(skipMenuText, f, skipMenu.renderer.bounds.size); skipMenuText.gameObject.SetActive(false); skipMenu.SetActive(false); PD.sounds.SetSoundVolume(PD.GetSaveData().savedOptions["vol_s"] / 350.0f); }
public void CreateDialog() { GetIDCount(); DialogContainer dialogContainer = new DialogContainer(); Type[] dialogTypes = { typeof(Dialog) }; XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer), dialogTypes); FileStream fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "dialogs.xml"), FileMode.Open); dialogContainer = (DialogContainer)serializer.Deserialize(fs); fs.Close(); dialogContainer.Dialogs.Add(new TextDialog(currentId, nextID ,actorID, name, dialogText)); fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "dialogs.xml"), FileMode.Create); serializer.Serialize(fs, dialogContainer); fs.Close(); }
/// <summary> /// Shows a dialog asynchronously /// </summary> /// <param name="sender">The object that is launching the dialog</param> /// <param name="dialog">The dialog to be shown</param> /// <returns>The task that is used to open the dialog or null if no listener is found</returns> public static Task ShowDialogAsync(object sender, BaseDialog dialog) { var type = sender.GetType(); DialogContainer genericListener = null, specificListener = null; foreach (var listener in _Listeners) { if (listener.Item2.Equals(type)) { // We found a listener specific for that type, so let's use that specificListener = listener.Item1; break; } else if (listener.Item2.IsAssignableFrom(type)) { /* In case we don't find a specific listener, use any that subscribed * for a type that is a parent class of the sender * * For example, if the sender is a Window and we find no one listening * for that specific type, we could use someone who's listening for an * UIElement. */ genericListener = listener.Item1; } } if (specificListener != null) { specificListener.DisplayDialogAsync(dialog); return(dialog.WaitForLoadAsync()); } else if (genericListener != null) { genericListener.DisplayDialogAsync(dialog); return(dialog.WaitForLoadAsync()); } _DialogsOnQueue.Add(new Tuple <Type, BaseDialog>(type, dialog)); return(null); }
//!Ładuje graf do edytora. public void load(string fileName) { DialogContainer dialogContainer = Resources.Load <DialogContainer>("Dialogs/Trees/" + fileName); //Ładuje plik. if (dialogContainer == null) { return; } deleteNodes(dialogContainer); foreach (NodeDataContainer data in dialogContainer.NodeData) //Odtwarza węzły na podstawie pliku. { DialogNode node = new DialogNode(data); foreach (NodeConnection portConnection in dialogContainer.Connections) { if (portConnection.NodeGuid == data.Guid) { node.createPort(portConnection.PortName, Direction.Output); } } view.AddElement(node); node.SetPosition(new Rect(data.Position.x, data.Position.y, 200, 200)); } nodes = view.nodes.ToList().Cast <DialogNode>().ToList(); foreach (NodeConnection portConnection in dialogContainer.Connections) //Odtwarza połączenia. { DialogNode output = nodes.Find(x => x.Guid == portConnection.NodeGuid); DialogNode input = nodes.Find(x => x.Guid == portConnection.TargetGuid); List <Port> ports = output.getOutputPorts(); Port outputPort = ports.Find(x => x.portName == portConnection.PortName); if (input != null) { output.IsLeaf = false; view.Add(outputPort.ConnectTo((Port)input.inputContainer[0])); } else { output.removePort(outputPort); } } }
// -------------------------------------------------------------------------------------------- /// <summary> /// Disposes this object. /// </summary> // -------------------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { if (disposing) { // --- First dispose the dialog container if (_Container != null) { try { _Container.Dispose(); } catch (Exception) { VsDebug.Fail("Failed to dispose container"); } _Container = null; } // --- Dispose the window itself if (_Window != null && _Window is IDisposable) { try { ((IDisposable)_Window).Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose window"); } _Window = null; } // --- Reset the dialog subclass if (_Subclass != null) { _Subclass = null; } // --- Unhook dialog page properties HookProperties(false); } base.Dispose(disposing); }
public void CreateDialog() { GetIDCount(); DialogContainer dialogContainer = new DialogContainer(); Type[] dialogTypes = { typeof(Dialog) }; XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer), dialogTypes); FileStream fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "dialogs.xml"), FileMode.Open); dialogContainer = (DialogContainer)serializer.Deserialize(fs); fs.Close(); dialogContainer.Dialogs.Add(new TextDialog(currentId, nextID, actorID, name, dialogText)); fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "dialogs.xml"), FileMode.Create); serializer.Serialize(fs, dialogContainer); fs.Close(); }
public static DialogContainer Load(string path) { TextAsset _xml = Resources.Load <TextAsset>(path); XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer)); StringReader reader = new StringReader(_xml.text); DialogContainer dialogs = serializer.Deserialize(reader) as DialogContainer; reader.Close(); // reset dictionary dialogs.IdToText.Clear(); foreach (var entry in dialogs.dialogs) { dialogs.IdToText.Add(entry.id, entry.text); } return(dialogs); }
//!Usuwa dotychczasowe węzły z edytora. private void deleteNodes(DialogContainer dialogContainer) { foreach (DialogNode node in nodes) { if (node.IsRoot) { node.Guid = dialogContainer.Connections.Find(x => x.PortName == "root").NodeGuid; } else { foreach (Edge edge in edges) { if (edge.input.node == node) { view.RemoveElement(edge); } } view.RemoveElement(node); } } }
/// <include file='doc\DialogPage.uex' path='docs/doc[@for="DialogPage.Dispose"]' /> /// <devdoc> /// Disposes this object. /// </devdoc> protected override void Dispose(bool disposing) { if (disposing) { if (_container != null) { try { _container.Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose container"); } _container = null; } if (_window != null && _window is IDisposable) { try { ((IDisposable)_window).Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose window"); } _window = null; } if (_subclass != null) { _subclass = null; } HookProperties(false); } base.Dispose(disposing); }
public static DialogContainer Load(string path) { /* * XmlDocument doc = new XmlDocument(); * doc.Load(path); * * XmlNodeList nodeList; * XmlNode root = doc.DocumentElement; */ TextAsset _xml = Resources.Load <TextAsset>(path); XmlSerializer serializer = new XmlSerializer(typeof(DialogContainer)); StreamReader reader = new StreamReader(path); DialogContainer dialogs = serializer.Deserialize(reader) as DialogContainer; reader.Close(); return(dialogs); }
// Use this for initialization void Start() { dialogContainer = DialogContainer.Load(textFile); timer = dialogContainer.dialogs[currentLine].timer; }
internal static void Unsubscribe(DialogContainer container) { _Listeners.RemoveAll(x => x.Item1 == container); }
internal static void Subscribe(DialogContainer container, Type senderType) { _Listeners.Add(new Tuple <DialogContainer, Type>(container, senderType)); }
//!Ustala treść zakończenia poprzez wybór odpowiedniego drzewa. public void setEndingDialog(DialogContainer endingDialog) { dialogTrees.Add(endingDialog); isDisplayingEnding = true; }