public void setTreeNode(TreeNode treeNode) { m_treeNode = treeNode; TalkNode talkNode = (TalkNode)m_treeNode.Tag; guiQuantityTxt.Text = talkNode.id; }
private void OnSceneGUI() { m_monoTalkNode = target as MonoTalkNode; m_talkNode = m_monoTalkNode.m_node; UpdateNodeTree(); }
public static Npc CreateNPC(Vector3 pos, Vector2 rot, Vector3 scale, RoleType type = RoleType.ClassD, ItemType itemHeld = ItemType.None, string name = "(EMPTY)", string root_node = "default_node.yml") { GameObject obj = UnityEngine.Object.Instantiate( NetworkManager.singleton.spawnPrefabs.FirstOrDefault(p => p.gameObject.name == "Player")); CharacterClassManager ccm = obj.GetComponent <CharacterClassManager>(); pos = new Vector3(pos.x, pos.y - (1f - scale.y) * Plugin.Instance.Config.NpcSizePositionMultiplier, pos.z); obj.transform.localScale = scale; obj.transform.position = pos; QueryProcessor processor = obj.GetComponent <QueryProcessor>(); processor.NetworkPlayerId = QueryProcessor._idIterator++; processor._ipAddress = "127.0.0.WAN"; ccm.CurClass = type; obj.GetComponent <PlayerStats>().SetHPAmount(ccm.Classes.SafeGet(type).maxHP); obj.GetComponent <NicknameSync>().Network_myNickSync = name; ServerRoles roles = obj.GetComponent <ServerRoles>(); roles.MyText = "NPC"; roles.MyColor = "red"; NetworkServer.Spawn(obj); PlayerManager.AddPlayer(obj); //I'm not sure if I need this Player ply_obj = new Player(obj); Player.Dictionary.Add(obj, ply_obj); Player.IdsCache.Add(ply_obj.Id, ply_obj); Npc npcc = obj.AddComponent <Npc>(); npcc.ItemHeld = itemHeld; npcc.RootNode = TalkNode.FromFile(Path.Combine(Config.NPCs_nodes_path, root_node)); npcc.NPCPlayer.ReferenceHub.transform.localScale = scale; npcc.NPCPlayer.SessionVariables.Add("IsNPC", true); npcc.AttachedCoroutines.Add(Timing.CallDelayed(0.3f, () => { npcc.NPCPlayer.ReferenceHub.playerMovementSync.OverridePosition(pos, 0, true); npcc.NPCPlayer.Rotations = rot; })); npcc.AttachedCoroutines.Add(Timing.CallDelayed(0.4f, () => { npcc.FireEvent(new NPCOnCreatedEvent(npcc, null)); })); return(npcc); }
private void onTextChanged(object sender, EventArgs e) { if (m_treeNode != null) { TalkNode talkNode = (TalkNode)m_treeNode.Tag; talkNode.id = guiQuantityTxt.Text; m_treeNode.Text = talkNode.ToString(); } }
public void setTreeNode(TreeNode treeNode) { m_treeNode = treeNode; TalkNode talkNode = (TalkNode)m_treeNode.Tag; String id = talkNode.id; String text = talkNode.text; guiGotoTxt.Text = id; guiReplyTxt.Text = text; }
static void WriteSelectionTalkNode(Transform monoDialogEvent) { TalkNode talkNode = monoDialogEvent.gameObject.GetComponent <MonoTalkNode> ().m_node; newWriterTalkNode = new TalkNode(talkNode.m_name); newWriterTalkNode.m_background = talkNode.m_background; newWriterTalkNode.m_tachie = talkNode.m_tachie; newWriterTalkNode.m_name = talkNode.m_name; newWriterTalkNode.m_dialogType = DialogNode.NodeType.Talk; newWriterSelectionNode.m_selection.Add(talkNode.m_name, newWriterTalkNode); }
static void LoadTalk() { Clear(); //检查的时候会自增,因此一开始先减去自增的数值 m_currentContent = -1; TalkNode m_node = (TalkNode)m_dialogEvent.m_nodeList [m_currentNode]; m_content = m_node.m_talkContents; GetSpriteAsset(m_node.m_background, m_background); GetSpriteAsset(m_node.m_tachie, m_tachie); }
private IEnumerator <float> HandleAnswerCoroutine(Player p, string answer) { if (TalkingStates.ContainsKey(p)) { TalkNode cur_node = TalkingStates[p]; if (int.TryParse(answer, out int node)) { if (cur_node.NextNodes.TryGet(node, out TalkNode new_node)) { TalkingStates[p] = new_node; IsActionLocked = true; bool end = new_node.Send(Name, p); foreach (NodeAction action in new_node.Actions.Keys) { try { action.Process(this, p, new_node.Actions[action]); } catch (Exception e) { Log.Error($"Exception during processing action {action.Name}: {e}"); } float dur = 0; try { dur = float.Parse(new_node.Actions[action]["next_action_delay"].Replace('.', ',')); } catch (Exception) { } yield return(Timing.WaitForSeconds(dur)); } IsActionLocked = false; if (end) { TalkingStates.Remove(p); p.SendConsoleMessage(Name + $" {Plugin.Instance.Config.TranslationTalkEnd}", "yellow"); IsLocked = false; } } else { p.SendConsoleMessage(Plugin.Instance.Config.TranslationInvalidAnswer, "red"); } } else { p.SendConsoleMessage(Plugin.Instance.Config.TranslationIncorrectFormat, "red"); } } else { p.SendConsoleMessage(Plugin.Instance.Config.TranslationNotTalking, "red"); } }
public void setTreeNode(TreeNode treeNode) { m_treeNode = treeNode; TalkNode talkNode = (TalkNode)m_treeNode.Tag; guiValueTxt.Text = talkNode.id; TalkTreeFlag talkTreeFlag; if (Enumeration.TryParse <TalkTreeFlag>(talkNode.text, out talkTreeFlag)) { guiTypeCbo.SelectedItem = talkTreeFlag; } else { guiTypeCbo.SelectedItem = TalkTreeFlag.More; } }
private void onValueSelected(object sender, EventArgs e) { if (sender.GetType().Equals(guiValueCbo.GetType())) { CodeValue codeValue = (CodeValue)guiValueCbo.SelectedItem; guiValueTxt.Text = codeValue.code.ToString(); } else { if (m_treeNode != null) { TalkNode talkNode = (TalkNode)m_treeNode.Tag; talkNode.id = guiValueTxt.Text; m_treeNode.Text = talkNode.ToString(); } } }
private void onTypeSelected(object sender, EventArgs e) { guiValueTxt.Visible = false; guiValueCbo.Visible = false; TalkTreeFlag talkTreeFlag = (TalkTreeFlag)guiTypeCbo.SelectedItem; switch (talkTreeFlag) { case TalkTreeFlag.Mission_Goto_Stage: guiValueCbo.Items.Clear(); if (m_parentForm.getStages() != null && m_parentForm.getStages().Count != 0) { guiValueCbo.Items.AddRange(m_parentForm.getStages().ToArray()); //guiValueCbo.Items.Add(CodeValue.Formatted(-2, "Repeatable mission")); guiValueCbo.Items.Add(new CodeValue(-2, "Mission completed & is repeatable")); if (guiValueTxt.Text.Length == 0) { guiValueCbo.SelectedIndex = 0; } else { guiValueCbo.SelectedItem = new CodeValue(Int32.Parse(guiValueTxt.Text)); } } guiValueCbo.Visible = true; break; default: guiValueTxt.Text = ""; break; } if (m_treeNode != null) { TalkNode talkNode = (TalkNode)m_treeNode.Tag; talkNode.text = ((int)talkTreeFlag).ToString(); talkNode.id = guiValueTxt.Text; m_treeNode.Text = talkNode.ToString(); } }
static public void PlaySelection() { UIManager.Instance().ClosePanel <UISelectPanel> (); Clear(); //检查的时候会自增,因此一开始先减去自增的数值 m_currentContent = -1; SelectionNode m_selectNode = (SelectionNode)m_dialogEvent.m_nodeList [m_currentNode]; Debug.Log("SelectedOption : " + m_selected); TalkNode m_node = m_selectNode.m_selection [m_selected]; m_content = m_node.m_talkContents; GetSpriteAsset(m_node.m_background, m_background); GetSpriteAsset(m_node.m_tachie, m_tachie); GameObject.Find("RigidBodyFPSController").GetComponent <UnityStandardAssets.Characters.FirstPerson.RigidbodyFirstPersonController> ().mouseLook.SetCursorLock(false); UIManager.Instance().ShowPanel <UIDialogPanel> (); GameObject.Find("UIDialogPanel").GetComponent <UIDialogPanel> ().InitDialog(); }
public void Init(TalkNode node) { m_node = node; }
//保存为xml public static void SaveXMLEvent() { DialogWriter dialogWriter = ProduceWriter(); //保存路径 path = Application.dataPath + "/OutputXml/" + dialogWriter.GetType() + ".xml"; FileInfo fi = new FileInfo(path); if (fi.Exists) { //fi.MoveTo ("./backup"); fi.Delete(); } List <DialogEvent> dialogEventLsit = dialogWriter.m_dialogEventList; XmlDocument doc = new XmlDocument(); XmlElement dialogWriterElem = doc.CreateElement("DialogWriter"); for (int i = 0; i < dialogEventLsit.Count; i++) { XmlElement eve = doc.CreateElement("Event"); DialogEvent dialogEvent = dialogEventLsit [i]; eve.SetAttribute("Name", dialogEvent.m_name); eve.SetAttribute("EvenOrder", dialogEvent.m_eventOrder.ToString()); for (int j = 0; j < dialogEvent.m_nodeList.Count; j++) { //判断是否为talk节点 if (dialogEvent.m_nodeList [j].m_dialogType == DialogNode.NodeType.Talk) { XmlElement node = doc.CreateElement("TalkNode"); TalkNode talkNode = (TalkNode)dialogEvent.m_nodeList [j]; node.SetAttribute("Name", talkNode.m_name); node.SetAttribute("NodeType", talkNode.m_dialogType.ToString()); for (int k = 0; k < talkNode.m_background.Count; k++) { //node.SetAttribute ("Background"+k, ); XmlElement background = doc.CreateElement("Background"); background.SetAttribute("Name", talkNode.m_background [k]); node.AppendChild(background); } for (int k = 0; k < talkNode.m_tachie.Count; k++) { XmlElement tachie = doc.CreateElement("Tachie"); tachie.SetAttribute("Name", talkNode.m_tachie [k]); node.AppendChild(tachie); //node.SetAttribute ("Tachie"+k, talkNode.m_tachie [k]); } for (int k = 0; k < talkNode.m_talkContents.Count; k++) { XmlElement content = doc.CreateElement("TalkContent"); TalkContent talkContent = talkNode.m_talkContents [k]; content.SetAttribute("Background", talkContent.m_backGround.ToString()); content.SetAttribute("Tachie", talkContent.m_tachie.ToString()); content.SetAttribute("Name", talkContent.m_name); content.SetAttribute("Content", talkContent.m_content); node.AppendChild(content); } eve.AppendChild(node); } else { XmlElement node = doc.CreateElement("SelectionNode"); SelectionNode selectionNode = (SelectionNode)dialogEvent.m_nodeList [j]; node.SetAttribute("Name", selectionNode.m_name); node.SetAttribute("NodeType", selectionNode.m_dialogType.ToString()); //分为两个select节点 foreach (string s in selectionNode.m_selection.Keys) { XmlElement select = doc.CreateElement("Select"); select.SetAttribute("Select", s); XmlElement talk = doc.CreateElement("TalkNode"); TalkNode talkNode = selectionNode.m_selection [s]; talk.SetAttribute("Name", talkNode.m_name); talk.SetAttribute("NodeType", talkNode.m_dialogType.ToString()); for (int k = 0; k < talkNode.m_background.Count; k++) { //node.SetAttribute ("Background"+k, ); XmlElement background = doc.CreateElement("Background"); background.SetAttribute("Name", talkNode.m_background [k]); talk.AppendChild(background); } for (int k = 0; k < talkNode.m_tachie.Count; k++) { XmlElement tachie = doc.CreateElement("Tachie"); tachie.SetAttribute("Name", talkNode.m_tachie [k]); talk.AppendChild(tachie); //node.SetAttribute ("Tachie"+k, talkNode.m_tachie [k]); } for (int k = 0; k < talkNode.m_talkContents.Count; k++) { XmlElement content = doc.CreateElement("TalkContent"); TalkContent talkContent = talkNode.m_talkContents [k]; content.SetAttribute("Background", talkContent.m_backGround.ToString()); content.SetAttribute("Tachie", talkContent.m_tachie.ToString()); content.SetAttribute("Name", talkContent.m_name); content.SetAttribute("Content", talkContent.m_content); talk.AppendChild(content); } select.AppendChild(talk); node.AppendChild(select); } eve.AppendChild(node); } } dialogWriterElem.AppendChild(eve); } doc.AppendChild(dialogWriterElem); doc.Save(path); }
//加载xm文件 public static DialogWriter LoadXMLEvent() { bool m_isTalkNode = true; if (Application.platform == RuntimePlatform.OSXPlayer) { Console.Log("sfdbdfsdgsfdgsfdds"); path = Application.dataPath + "/Resources/Data/StreamingAssets/dialogWriter.xml"; Console.Log(path); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { path = Application.dataPath + "/Raw/"; } else if (Application.platform == RuntimePlatform.Android) { path = "jar:file//" + Application.dataPath + "!/assets/"; } //} else if(Application.platform == RuntimePlatform.){ // path = Application.dataPath + "/StreamingAssets/"; //} XmlReader reader = new XmlTextReader(path); //提前设置的变量,用于保存读取文件时的各个子节点 DialogWriter newDialogWriter = null; DialogEvent newDialogEvent = null; TalkNode newTalkNode = null; SelectionNode newSelectionNode = null; TalkContent newTalkContent = null; string newSelect = ""; newDialogWriter = new DialogWriter(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.LocalName == "DialogWriter") { if (newDialogWriter != null) { } //不会执行 } else if (reader.LocalName == "Event") { newDialogEvent = new DialogEvent(""); for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Name") { newDialogEvent.m_name = reader.Value; } else if (reader.Name == "EventOrder") { newDialogEvent.m_eventOrder = int.Parse(reader.Value); } } if (newDialogWriter != null) { newDialogWriter.m_dialogEventList.Add(newDialogEvent); } } else if (reader.LocalName == "TalkNode") { newTalkNode = new TalkNode(""); for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Name") { newTalkNode.m_name = reader.Value; } else if (reader.Name == "NodeType") { newTalkNode.m_dialogType = (DialogNode.NodeType)System.Enum.Parse(typeof(DialogNode.NodeType), reader.Value); } } //不是选择分支下的对话节点 if (m_isTalkNode) { if (newDialogEvent != null) { newDialogEvent.m_nodeList.Add(newTalkNode); } } else { if (newSelectionNode != null) { newSelectionNode.m_selection [newSelect] = newTalkNode; //每次都重新设为true m_isTalkNode = true; } } } else if (reader.LocalName == "Background") { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Name") { newTalkNode.m_background.Add(reader.Value); } } } else if (reader.LocalName == "Tachie") { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Name") { newTalkNode.m_tachie.Add(reader.Value); } } } else if (reader.LocalName == "TalkContent") { newTalkContent = new TalkContent(); for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Background") { newTalkContent.m_backGround = int.Parse(reader.Value); } else if (reader.Name == "Tachie") { newTalkContent.m_tachie = int.Parse(reader.Value); } else if (reader.Name == "Name") { newTalkContent.m_name = reader.Value; } else if (reader.Name == "Content") { newTalkContent.m_content = reader.Value; } } if (newTalkNode != null) { newTalkNode.m_talkContents.Add(newTalkContent); } } else if (reader.LocalName == "SelectionNode") { newSelectionNode = new SelectionNode(""); for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Name") { newSelectionNode.m_name = reader.Value; } } if (newDialogEvent != null) { newDialogEvent.m_nodeList.Add(newSelectionNode); } } else if (reader.LocalName == "Select") { m_isTalkNode = false; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name == "Select") { //把数值临时保存 newSelect = reader.Value; newSelectionNode.m_selection.Add(reader.Value, new TalkNode("")); } } } } } return(newDialogWriter); }
IEnumerator TalkToCustumer(int indexTalk) { showTalkButtons=false; activeNode=nodes[indexTalk]; Debug.Log("Shopkeeper: "+activeNode.text); mySource.clip=activeNode.audioText; mySource.Play(); if (mySource.clip!=null) yield return new WaitForSeconds (activeNode.audioText.length); Debug.Log("Customer: "+activeNode.response); mySource.clip=activeNode.audioResponse; mySource.Play(); if (mySource.clip!=null) yield return new WaitForSeconds (activeNode.audioResponse.length); showTalkButtons=true; GenerateTalkVariations(); }
public void SetRunner(TalkNode newRunner) { runner = newRunner; defaultFont = runner.menuManager.dialogueBit.text.font; defaultColor = choiceBits[0].bitRoot.GetComponent<Selectable>().colors.normalColor; }