public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { if (options is CancellationToken) { throw new ArgumentException($"{nameof(options)} should not ever be a cancellation token"); } EnsureDependenciesInstalled(); var activeDialogState = dc.ActiveDialog.State as Dictionary <string, object>; activeDialogState[AdaptiveKey] = new AdaptiveDialogState(); var state = activeDialogState[AdaptiveKey] as AdaptiveDialogState; // Persist options to dialog state dc.State.SetValue(ThisPath.OPTIONS, options); // Evaluate events and queue up step changes var dialogEvent = new DialogEvent { Name = AdaptiveEvents.BeginDialog, Value = options, Bubble = false }; await OnDialogEventAsync(dc, dialogEvent, cancellationToken).ConfigureAwait(false); // Continue step execution return(await ContinueActionsAsync(dc, options, cancellationToken : cancellationToken).ConfigureAwait(false)); }
protected override async Task <bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent dialogEvent, CancellationToken cancellationToken = default) { var sequenceContext = ToSequenceContext(dc); // Process event and queue up any potential interruptions return(await ProcessEventAsync(sequenceContext, dialogEvent, preBubble : true, cancellationToken : cancellationToken).ConfigureAwait(false)); }
public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { if (options is CancellationToken) { throw new ArgumentException($"{nameof(options)} should not ever be a cancellation token"); } EnsureDependenciesInstalled(); SetLocalGenerator(dc.Context); // replace initial activeDialog.State with clone of options if (options != null) { dc.ActiveDialog.State = JsonConvert.DeserializeObject <Dictionary <string, object> >(JsonConvert.SerializeObject(options)); } var activeDialogState = dc.ActiveDialog.State as Dictionary <string, object>; activeDialogState[AdaptiveKey] = new AdaptiveDialogState(); var state = activeDialogState[AdaptiveKey] as AdaptiveDialogState; // Evaluate events and queue up step changes var dialogEvent = new DialogEvent { Name = AdaptiveEvents.BeginDialog, Value = options, Bubble = false }; await OnDialogEventAsync(dc, dialogEvent, cancellationToken).ConfigureAwait(false); // Continue step execution return(await ContinueActionsAsync(dc, options, cancellationToken : cancellationToken).ConfigureAwait(false)); }
public static void AddDialogEvent(string name, DialogEvent de) { if (!dialogEvents.ContainsKey(name)) dialogEvents.Add(name, de); else dialogEvents[name] = de; }
public static void InvokeEvent(DialogName _dialog, DialogEvent _event) { if (Instance.onGuiEvent != null) { Instance.onGuiEvent.Invoke(_dialog, _event); } }
/// <inheritdoc/> protected override async Task <bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken) { if (e.Name == DialogEvents.ActivityReceived && dc.Context.Activity.Type == ActivityTypes.Message) { //Get interruption mask pattern from expression string regexPattern = this.InterruptionMask?.GetValue(dc.State); // Return true( already handled ) if input matches our regex interruption mask if (!string.IsNullOrEmpty(regexPattern) && Regex.Match(dc.Context.Activity.Text, regexPattern).Success) { return(true); } // Ask parent to perform recognition await dc.Parent.EmitEventAsync(AdaptiveEvents.RecognizeUtterance, value : dc.Context.Activity, bubble : false, cancellationToken : cancellationToken).ConfigureAwait(false); // Should we allow interruptions var canInterrupt = true; if (this.AllowInterruptions != null) { var(allowInterruptions, error) = this.AllowInterruptions.TryGetValue(dc.State); canInterrupt = error == null && allowInterruptions; } // Stop bubbling if interruptions ar NOT allowed return(!canInterrupt); } return(false); }
public void ShowDialog(Dialog newDialog) { dialog = newDialog; titleObject.text = newDialog.title; bodyObject.text = newDialog.body; button1.GetComponentInChildren <TextMeshProUGUI>().text = newDialog.buttonLabel1.Length > 0 ? newDialog.buttonLabel1 : "Next"; button2.GetComponentInChildren <Text>().text = newDialog.buttonLabel2; if (newDialog.event2.GetPersistentEventCount() > 0) { onButtonTwoClick = newDialog.event2; button2.gameObject.SetActive(true); } else { onButtonTwoClick = null; button2.gameObject.SetActive(false); } if (newDialog.event1.GetPersistentEventCount() > 0) { onButtonOneClick = newDialog.event1; } else { onButtonOneClick = null; } if (newDialog.typeText) { TypeText(); } }
public void SendDialogResponse(bool ok, string dinput) { DialogEvent de = new DialogEvent() { GenericType = BrowserEventType.Dialog, success = ok, input = dinput }; EventPacket ep = new EventPacket { Event = de, Type = BrowserEventType.Dialog }; MemoryStream mstr = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(mstr, ep); byte[] b = mstr.GetBuffer(); // lock (_clientSocket.GetStream()) { _clientSocket.GetStream().Write(b, 0, b.Length); } }
/// <inheritdoc/> protected override async Task <bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken) { if (e.Name == DialogEvents.ActivityReceived && dc.Context.Activity.Type == ActivityTypes.Message) { // Ask parent to perform recognition await dc.Parent.EmitEventAsync(AdaptiveEvents.RecognizeUtterance, value : dc.Context.Activity, bubble : false, cancellationToken : cancellationToken).ConfigureAwait(false); // Should we allow interruptions var canInterrupt = true; if (this.AllowInterruptions != null) { var(allowInterruptions, error) = this.AllowInterruptions.TryGetValue(dc.State); canInterrupt = error == null && allowInterruptions; } // Stop bubbling if interruptions ar NOT allowed return(!canInterrupt); } // Mark activity as handled if this is the CommandResult that we are expecting. if (dc.Context.Activity.Type == ActivityTypes.CommandResult && dc.Context.Activity.Name == this.CommandName.GetValue(dc.State)) { return(true); } return(false); }
// Start is called before the first frame update void Start() { if (dialogEvent == null) { dialogEvent = new DialogEvent(); } dialogueText.text = dialogue_1.serializedNodes[0].text; }
private void OnEnable() { m_monoDialogEvent = target as MonoDialogEvent; m_dialogEvent = m_monoDialogEvent.m_event; UpdateEventTree(); }
//从mono中提取对象并保存到临时对象中,并加入上一级的临时对象的子对象中 static void WriteDialogEvent(Transform monoDialogEvent, int eventOrder) { DialogEvent dialogevent = monoDialogEvent.gameObject.GetComponent <MonoDialogEvent> ().m_event; newWriterDialogEvent = new DialogEvent(dialogevent.m_name); dialogevent.m_eventOrder = eventOrder; writer.m_dialogEventList.Add(newWriterDialogEvent); }
public void StartDialog(DialogEvent dialogEvent) { dialogIndex = 0; hasRung = false; this.currentDialog = dialogEvent; background.SetActive(true); LoadFrame(this.currentDialog.dialog[dialogIndex]); }
public void InvokeEvent(string id, params string[] args) { DialogEvent eventToInvoke = _events.Find(x => x.CheckAliases(id)); if (eventToInvoke == null) { throw new System.ArgumentException($"DialogEvent named {id} not found in dispatcher {name}"); } eventToInvoke?.Invoke(args); }
/** * Finds a dialog set in PosConfig and loads it. */ public void LoadDialog(string dialog_name) { PosEvent posEvent = null; Dialog dialog = (Dialog)PosContext.Instance.Config.Dialogs[dialog_name]; if (dialog != null) { foreach (object obj in dialog.DialogEvents) { DialogEvent dialogEvent = obj as DialogEvent; if (dialogEvent.EventClass.Trim().Length != 0) { try { posEvent = Assembly.GetExecutingAssembly().CreateInstance(dialogEvent.EventClass) as PosEvent; //eventClass.Trim()) as PosEvent; // Push the event in current event stack //this.PushEvent(posEvent); if (posEvent.isDialog) { int state = dialogEvent.State; ((PosDialogEvent)posEvent).PushState(state); } } catch (System.NullReferenceException exNull) { MessageBox.Show(exNull.ToString() + dialogEvent.EventClass); Logger.Error("PosEventStack.cs", "PosEventStack.cs :" + "Invalid class name " + dialogEvent.EventClass); return; } catch (Exception ex) { MessageBox.Show(ex.ToString() + dialogEvent.EventClass); Logger.Error("PosEventStack.cs", "PosEventStack.cs :" + ex.ToString()); return; } if (dialogEvent.EventRequired == 1 || dialogEvent.EventEnabled == 1) { this.PushEvent(posEvent); } } else { //Use the event on top of stack posEvent = this.CurrentPosEvent(); if (posEvent.isDialog && (dialogEvent.EventRequired == 1 || dialogEvent.EventEnabled == 1)) { int state = dialogEvent.State; ((PosDialogEvent)posEvent).PushState(state); } } } } }
private MonoDialogEvent ShowEvent(DialogEvent e) { GameObject go = new GameObject(e.m_name + "-" + e.GetType()); go.transform.SetParent(m_monoDialogWriter.transform); go.transform.position = Vector3.zero; MonoDialogEvent monoEvent = go.AddComponent <MonoDialogEvent> (); monoEvent.Init(e); return(monoEvent); }
//Receiver public void CheckMessage() { if (Initialized) { try { // Ensure that no other threads try to use the stream at the same time. EventPacket ep = _inCommServer.GetMessage(); if (ep != null) { //main handlers if (ep.Type == BrowserEventType.Dialog) { DialogEvent dev = ep.Event as DialogEvent; if (dev != null) { if (OnJavaScriptDialog != null) { OnJavaScriptDialog(dev.Message, dev.DefaultPrompt, dev.Type); } } } if (ep.Type == BrowserEventType.Generic) { GenericEvent ge = ep.Event as GenericEvent; if (ge != null) { if (ge.Type == GenericEventType.JSQuery) { if (OnJavaScriptQuery != null) { OnJavaScriptQuery(ge.JsQuery); } } } if (ge.Type == GenericEventType.PageLoaded) { if (OnPageLoaded != null) { OnPageLoaded(ge.NavigateUrl); } } } } } catch (Exception e) { Debug.Log("Error reading from socket,waiting for plugin server to start..."); } } }
private void EndDialog() { DialogEvent dialogEvent = lastEmitter.GetComponent <DialogEvent>(); if (dialogEvent != null) { dialogEvent.EndDialog(); } EnableControllers(); lastEmitter = null; this.gameObject.SetActive(false); }
public void StartDialogue(DialogEvent dialogEvent) { PlayerController.inMenu = true; MenuTop.enableMenu = false; Textboxes.Clear(); goTextbox.SetActive(true); foreach (DialogTextBox Textbox in dialogEvent.TextBoxes) { Textboxes.Enqueue(Textbox); } DisplayNextSentence(); }
void StartConversation() { DialogEvent dialogEvent = new DialogEvent(); dialogEvent.myDialogMessages = new List <DialogMessage>(); for (int i = 0; i < myConversation.Count; i++) { dialogEvent.myDialogMessages.Add(myConversation[i]); } EventManager.TriggerEvent(dialogEvent); }
private void btnSave_Click(object sender, System.Windows.RoutedEventArgs e) { if (this.tbDialog.Text != "") { var dialog = new DialogEvent() { EventName = "对话", Dialog = this.tbDialog.Text }; AddDialog(dialog); this.Close(); } else { MessageBox.Show("对话不能为空啊!", "..."); } }
public void LoadNextTunnel() { tunnelIndex++; if (tunnelIndex > events.GetLength(0)) { NeverEnding(); return; } Debug.Log("Loading Tunnel " + tunnelIndex); DialogEvent startDialog = events[tunnelIndex - 1]; Debug.Log(startDialog); this.dialogController.StartDialog(startDialog); }
public void OnStart() { subscription = BusManager.Add((evnt) => { if (evnt is DialogEvent) { DialogEvent ev = evnt as DialogEvent; if (ev.isCloseEvent) { Application.Current.Dispatcher.Invoke(() => { IsDisplayDialog = false; }); } } }); }
/// <summary> /// /// </summary> /// <param name="callback"></param> /// <returns></returns> public bool Popup(DialogEvent callback = null) { if (callback != null) { this.OnAccept = callback; } if (OnOpen != null) { OnOpen(this, null); } return(this.ShowDialog() == DialogResult.OK && this.FilePath != "" && (OnAccept == null || OnAccept(this))); }
// Update is called once per frame void Update() { myDialogIconGameObject.transform.position = transform.position + ((Vector3.up * 2) + new Vector3(0, GetComponent <Collider>().bounds.extents.y, 0)); if (myPlayerIsLocked == true) { return; } if (myLockCoolDown >= 0) { myLockCoolDown -= Time.deltaTime; return; } GameObject player = PollingStation.instance.GetGameObject(ePollingStationGameObjects.PLAYEROBJECT); if ((transform.position - player.transform.position).magnitude <= myRadius) { if (myDialogIconGameObject.activeSelf == false && myUseIcon == true) { myDialogIconGameObject.SetActive(true); } bool startConv = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Joystick1Button0); if (startConv == true) { //myDialogIconGameObject.SetActive(false); DialogEvent dialogEvent = new DialogEvent(); dialogEvent.myDialogMessages = new List <DialogMessage>(); for (int i = 0; i < myConversation.Count; i++) { dialogEvent.myDialogMessages.Add(myConversation[i]); } EventManager.TriggerEvent(dialogEvent); } } else { if (myDialogIconGameObject.activeSelf == true && myUseIcon == true) { myDialogIconGameObject.SetActive(false); } } }
/// <summary> /// Called before game start /// </summary> private void Awake() { ItemPickupEvent = new ItemEvent(); ItemPickupEvent.AddListener(Ping); ItemDroppedEvent = new ItemEvent(); ItemDroppedEvent.AddListener(Ping); DialogOpenEvent = new DialogEvent(); DialogOpenEvent.AddListener(Ping); DialogOptionSelectedEvent = new DialogOptionEvent(); DialogOptionSelectedEvent.AddListener(Ping); CharacterDeathEvent = new CharacterEvent(); CharacterDeathEvent.AddListener(Ping); InteractableActivatedEvent = new InteractableEvent(); }
private void _mainWorker_OnJSDialog(string message, string prompt, DialogEventType type) { DialogEvent msg = new DialogEvent() { DefaultPrompt = prompt, Message = message, Type = type, GenericType = BrowserEventType.Dialog }; EventPacket ep = new EventPacket { Event = msg, Type = BrowserEventType.Dialog }; _outCommServer.TrySend(ep, 100); }
public override void OnInspectorGUI() { SerializedProperty dEvent = serializedObject.FindProperty("_event"); EditorGUILayout.PropertyField(dEvent); SerializedProperty sprop = serializedObject.FindProperty("_onRaisedZero"); DialogEvent theEvent = (dEvent.objectReferenceValue as DialogEvent); if (theEvent != null) { switch ((dEvent.objectReferenceValue as DialogEvent).argumentCount) { case ArgumentCount.ZERO: sprop = serializedObject.FindProperty("_onRaisedZero"); break; case ArgumentCount.ONE: sprop = serializedObject.FindProperty("_onRaisedOne"); break; case ArgumentCount.TWO: sprop = serializedObject.FindProperty("_onRaisedTwo"); break; case ArgumentCount.THREE: sprop = serializedObject.FindProperty("_onRaisedThree"); break; case ArgumentCount.FOUR: sprop = serializedObject.FindProperty("_onRaisedFour"); break; case ArgumentCount.VARIABLE: sprop = serializedObject.FindProperty("_onRaisedVariable"); break; } EditorGUILayout.PropertyField(sprop); } serializedObject.ApplyModifiedProperties(); }
private bool load_dialog_from_file(string fileName) { try { string line; StreamReader theReader = new StreamReader(fileName, Encoding.Default); DialogEvent current_dialog_event = new DialogEvent(); using (theReader) { do { line = theReader.ReadLine(); if (line != null) { if (line.Contains("x-pos")) { string[] parts_of_line = line.Split(':'); float x_position = float.Parse(parts_of_line[1]); current_dialog_event.x_position = x_position; //Debug.Log("New Conversation at: "+x_position); } else if (line.Equals("") || line.Contains("***")) { list_of_dialog_events.Add(current_dialog_event); current_dialog_event = new DialogEvent(); //Debug.Log("Done Reading Event"); } else { current_dialog_event.messages.Add(line); //Debug.Log(line); } //Debug.Log(line); } } while (line != null); theReader.Close(); return(true); } } catch (Exception e) { Debug.LogError(e.Message); return(false); } }
public void SendDialogResponse(bool ok, string dinput) { if (Initialized) { DialogEvent de = new DialogEvent { GenericType = BrowserEventType.Dialog, success = ok, input = dinput }; EventPacket ep = new EventPacket { Event = de, Type = BrowserEventType.Dialog }; _outCommServer.TrySend(ep, 100); } }
public void SendDialogResponse(bool ok, string dinput) { if (Initialized) { DialogEvent de = new DialogEvent() { GenericType = MessageLibrary.BrowserEventType.Dialog, success = ok, input = dinput }; EventPacket ep = new EventPacket { Event = de, Type = MessageLibrary.BrowserEventType.Dialog }; _outCommServer.WriteMessage(ep); } }
/// <inheritdoc/> protected override async Task <bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken) { if (dc.Context.Activity.Type == ActivityTypes.Message) { // decide whether we want to allow interruption or not. // if we don't get a response from QnA which signifies we expected it, // then we allow interruption. var reply = dc.Context.Activity.Text; var dialogOptions = ObjectPath.GetPathValue <QnAMakerDialogOptions>(dc.ActiveDialog.State, Options); if (reply.Equals(dialogOptions.ResponseOptions.CardNoMatchText, StringComparison.OrdinalIgnoreCase)) { // it matches nomatch text, we like that. return(true); } var suggestedQuestions = dc.State.GetValue <List <string> >($"this.suggestedQuestions"); if (suggestedQuestions != null && suggestedQuestions.Any(question => string.Compare(question, reply.Trim(), StringComparison.OrdinalIgnoreCase) == 0)) { // it matches one of the suggested actions, we like that. return(true); } // Calling QnAMaker to get response. var qnaClient = await GetQnAMakerClientAsync(dc).ConfigureAwait(false); ResetOptions(dc, dialogOptions); var response = await qnaClient.GetAnswersRawAsync(dc.Context, dialogOptions.QnAMakerOptions).ConfigureAwait(false); // cache result so step doesn't have to do it again, this is a turn cache and we use hashcode so we don't conflict with any other qnamakerdialogs out there. dc.State.SetValue($"turn.qnaresult{this.GetHashCode()}", response); // disable interruption if we have answers. return(response.Answers.Any()); } // call base for default behavior. return(await OnPostBubbleEventAsync(dc, e, cancellationToken).ConfigureAwait(false)); }
public INIParser(Stream stream) : base(stream) { str = (BigStream)stream; //Console.WriteLine(str.Name); long filesize = str.Length; while (str.Position < filesize) { ParseLine(); string s = getString(); string name; switch (s) { case "#include": includeFile(getString()); break; case "#define": macros.Add(getString().ToUpper(), getStrings()); break; case "Armor": Armor ar = new Armor(); name = getString(); ParseObject(ar); INIManager.AddArmor(name, ar); break; case "AmbientStream": AmbientStream ast = new AmbientStream(); name = getString(); ParseObject(ast); INIManager.AddAmbientStream(name, ast); break; case "AudioEvent": AudioEvent e = new AudioEvent(); name = getString(); ParseObject(e); INIManager.AddAudioEvent(name, e); break; case "CommandButton": CommandButton cb = new CommandButton(); name = getString(); ParseObject(cb); INIManager.AddCommandButton(name, cb); break; case "DialogEvent": DialogEvent de = new DialogEvent(); name = getString(); ParseObject(de); INIManager.AddDialogEvent(name, de); break; case "FXList": FXList fl = new FXList(); name = getString(); ParseObject(fl); INIManager.AddFXList(name, fl); break; case "GameData": GameData data = new GameData(); ParseObject(data); INIManager.SetGameData(data); break; case "LoadSubsystem": LoadSubsystem ls = new LoadSubsystem(); name = getString(); ParseObject(ls); ls.LoadFiles(); break; case "MappedImage": MappedImage mi = new MappedImage(); name = getString(); ParseObject(mi); INIManager.AddMappedImage(name, mi); break; case "ModifierList": ModifierList ml = new ModifierList(); name = getString(); ParseObject(ml); INIManager.AddModifierList(name, ml); break; case "Multisound": Multisound ms = new Multisound(); name = getString(); ParseObject(ms); INIManager.AddMultisound(name, ms); break; case "MusicTrack": MusicTrack mt = new MusicTrack(); name = getString(); ParseObject(mt); INIManager.AddMusicTrack(name, mt); break; case "Object": INI.Object o = new INI.Object(); name = getString(); ParseObject(o); INIManager.AddObject(name, o); break; case "Science": Science sc = new Science(); name = getString(); ParseObject(sc); INIManager.AddScience(name, sc); break; case "StreamedSound": StreamedSound ss = new StreamedSound(); name = getString(); ParseObject(ss); INIManager.AddStreamedSound(name, ss); break; case "Upgrade": Upgrade u = new Upgrade(); name = getString(); ParseObject(u); INIManager.AddUpgrade(name, u); break; case "Weapon": Weapon w = new Weapon(); name = getString(); ParseObject(w); INIManager.AddWeapon(name, w); break; default: if (!objects.Contains(s)) { //PrintError("unhandled entry: " + s); objects.Add(s); } break; } } count++; }
public override void OnCreate() { base.OnCreate(); m_dialogText = GetChildComponent<AocTypewriterEffect>("DialogText"); m_head1Sprite = GetChildComponent<UISprite>("LeftHead"); m_head2Sprite = GetChildComponent<UISprite>("RightHead"); m_dialogBoardSprite = GetChildComponent<UISprite>("DialogBoard"); m_dialogEffectPlayer = m_dialogBoardSprite.GetComponent<UIEffectPlayer>(); m_backPic = GetChildComponent<UISprite>("Background"); m_itemBoard = GetChildComponent<UISprite>("ItemBoard"); m_clickSprite = GetChildComponent<UISprite>("ClickSprite"); m_pressReceiver = m_dialogBoardSprite.transform.GetComponent<PressReceiver>(); AddChildComponentMouseClick("SkipBtn", delegate() { EndDialog(); }); //解析DialogEvent配置文件 string eventContent = ResourceManager.Singleton.LoadTextFile("DialogEvent"); //解析Dialog配置文件//////////////////////////////////////////////////////////////////////// StringReader sr = new StringReader(eventContent); string line = sr.ReadLine(); while (line != null) { if (line.Contains("//")) { line = sr.ReadLine(); continue; } if (string.IsNullOrEmpty(line)) { line = sr.ReadLine(); continue; } string[] values = line.Split(new string[] { "\t", " " }, System.StringSplitOptions.RemoveEmptyEntries); if (values.Length > 0) { int curStageNum = System.Convert.ToInt32(values[0]); DialogTriggerPos triggerPos = (DialogTriggerPos)System.Convert.ToInt32(values[1]); DialogEvent data = new DialogEvent(); data.dialogGroupNum = System.Convert.ToInt32(values[2]); data.need3Star = (values[2] == "Y"); data.backPic = values[3]; data.triggerPos = triggerPos; m_dialogEventMap.Add(new KeyValuePair<int, DialogTriggerPos>(curStageNum, triggerPos), data); //添加对话数据 } line = sr.ReadLine(); } sr.Close(); string content = ResourceManager.Singleton.LoadTextFile("Dialog"); //解析Dialog配置文件//////////////////////////////////////////////////////////////////////// sr = new StringReader(content); line = sr.ReadLine(); int curDialogGroupNum = -1; List<DialogData> curDialogGroup = new List<DialogData>(); while (line != null) { if (line.Contains("//")) { line = sr.ReadLine(); continue; } if (string.IsNullOrEmpty(line)) { line = sr.ReadLine(); continue; } string[] values = line.Split(new string[] { "\t", " " }, System.StringSplitOptions.RemoveEmptyEntries); if (values.Length > 0) { int num = System.Convert.ToInt32(values[0]); if(curDialogGroupNum == -1) { curDialogGroupNum = num; m_dialogGroupMap.Add(curDialogGroupNum, curDialogGroup); } else if (num != curDialogGroupNum) //若数字变化了,新加一组对话 { curDialogGroup = new List<DialogData>(); //重新创建一个对话组数据 curDialogGroupNum = num; //更改当前在编的对话组数字 m_dialogGroupMap.Add(curDialogGroupNum, curDialogGroup); } DialogData data = new DialogData(); data.activeLeftHead = (values[1] == "L"); data.headLeft = values[2]; data.headRight = values[3]; data.itemSprite = values[4]; data.speed = System.Convert.ToInt32(values[5]); data.content = values[6]; data.content.Replace('_', ' '); //下划线替换成空格 curDialogGroup.Add(data); //添加对话数据 } line = sr.ReadLine(); } sr.Close(); }
public static bool TryGetDialogEvent(string name, out DialogEvent de) { if (dialogEvents.ContainsKey(name)) { de = dialogEvents[name]; return true; } de = null; return false; }