// edit here when dialogue data changes public void LoadRuntimeSaveData() { m_dialogueData = new Dictionary <int, DialogueData>(); m_characterData = new Dictionary <string, CharacterComponent>(); // load dialogue data (runtime) for (int dialogue_index = 0; dialogue_index < m_runtimeBuiltData.Count; ++dialogue_index) { DialogueData dialogue = m_runtimeBuiltData[dialogue_index]; LoadCharacterEmotions(dialogue); // loading objects for events dialogue.eventObjects = new List <GameObject>(); for (int i = 0; i < dialogue.eventObjectNames.Count; ++i) { dialogue.eventObjects.Add(FindGameObject(dialogue.eventObjectNames[i])); } m_dialogueData.Add(dialogue.node_id, dialogue); } for (int gameob_index = 0; gameob_index < m_charactersInvolvedStrings.Count; ++gameob_index) { string go_name = m_charactersInvolvedStrings[gameob_index]; m_characterData.Add(go_name, FindGameObject(go_name).GetComponent <CharacterComponent>()); } }
void Update() { if (interactable) { if (Input.GetKeyUp("e")) { if (modalPanel.modalPanelObject.activeInHierarchy) { modalPanel.ClosePanel(); GameInformation.PlayerControllable = true; interactions++; GameInformation.AddInteraction(this.gameObject.name, interactions); SendMessage("ResetFacing"); } else { GameInformation.PlayerControllable = false; SendMessage("FaceThePlayer"); ModalPanelDetails modalPanelDetails = new ModalPanelDetails(); string temp = DialogueData.LoadFromXML(dialogID); modalPanelDetails.text = temp.Replace("PlayerName", GameInformation.PlayerName); modalPanelDetails.title = this.gameObject.name; modalPanelDetails.iconImage = spriteRenderer.sprite; modalPanel.NewChoice(modalPanelDetails); } } } }
private void DisplayDialogueData(DialogueData dialogueData) { this._messageTextField.text = dialogueData._SentenceText; this._collocutorNameTextField.text = dialogueData._Collocutor._ProfileName; this._collocutorIconImageField.sprite = dialogueData._Collocutor._ProfileIcon; }
private int CheckDialogueConditions(DialogueData dialogue) { bool condition = true; // checking items if (dialogue.itemsToCheck.Count > 0) { condition &= CheckItemsInInventory(dialogue); } // checking quests that need to be aquired if (dialogue.questsRequired.Count > 0) { condition &= CheckRequiredQuests(dialogue); } // checking quests that need to be completed if (dialogue.questsCompleted.Count > 0) { condition &= CheckCompletedQuests(dialogue); } int conditionIndex = condition ? 1 : 0; // it didnt allow me to cast bool to int /shrug return(dialogue.m_nextDialogueData[conditionIndex]); }
private void DisplayEventNode(DialogueData data) { Label("Events to trigger at this node", EditorStyles.boldLabel); BeginHorizontal(); if (Button("Add Dialogue Event")) { data.eventObjects.Add(null); data.eventFunctions.Add(null); data.eventObjectNames.Add(null); } if (Button("Remove Dialogue Event")) { int index = (data.eventObjects.Count - 1 <= 0) ? 0 : data.eventObjects.Count - 1; if (data.eventObjects.Count > 0) { data.eventObjects.RemoveAt(index); data.eventFunctions.RemoveAt(index); data.eventObjectNames.RemoveAt(index); } } EndHorizontal(); for (int i = 0; i < data.eventObjects.Count; ++i) { BeginHorizontal(); data.eventObjects[i] = EditorGUILayout.ObjectField(data.eventObjects[i], typeof(GameObject), true) as GameObject; data.eventFunctions[i] = TextArea(data.eventFunctions[i], Width(m_nodePropertiesRect.width * 0.5f)); data.eventObjectNames[i] = data.eventObjects[i].name; EndHorizontal(); } }
public override bool Load() { Dialogue targetData = target as Dialogue; var client = new DatabaseClient("", ""); string error = string.Empty; var db = client.GetDatabase(targetData.SheetName, ref error); var table = db.GetTable <DialogueData>(targetData.WorksheetName) ?? db.CreateTable <DialogueData>(targetData.WorksheetName); List <DialogueData> myDataList = new List <DialogueData>(); var all = table.FindAll(); foreach (var elem in all) { DialogueData data = new DialogueData(); data = Cloner.DeepCopy <DialogueData>(elem.Element); myDataList.Add(data); } targetData.dataArray = myDataList.ToArray(); EditorUtility.SetDirty(targetData); AssetDatabase.SaveAssets(); return(true); }
public DialogueWordsData(DialogueWords words, DialogueData parent) { model = words; this.parent = parent; if (model.Options.Count > 0 && parent) { int index = parent.model.Words.IndexOf(words); for (int i = 0; i < model.Options.Count; i++) { int indexBack = index; WordsOption option = model.Options[i]; if (words.NeedToChusCorrectOption) { if (model.IndexOfCorrectOption == i) { indexBack++; } } else { indexBack = option.IndexToGoBack > 0 && option.OptionType != WordsOptionType.SubmitAndGet && option.OptionType != WordsOptionType.OnlyGet && parent.model.StoryDialogue && (option.OptionType == WordsOptionType.BranchDialogue || option.OptionType == WordsOptionType.BranchWords) && !option.GoBack ? option.IndexToGoBack : indexBack; } WordsOptionData od = new WordsOptionData(option, this, indexBack); optionDatas.Add(od); } } }
// Use this for initialization void Start() { matureDialogue = new DialogueData(new string[] { "Gegner: ", "Du: ", "Gegner: ", "Du; " }, new string[] { "Na lange nicht gesehen", "Kenne ich dich. Warum greifst du mich nicht an. Du bist doch ein gegner?", "Wießt du nicht mehr. 1988, San Franzisko, in der Disko", "Ich glaube ich war zu betrunken. Ich haue jetzt ab lieber ab. Tschau", "Tschüss. Hoffentlich sehehn wir uns baldf wieder" }); depressantDialogue = new DialogueData(new string[] { "Gegner: ", "Du: ", "Du: ", "Genger: ", "Du: " }, new string[] { "Hey, hey, hey. Fahr' mal 'n bissl' runta. Chill ma. Willste ne Kippe.", "ARggeregr #!äe#.,::,y,c+#+*ow ......", "Warum eigentlich nicht?. Ein bissl Frieden kann nie Schaden", "Yo erwitere deinenen Horizont", "Hier nicht!" }); aggressiveDialogue = new DialogueData(new string[] { "Gegner: ", "Du: ", "Gegner: ", "Du: ", "Gegner: ", "Du: ", "Du: " }, new string[] { "Der böse Spieler zum Angriff", "Jawohl zum Angriff", "Mit gebrüll [Hier Gebrüll einsetzen]", "Jawohl mit Gebrüll", "Fallen wir über ihn her", "Jawohl falllen wir über eu....", "Ich bin ja aller. ich habe keine Freunde. Warum habe ich eigentlich keine Freunde. Egal zum Angriff!!!" }); }
private void Awake() { Instance = this; textUIManager = new TextUIManager(gameObject.GetComponentInChildren <GroupTextUI>()); string[] tempData = TextAssetTool.ReadTextAssetData("Text/sampleDialogue"); foreach (string data in tempData) { string[] seperatedData = data.Split('-'); foreach (string datak in seperatedData) { Debug.Log(datak); } if (seperatedData.Length == 3) { DialogueData dialogueData = new DialogueData(seperatedData[0], TextAssetTool.ConvertNumberStringToInt(seperatedData[1], ':'), seperatedData[2].Split(';')); AddEventTextToDatabase(dialogueData.GetDialogueKey(), dialogueData); Debug.LogWarning(string.Format("The key {0} is added", dialogueData.GetDialogueKey())); } else { Debug.LogError("GO F**K URSELF"); } } Debug.LogWarning("TextDataManager initialized"); }
public DialogueStepData GetDialogueStepDataByCharcterID(int char_id) { DialogueStepData defaultStepData = null; var enumerator = m_Dialogues.Values.GetEnumerator(); while (enumerator.MoveNext()) { DialogueData dialogueData = enumerator.Current; int len = dialogueData.Steps.Length; for (int i = 0; i < len; i++) { var step = dialogueData.Steps[i]; if (step.Icon == char_id.ToString()) { return(step); } else if (step.Layout == 1) { defaultStepData = step; } } } EB.Debug.LogWarning("GetDialogueStepDataByCharcterID Fail so use other DialogueStepData char_id:{0}", char_id); return(defaultStepData); }
private void LoadDialogue(DialogueData dialogueData) { Debug.Log($"Loading script {dialogueData.name}..."); _dialogueData = dialogueData; DialogueView.LoadDialogue(_dialogueData); }
private void VisitNode(DialogueData data, int childCount, TreeList <IDialogueContext> tree, List <IDialogueContext> contexts) { IDialogueContext context = data.GetDialogueContext(); contexts.Add(context); tree.Insert(new TreeNode <IDialogueContext>(context, childCount)); }
private void GenerateNodeFromContainer(DialogueData dialogueContainer) { foreach (var node in dialogueContainer.Nodes) { if (node.isEntryPoint) { var entryPoint = Nodes.Find(n => n.isEntryPoint); entryPoint.Guid = node.Guid; (entryPoint.outputContainer.Q <Port>() as DialoguePort).Next = node.Next; continue; } if (node.isChoiceNode) { ChoiceNode temp = graph.CreateChoiceNode("Choice Node"); temp.Guid = node.Guid; foreach (var choice in node.Choices) { graph.AddChoicePort(temp as ChoiceNode, choice.Question, choice.Next); } temp.SetPosition(new Rect(JsonUtility.FromJson <Vector2>(node.JsonData), graph.nodeSize)); graph.AddElement(temp); } else { DialogueNode temp = graph.CreateDialogueNode("Dialogue Node", node.Text, node.Character, node.Next);; temp.Guid = node.Guid; temp.SetPosition(new Rect(JsonUtility.FromJson <Vector2>(node.JsonData), graph.nodeSize)); graph.AddElement(temp); } } }
private void DrawEventNode(Node node, GUIStyle style) { Rect nodeRect = new Rect(node.m_position.x, node.m_position.y, node.m_dimension.x, node.m_dimension.y); // draw plugs on specific node DrawPlug(node.m_inputPlug, nodeRect, m_inputPlugStyle, 1, 1); int plug_count = 1; Plug delete_plug = null; foreach (KeyValuePair <int, Plug> output_plug in node.m_outputPlugs) { if (delete_plug == null) { delete_plug = DrawPlug(output_plug.Value, nodeRect, m_outputPlugStyle, plug_count, node.m_outputPlugs.Count); } else { DrawPlug(output_plug.Value, nodeRect, m_outputPlugStyle, plug_count, node.m_outputPlugs.Count); } ++plug_count; } if (delete_plug != null) { m_nodeGraphModel.RemoveOutputPlugFromNode(delete_plug.m_plugId, delete_plug.m_nodeId); } // drawing the node itself with the contents in it DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node.m_id); if ((data.questsToAdd.Count > 0) || (data.questsToComplete.Count > 0) || (data.itemsToGive.Count > 0)) { style = m_actionNodeStyle; } GUI.Box(nodeRect, "", style); float padding = 7f; Rect nodeContentRect = new Rect(node.m_position.x + padding, node.m_position.y + padding, node.m_dimension.x - (2 * padding), node.m_dimension.y - (2 * padding)); BeginArea(nodeContentRect); Label("Event", EditorStyles.boldLabel); if (data != null) { List <string> errors = m_nodeGraphModel.GetErrorMesssages(node.m_id); if (errors.Count > 0) { GUIStyle error_label = new GUIStyle(); error_label.fontStyle = FontStyle.Bold; error_label.normal.textColor = new Color(171f / 255f, 19f / 255f, 0); Label("Errors!!", error_label); } for (int i = 0; i < data.eventFunctions.Count; ++i) { Label(data.eventObjectNames[i] + ": " + data.eventFunctions[i]); } } EndArea(); }
public void SelectDialogue(DialogueData newDialogueData) { dialogueData = newDialogueData; choiceButton = false; StartConversation(); dialogueSystem.ResetChoices(); }
/// <summary> /// loads the dialog aggravation score information /// from a JSON file and into a dictionary data structure /// </summary> /// <param name="filename">The name of the JSON file</param> public void loadDialogueText(string filename) { if (dialogueText == null) { dialogueText = new Dictionary <string, float>(); } else { dialogueText.Clear(); } string filepath = Path.Combine(Application.streamingAssetsPath, filename); if (File.Exists(filepath)) { string jsonData = File.ReadAllText(filepath); DialogueData data = JsonUtility.FromJson <DialogueData>(jsonData); for (int i = 0; i < data.items.Length; ++i) { dialogueText.Add(data.items[i].key, data.items[i].value); } //Debug.Log("Json dialogue loaded"); } }
private void Execute(bool isPaused, string buttonKey, Action <bool> handler) { var hasAppToggled = appState.Pause(isPaused); controller.IsPaused = isPaused; if (!hasAppToggled) { return; } if (isPaused) { var data = new DialogueData { Message = localization.Get(TextKeys.PAUSE_TEXT), BackgroundAlpha = 1f }; if (!string.IsNullOrEmpty(buttonKey)) { var buttonText = localization.Get(buttonKey); data.AddAction(buttonText, handler); } onShowDialogue.Dispatch(data); } else { onHideDialogue.Dispatch(); } }
public int AddConditionalNode(Vector2 position) // returns node id { Node newNode = new Node(); newNode.m_id = newNode.GetHashCode(); newNode.m_position = position; newNode.isConditionalNode = true; newNode.m_inputPlug = new Plug(); newNode.m_inputPlug.m_nodeId = newNode.m_id; newNode.m_inputPlug.m_plugId = newNode.m_inputPlug.GetHashCode(); newNode.m_inputPlug.m_plugType = PlugType.kIn; newNode.m_outputPlugs = new Dictionary <int, Plug>(); m_nodes.Add(newNode.m_id, newNode); DialogueData dialogue = ScriptableObject.CreateInstance <DialogueData>(); dialogue.node_id = newNode.m_id; dialogue.isConditionalBranching = true; m_dialogueData.Add(newNode.m_id, dialogue); int plug_id_0 = AddOutputPlugToNode(newNode.m_id); newNode.m_outputPlugs[plug_id_0].m_plugIndex = 0; int plug_id_1 = AddOutputPlugToNode(newNode.m_id); newNode.m_outputPlugs[plug_id_1].m_plugIndex = 1; return(newNode.m_id); }
public int DuplicateNode(int node_id_to_duplicate) { Node node_to_duplicate = GetNodeFromID(node_id_to_duplicate); Node duplicate = new Node(); duplicate.isConditionalNode = node_to_duplicate.isConditionalNode; duplicate.m_id = duplicate.GetHashCode(); duplicate.m_position = node_to_duplicate.m_position + new Vector2(20, 20); duplicate.m_inputPlug = new Plug(); duplicate.m_inputPlug.m_nodeId = duplicate.m_id; duplicate.m_inputPlug.m_plugId = duplicate.m_inputPlug.GetHashCode(); m_nodes.Add(duplicate.m_id, duplicate); //dialogue data DialogueData dialogue = GetDataFromNodeID(node_to_duplicate.m_id); DialogueData dataCopy = dialogue.Copy(); dataCopy.node_id = duplicate.m_id; m_dialogueData.Add(duplicate.m_id, dataCopy); duplicate.m_outputPlugs = new Dictionary <int, Plug>(); for (int i = 0; i < node_to_duplicate.m_outputPlugs.Count; ++i) { AddOutputPlugToNode(duplicate.m_id); } return(duplicate.m_id); }
private void AdjustDialogueData(DialogueData data) { var convoBlock = data.conversation; if (convoBlock.Count <= 0) { convoBlock.Add(new DialogueData.DialogueBlock()); } if (convoBlock[convoBlock.Count - 1].dialogue != string.Empty) { var temp = new DialogueData.DialogueBlock(); temp.character = convoBlock[convoBlock.Count - 1].character; convoBlock.Add(temp); } if (convoBlock[0].dialogue.Length >= 10) { if (!convoBlock[0].dialogue.Substring(0, 10).Equals(dialogueStartPauseTxt)) { var temp = new DialogueData.DialogueBlock(); temp.character = convoBlock[0].character; temp.dialogue = dialogueStartPauseTxt + convoBlock[0]; convoBlock[0] = temp; } } else { var temp = new DialogueData.DialogueBlock(); temp.character = convoBlock[0].character; temp.dialogue = dialogueStartPauseTxt + convoBlock[0]; convoBlock[0] = temp; } }
public void ActivateDialogue(DialogueData dialogueData) { Debug.Log("Activated" + dialogueData); ActivateUI(); animatedText.text = string.Empty; raycast.enabled = true; inDialogue = true; canExit = false; dialogueFinished = false; if (timesDialogueActivated >= levelDialogue.Length) { print("End of dialogue reached. Repeating last dialogue..."); timesDialogueActivated = levelDialogue.Length - 1; } currentDialogue = levelDialogue[timesDialogueActivated]; if (dialogueData != null) { currentDialogue = dialogueData; } AdjustDialogueData(currentDialogue); dialogueUI.transform.DOKill(); Sequence s = DOTween.Sequence().Append(dialogueUI.GetComponent <RectTransform>().DOAnchorPos(new Vector2(0, 20), 1f).SetEase(Ease.OutCubic)); s.target = dialogueUI.transform; animatedText.ReadText(currentDialogue.conversation[dialogueIndex].dialogue); charScript.SetCharacterValsInUI(currentDialogue.conversation[dialogueIndex].character); }
public void runMenuResult(int nextDialogueIndex, DialogueData.MenuResultInstruct resultInstruct, int data, string saveLocation) { switch (resultInstruct) { case DialogueData.MenuResultInstruct.NONE: break; case DialogueData.MenuResultInstruct.SaveToPlayerPrefs_Int: DialogueData.setSavedInt(saveLocation, data); break; default: break; } if (nextDialogueIndex != -1) { //If a menu option is selected then use the Dialogue Index attached to the //menu option to start a new Speech. dialogueManager.startDialogueOutput(nextDialogueIndex); } //Make menu inactive only after the next speech has had a chance to start. dialogueMenuActive = false; }
void ReferenceAcquire() { player = GameObject.FindGameObjectWithTag("Player"); dialogueCanvasObj = GameObject.FindGameObjectWithTag("DialogueCanvas"); tmpName = dialogueCanvasObj.transform.GetChild(3).GetComponent <TextMeshProUGUI>(); tmpText = dialogueCanvasObj.transform.GetChild(5).GetComponent <TextMeshProUGUI>(); threedotsCG = dialogueCanvasObj.transform.GetChild(6).GetComponent <CanvasGroup>(); tmpThreeDots = dialogueCanvasObj.transform.GetChild(6).transform.GetChild(0).GetComponent <TextMeshProUGUI>(); choicesCG = dialogueCanvasObj.transform.GetChild(7).GetComponent <CanvasGroup>(); charSpriteCG = dialogueCanvasObj.transform.GetChild(1).GetComponent <CanvasGroup>(); charImage = dialogueCanvasObj.transform.GetChild(1).transform.GetChild(0).GetComponent <Image>(); var obj = dialogueCanvasObj.transform.GetChild(7).gameObject; choiceBG2 = obj.transform.GetChild(0).gameObject; choiceBG3 = obj.transform.GetChild(1).gameObject; choiceBG4 = obj.transform.GetChild(2).gameObject; button0 = obj.transform.GetChild(3).GetComponent <Button>(); tmp_b0 = obj.transform.GetChild(3).transform.GetChild(0).GetComponent <TextMeshProUGUI>(); button1 = obj.transform.GetChild(4).GetComponent <Button>(); tmp_b1 = obj.transform.GetChild(4).transform.GetChild(0).GetComponent <TextMeshProUGUI>(); button2 = obj.transform.GetChild(5).GetComponent <Button>(); tmp_b2 = obj.transform.GetChild(5).transform.GetChild(0).GetComponent <TextMeshProUGUI>(); button3 = obj.transform.GetChild(6).GetComponent <Button>(); tmp_b3 = obj.transform.GetChild(6).transform.GetChild(0).GetComponent <TextMeshProUGUI>(); dialogueCG = dialogueCanvasObj.GetComponent <CanvasGroup>(); data = GetComponent <DialogueData>(); }
static private void Start(DialogueData interactionContainer) { EventManager.instance.Raise(new DialogueEvent(DialogueEvent.EventType.start)); UIStack.Instance.ExitStack(true); _interaction.ClearCharacterInfo(); if (interactionContainer.isDuringGameplay) { _interaction.PreStart(ref interactionContainer); _interaction.Start(null); } else { // Show the interaction screen CreateDialogueHUD(); DialogueHUDLogic dialogueHUDLogic = _interactionHud.GetComponent <DialogueHUDLogic>(); if (null != dialogueHUDLogic && !dialogueHUDLogic.IsOnUIStack()) // don't need to add it to the stack if it's already on there { UIStack.Instance.EnStack(dialogueHUDLogic); } EnterParticipantsToDialogue(); } if (null != onInteractionStart) { onInteractionStart(interactionContainer); } }
// edit here when dialogue data changes public void LoadRuntimeSaveData() { m_dialogueData = new Dictionary <int, DialogueData>(); string[] data = m_dialogueRuntimeSaveData.Split("`".ToCharArray()); int data_index = 0; if (data.Length <= 1) { return; } // load dialogue data (runtime) int dialogue_count = int.Parse(data[data_index++]); for (int dialogue_index = 0; dialogue_index < dialogue_count; ++dialogue_index) { DialogueData dialogue = new DialogueData(); dialogue.node_id = int.Parse(data[data_index++]); dialogue.characterName = data[data_index++]; dialogue.dialogueText = data[data_index++]; dialogue.previewDialogueText = data[data_index++]; dialogue.m_isBranching = bool.Parse(data[data_index++]); dialogue.m_nextDialogueData = new List <int>(); int branchingIDs_count = int.Parse(data[data_index++]); for (int i = 0; i < branchingIDs_count; ++i) { dialogue.m_nextDialogueData.Add(int.Parse(data[data_index++])); } m_dialogueData.Add(dialogue.node_id, dialogue); } m_startIndex = int.Parse(data[data_index++]); }
// edit here when dialogue data changes private void SaveToRuntimeDialogueData() { m_dialogueAsset.m_dialogueRuntimeSaveData = ""; int start_node_index = 0; m_dialogueAsset.m_dialogueRuntimeSaveData += m_dialogueAsset.m_dialogueData.Count + "`"; foreach (KeyValuePair <int, DialogueData> pair in m_dialogueAsset.m_dialogueData) { DialogueData dialogue = pair.Value; if (dialogue.m_isStartNode) { start_node_index = dialogue.node_id; } m_dialogueAsset.m_dialogueRuntimeSaveData += dialogue.node_id + "`"; m_dialogueAsset.m_dialogueRuntimeSaveData += dialogue.characterName + "`"; m_dialogueAsset.m_dialogueRuntimeSaveData += dialogue.dialogueText + "`"; m_dialogueAsset.m_dialogueRuntimeSaveData += dialogue.previewDialogueText + "`"; m_dialogueAsset.m_dialogueRuntimeSaveData += dialogue.m_isBranching + "`"; m_dialogueAsset.m_dialogueRuntimeSaveData += dialogue.m_nextDialogueData.Count + "`"; foreach (int ID in dialogue.m_nextDialogueData) { m_dialogueAsset.m_dialogueRuntimeSaveData += ID + "`"; } } m_dialogueAsset.m_dialogueRuntimeSaveData += start_node_index + "`"; }
public bool StartDialogue(string DialogueKey, Sprite inNPCSprite) { this.diagDisplay.SetActive(true); this.playerPortrait.SetActive(true); this.NPCPortrait.SetActive(true); this._NPCImage.sprite = inNPCSprite; CurrentDialogue = dialogueLibrary.FetchDialogueData(DialogueKey); if (CurrentDialogue != null) { GameManager.Instance.ChangeGameState(GameStateId.Dialogue); //string s = ""; //for (int i = 0; i < CurrentDialogue.Lines.Count; i++) // { // s += CurrentDialogue.Lines[i].line; // //s += ","; // } //s = s.Replace("/", "\n"); this.diagDisplay.GetComponentInChildren <UnityEngine.UI.Text>().text = CurrentDialogue.Lines[0].line; //Testing!! //Debug.Log(CurrentDialogue.Lines[0].line); //Debug.Log(CurrentDialogue.Lines[0].Actor); //Debug.Log(CurrentDialogue.Lines[1].line); //Debug.Log(CurrentDialogue.Lines[1].Actor); //Debug.Log(CurrentDialogue.Lines[2].line); //Debug.Log(CurrentDialogue.Lines[2].Actor); return(true); } return(false); }
/// <summary> /// Set the dialogue that this character will talk about. /// </summary> public void SetDialogue(string dialogueResourceName) { TextAsset data = Resources.Load <TextAsset>($"Dialogues/{dialogueResourceName}"); curDialogue = JsonUtility.FromJson <DialogueData>(data.ToString()); spokenMainDialogue = false; }
public void StartConversation(DialogueData data) { NamePanel.SetActive(true); DialoguePanel.SetActive(true); SetActiveDialogue(data); CycleDialogue(); }
public static void OpenAsset(DialogueData dialogueData) { DialogueEditorWindow window = GetWindow <DialogueEditorWindow>(); window.LoadDialogue(dialogueData); window.Show(); }
public void PlayDialogue() { this.gameObject.SetActive(true); this.GetComponent<CanvasGroup>().alpha = 1; dialogueData = DataManager.Instance.GetDialogueDataSet ().GetDialogueData(dialogID); currentTextCount = 0; OnNextDialogue (); }
// Use this for initialization public ServerDialogues() { functionName = "Dialogue"; // Database tables name tableName = "dialogue"; functionTitle = "Dialogue Configuration"; loadButtonLabel = "Load Dialogues"; notLoadedText = "No Dialogue loaded."; // Init dataRegister = new Dictionary<int, DialogueData> (); editingDisplay = new DialogueData (); originalDisplay = new DialogueData (); }
static void LoadData() { for (int i = 1; i < ExcelData.Rows.Count;) { DialogueData data = new DialogueData(); dialogueDataSet.dataSet.Add(data); data.dialogueID = ExcelLoader.GetIntCell(ExcelData, i, 0); SentenceData sentence; sentence.tellerName = ExcelLoader.GetCell(ExcelData, i, 1); sentence.avatarID = ExcelLoader.GetIntCell(ExcelData, i, 2); sentence.content = ExcelLoader.GetCell(ExcelData, i, 3); data.sentences.Add(sentence); while(++i < ExcelData.Rows.Count && ExcelLoader.GetIntCell(ExcelData, i, 0, true, 0) == 0) { sentence.tellerName = ExcelLoader.GetCell(ExcelData, i, 1); sentence.avatarID = ExcelLoader.GetIntCell(ExcelData, i, 2); sentence.content = ExcelLoader.GetCell(ExcelData, i, 3); data.sentences.Add(sentence); } } }
// Draw the loaded list public override void DrawLoaded(Rect box) { // Setup the layout Rect pos = box; pos.x += ImagePack.innerMargin; pos.y += ImagePack.innerMargin; pos.width -= ImagePack.innerMargin; pos.height = ImagePack.fieldHeight; if (dataRegister.Count <= 0) { pos.y += ImagePack.fieldHeight; ImagePack.DrawLabel (pos.x, pos.y, "You must create a Dialogue before edit it."); return; } // Draw the content database info ImagePack.DrawLabel (pos.x, pos.y, "Dialogue Configuration"); if (newItemCreated) { newItemCreated = false; LoadSelectList(); newSelectedDisplay = displayKeys.Count - 1; } // Draw data Editor if (newSelectedDisplay != selectedDisplay) { selectedDisplay = newSelectedDisplay; int displayKey = displayKeys [selectedDisplay]; editingDisplay = dataRegister [displayKey]; originalDisplay = editingDisplay.Clone(); requestedDisplay = selectedDisplay; } //if (!displayList.showList) { pos.y += ImagePack.fieldHeight; pos.x -= ImagePack.innerMargin; pos.y -= ImagePack.innerMargin; pos.width += ImagePack.innerMargin; DrawEditor (pos, false); pos.y -= ImagePack.fieldHeight; //pos.x += ImagePack.innerMargin; pos.y += ImagePack.innerMargin; pos.width -= ImagePack.innerMargin; //} if (state != State.Loaded) { // Draw combobox pos.width /= 2; pos.x += pos.width; newSelectedDisplay = ImagePack.DrawCombobox (pos, "", selectedDisplay, displayList); //requestedDisplay = newSelectedDisplay; pos.x -= pos.width; pos.width *= 2; } if(requestedDisplay != -1 && requestedDisplay != selectedDisplay) newSelectedDisplay = requestedDisplay; }
// Edit or Create public override void DrawEditor(Rect box, bool newItem) { if (!linkedTablesLoaded) { LoadDialogueList(); LoadQuestList(); LoadFactionList(); actionOptions = ServerOptionChoices.LoadAtavismChoiceOptions("Dialogue Action", false); linkedTablesLoaded = true; } // Setup the layout Rect pos = box; pos.x += ImagePack.innerMargin; pos.y += ImagePack.innerMargin; pos.width -= ImagePack.innerMargin; pos.height = ImagePack.fieldHeight; // Draw the content database info if (newItem) { ImagePack.DrawLabel (pos.x, pos.y, "Create a new Dialogue"); pos.y += ImagePack.fieldHeight; } // Draw a button to go back to the previous dialogue if (editingDisplay.previousDialogueID != -1) { DialogueData dd = (DialogueData) dataRegister[editingDisplay.previousDialogueID]; pos.width = pos.width * 2; if (ImagePack.DrawButton (pos.x, pos.y, "Go back to " + dd.id + "." + dd.name)) { //editingDisplay = GetDialogue(editingDisplay.previousDialogueID); requestedDisplay = GetPositionOfPreviousDialogue(editingDisplay.previousDialogueID); state = State.Edit; return; } pos.y += ImagePack.fieldHeight; pos.width = pos.width / 2; } editingDisplay.name = ImagePack.DrawField (pos, "Name:", editingDisplay.name, 0.5f); pos.y += ImagePack.fieldHeight; pos.width = pos.width / 2; editingDisplay.openingDialogue = ImagePack.DrawToggleBox(pos, "Opening Dialogue:", editingDisplay.openingDialogue); pos.x += pos.width; editingDisplay.repeatable = ImagePack.DrawToggleBox(pos, "Repeatable:", editingDisplay.repeatable); pos.x -= pos.width; pos.y += ImagePack.fieldHeight; int dialogueID = GetPositionOfDialogue(editingDisplay.prereqDialogue); dialogueID = ImagePack.DrawSelector (pos, "Prereq Dialogue:", dialogueID, dialogueList); editingDisplay.prereqDialogue = dialogueIds[dialogueID]; pos.x += pos.width; int questID = GetPositionOfFaction(editingDisplay.prereqQuest); questID = ImagePack.DrawSelector (pos, "Prereq Quest:", questID, questList); editingDisplay.prereqFaction = factionIds[questID]; pos.x -= pos.width; pos.y += ImagePack.fieldHeight; int factionID = GetPositionOfFaction(editingDisplay.prereqFaction); factionID = ImagePack.DrawSelector (pos, "Prereq Faction:", factionID, factionList); editingDisplay.prereqFaction = factionIds[factionID]; pos.x += pos.width; int factionStance = GetPositionOfStance(editingDisplay.prereqFactionStance); factionStance = ImagePack.DrawSelector (pos, "Prereq Stance:", factionStance, FactionData.stanceOptions); editingDisplay.prereqFactionStance = FactionData.stanceValues[factionStance]; pos.x -= pos.width; pos.y += ImagePack.fieldHeight; pos.width = pos.width * 2; editingDisplay.text = ImagePack.DrawField (pos, "Text:", editingDisplay.text, 0.75f, 60); pos.y += 3f * ImagePack.fieldHeight; // Only show actions if it has been saved due to complications of moving forward/back if (!newItem) { if (editingDisplay.entries.Count == 0) { editingDisplay.entries.Add(new DialogueActionEntry("", actionOptions[0], -1)); } for (int i = 0; i < editingDisplay.maxEntries; i++) { if (editingDisplay.entries.Count > i) { ImagePack.DrawLabel (pos.x, pos.y, "Action " + (i+1)); pos.y += ImagePack.fieldHeight; editingDisplay.entries[i].text = ImagePack.DrawField (pos, "Text:", editingDisplay.entries[i].text, 1.4f); pos.width = pos.width / 2; pos.y += ImagePack.fieldHeight; editingDisplay.entries[i].action = ImagePack.DrawSelector (pos, "Action Type:", editingDisplay.entries[i].action, actionOptions); pos.x += pos.width; if (editingDisplay.entries[i].action == "Dialogue") { // Treat dialogues differently as the developer will be able to click to move onto the next one if (editingDisplay.entries[i].actionID == -1) { // No dialogue yet, click button to create a new one if (ImagePack.DrawButton (pos.x, pos.y, "Create Dialogue")) { // Save dialogue first then lets go create a new one UpdateEntry (); int previousDialogueID = editingDisplay.id; CreateNewData(); editingDisplay.previousDialogueID = previousDialogueID; editingDisplay.previousActionPosition = i; editingDisplay.openingDialogue = false; this.state = State.New; return; } } else { // Show dialogue with option to move forward if (ImagePack.DrawButton (pos.x, pos.y, "Edit Dialogue")) { // Save dialogue first then lets go create a new one UpdateEntry (); dataRegister[editingDisplay.entries[i].actionID].previousDialogueID = editingDisplay.id; requestedDisplay = GetPositionOfDialogue(editingDisplay.entries[i].actionID); state = State.Edit; } } } else { editingDisplay.entries[i].actionID = ImagePack.DrawField (pos, "ActionID:", editingDisplay.entries[i].actionID); } pos.x -= pos.width; pos.y += ImagePack.fieldHeight; pos.width = pos.width * 2; } } if (editingDisplay.entries.Count < editingDisplay.maxEntries) { if (ImagePack.DrawButton (pos.x, pos.y, "Add Action")) { DialogueActionEntry actionEntry = new DialogueActionEntry("", actionOptions[0], -1); editingDisplay.entries.Add(actionEntry); } } } //pos.width = pos.width * 2; // Save data pos.x -= ImagePack.innerMargin; pos.y += 1.4f * ImagePack.fieldHeight; pos.width /=3; if (ImagePack.DrawButton (pos.x, pos.y, "Save Data")) { if (newItem) InsertEntry (); else UpdateEntry (); state = State.Loaded; } // Delete data if (!newItem) { pos.x += pos.width; if (ImagePack.DrawButton (pos.x, pos.y, "Delete Data")) { DeleteEntry (); newSelectedDisplay = 0; state = State.Loaded; } } // Cancel editing pos.x += pos.width; if (ImagePack.DrawButton (pos.x, pos.y, "Cancel")) { editingDisplay = originalDisplay.Clone(); if (newItem) state = State.New; else state = State.Loaded; } if (resultTimeout != -1 && resultTimeout > Time.realtimeSinceStartup) { pos.y += ImagePack.fieldHeight; ImagePack.DrawText(pos, result); } if (!newItem) EnableScrollBar(pos.y - box.y + ImagePack.fieldHeight + 28); else EnableScrollBar(pos.y - box.y + ImagePack.fieldHeight); }
public override void CreateNewData() { editingDisplay = new DialogueData (); originalDisplay = new DialogueData (); selectedDisplay = -1; }
// Insert new entries into the table void InsertEntry() { NewResult("Inserting..."); // Setup the update query string query = "INSERT INTO " + tableName; query += " (" + editingDisplay.FieldList ("", ", ") + ") "; query += "VALUES "; query += " (" + editingDisplay.FieldList ("?", ", ") + ") "; int mobID = -1; // Setup the register data List<Register> update = new List<Register> (); foreach (string field in editingDisplay.fields.Keys) { update.Add (editingDisplay.fieldToRegister (field)); } // Update the database mobID = DatabasePack.Insert (DatabasePack.contentDatabasePrefix, query, update); // If the insert succeeded - update other fields if (mobID != -1) { // Update online table to avoid access the database again editingDisplay.id = mobID; editingDisplay.isLoaded = true; //Debug.Log("ID:" + mobID + "ID2:" + editingDisplay.id); dataRegister.Add (editingDisplay.id, editingDisplay); displayKeys.Add (editingDisplay.id); newItemCreated = true; // If this has a previous id - update the actionID field for that dialogue if (editingDisplay.previousDialogueID != -1) { int tempSelectedDisplay = selectedDisplay; selectedDisplay = GetPositionOfPreviousDialogue(editingDisplay.previousDialogueID); int actionPos = editingDisplay.previousActionPosition; editingDisplay = dataRegister [editingDisplay.previousDialogueID]; editingDisplay.entries[actionPos].actionID = mobID; UpdateEntry(); editingDisplay = originalDisplay; selectedDisplay = tempSelectedDisplay; } NewResult("New entry inserted"); } else { NewResult("Error occurred, please check the Console"); } }
// Load Database Data public override void Load() { if (!dataLoaded) { // Clean old data dataRegister.Clear (); displayKeys.Clear (); // Read all entries from the table string query = "SELECT * FROM " + tableName; // If there is a row, clear it. if (rows != null) rows.Clear (); // Load data rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query); //Debug.Log("#Rows:"+rows.Count); // Read all the data if ((rows!=null) && (rows.Count > 0)) { foreach (Dictionary<string,string> data in rows) { //foreach(string key in data.Keys) // Debug.Log("Name[" + key + "]:" + data[key]); //return; DialogueData display = new DialogueData (); display.id = int.Parse (data ["id"]); display.name = data ["name"]; display.openingDialogue = bool.Parse (data ["openingDialogue"]); display.repeatable = bool.Parse (data ["repeatable"]); display.prereqDialogue = int.Parse (data ["prereqDialogue"]); display.prereqQuest = int.Parse (data ["prereqQuest"]); display.prereqFaction = int.Parse (data ["prereqFaction"]); display.prereqFactionStance = int.Parse (data ["prereqFactionStance"]); display.reactionAutoStart = bool.Parse (data ["reactionAutoStart"]); display.text = data ["text"]; for (int i = 1; i <= display.maxEntries; i++) { string text = data ["option" + i + "text"]; if (text != null && text.Length != 0) { string action = data ["option" + i + "action"]; int actionID = int.Parse (data ["option" + i + "actionID"]); DialogueActionEntry entry = new DialogueActionEntry(text, action, actionID); display.entries.Add(entry); } } display.isLoaded = true; //Debug.Log("Name:" + display.name + "=[" + display.id + "]"); dataRegister.Add (display.id, display); displayKeys.Add (display.id); } LoadSelectList(); } dataLoaded = true; } }