//examplePlayer.cs calls this one to move forward in the conversation public void CallNext() { //Let's not go forward if text is currently being animated, but let's speed it up. if (animatingText) { animatingText = false; return; } if (!dialoguePaused) //Only if { //We check for current extraData before moving forward to do special actions //ExtraDataLookUp returns true if an action requires to skip VIDE_Data.Next() //It will be true when we receive an item if (ExtraVariablesLookUp(VIDE_Data.nodeData, true)) { return; } VIDE_Data.Next(); //We call the next node and populate nodeData with new data return; } //This will just disable the item popup if it is enabled if (itemPopUp.activeSelf) { dialoguePaused = false; itemPopUp.SetActive(false); } }
void Awake() { instance = this; TextAsset[] files = Resources.LoadAll <TextAsset>("Dialogues"); List <string> names = new List <string>(); for (int i = 0; i < files.Length; i++) { names.Add(files[i].name); } names.Sort(); for (int i = 0; i < names.Count; i++) { string ttag = ""; if (Resources.Load("Dialogues/" + names[i]) == null) { break; } Dictionary <string, object> dict = SerializeHelper.ReadFromFile(names[i]) as Dictionary <string, object>; if (dict.ContainsKey("loadTag")) { ttag = (string)dict["loadTag"]; } diags.Add(new Diags(names[i], ttag)); } //Debug.Log("Found: " + diags.Count.ToString() + " dialogues"); }
//Check to see if there's extraData and if so, we do stuff bool ExtraVariablesLookUp(VIDE_Data.NodeData data, bool PreCall) { //Don't conduct extra variable actions if we are waiting on a paused action if (data.pausedAction) { return(false); } if (!data.currentIsPlayer) //For player nodes { //Check for extra variables //This one finds a key named "item" which has the value of the item thats gonna be given //If there's an 'item' key, then we will assume there's also an 'itemLine' key and use it if (PreCall) //Checks that happen right before calling the next node { if (data.extraVars.ContainsKey("item") && !data.dirty) { if (data.npcCommentIndex == (int)data.extraVars["itemLine"]) { if (data.extraVars.ContainsKey("item++")) //If we have this key, we use it to increment the value of 'item' by 'item++' { Dictionary <string, object> newVars = data.extraVars; //Clone the current extraVars content int newItem = (int)newVars["item"]; //Retrieve the value we want to change newItem += (int)data.extraVars["item++"]; //Change it as we desire newVars["item"] = newItem; //Set it back VIDE_Data.UpdateExtraVariables(25, newVars); //Send newVars through UpdateExtraVariable method } //If it's CrazyCap, check his stock before continuing //If out of stock, change override start node if (VIDE_Data.assigned.alias == "CrazyCap") { if ((int)data.extraVars["item"] + 1 >= example_Items.Count) { VIDE_Data.assigned.overrideStartNode = 28; } } if (!example_ItemInventory.Contains(example_Items[(int)data.extraVars["item"]])) { GiveItem((int)data.extraVars["item"]); return(true); } } } } if (data.extraVars.ContainsKey("nameLookUp")) { nameLookUp(data); } } else //for NPC nodes { //Nothing here yet ¯\_(ツ)_/¯ } return(false); }
//Unsuscribe from everything, disable UI, and end dialogue void EndDialogue(VIDE_Data.NodeData data) { VIDE_Data.OnActionNode -= ActionHandler; VIDE_Data.OnNodeChange -= NodeChangeAction; VIDE_Data.OnEnd -= EndDialogue; uiContainer.SetActive(false); VIDE_Data.EndDialogue(); }
//Here I'm assigning the variable a new component of its required type void Start() { dialogue = gameObject.AddComponent <VIDE_Data>(); //Automatically adding the VIDE_Data component dialogue.OnActionNode += ActionHandler; //Subscribe to listen to triggered actions dialogue.OnLoaded += OnLoadedAction; //Subscribe dialogue.LoadDialogues(); //Load all dialogues to memory so that we dont spend time doing so later //Remember you can also manually add the VIDE_Data script as a component in the Inspector, //then drag&drop it on your 'dialogue' variable slot }
void Awake() { if (_instance) { Debug.LogError("Should not be 2 conversation ui managers in scene"); } _instance = this; _currentDialogue = gameObject.AddComponent <VIDE_Data>(); _currentDialogue.LoadDialogues(); }
public void Begin(VIDE_Assign diagToLoad) { inConversation = true; aiDialogue.text = ""; playerDialogue.text = ""; VIDE_Data.OnActionNode += ActionHandler; VIDE_Data.OnNodeChange += NodeChangeAction; VIDE_Data.OnEnd += EndDialogue; //SpecialStartNodeOverrides(diagToLoad); //This one checks for special cases when overrideStartNode could change right before starting a conversation VIDE_Data.BeginDialogue(diagToLoad); //Begins conversation, will call the first OnNodeChange uiContainer.SetActive(true); }
void Start() { coolDownTimer = coolDown; positionIni = Mask.transform.position; position = Mask.transform.position; gameObject.AddComponent <VIDE_Data>(); VIDE_Data.LoadDialogues(); //Load all dialogues to memory so that we dont spend time doing so later VIDE_Data.BeginDialogue(GetComponent <VIDE_Assign>()); Photo = gameObject.GetComponentInChildren <CapturePhotoIntro>(true); npcText = gameObject.GetComponentInChildren <Text>(true); action = true; etape = 0; npcText.text = "Bonjour"; etatMask = 0; }
//This begins the conversation (Called by examplePlayer script) public void Begin(VIDE_Assign diagToLoad) { //Let's clean the NPC text variables npcText.text = ""; npcName.text = ""; //First step is to call BeginDialogue, passing the required VIDE_Assign component //This will store the first Node data in VIDE_Data.nodeData //But before we do so, let's subscribe to certain events that will allow us to easily //Handle the node-changes VIDE_Data.OnActionNode += ActionHandler; VIDE_Data.OnNodeChange += NodeChangeAction; VIDE_Data.OnEnd += EndDialogue; SpecialStartNodeOverrides(diagToLoad); //This one checks for special cases when overrideStartNode could change right before starting a conversation VIDE_Data.BeginDialogue(diagToLoad); //Begins conversation, will call the first OnNodeChange uiContainer.SetActive(true); }
void OnGUI() { if (VIDE_Data.isLoaded) { var data = VIDE_Data.nodeData; //Quick reference if (data.currentIsPlayer) // If it's a player node, let's show all of the available options as buttons { for (int i = 0; i < data.playerComments.Length; i++) { if (GUILayout.Button(data.playerComments[i])) //When pressed, set the selected option and call Next() { data.selectedOption = i; VIDE_Data.Next(); } } } else //if it's a NPC node, Let's show the comment and add a button to continue { GUILayout.Label(data.npcComment[data.npcCommentIndex]); if (GUILayout.Button(">")) { VIDE_Data.Next(); } } if (data.isEnd) // If it's the end, let's just call EndDialogue { VIDE_Data.EndDialogue(); } } else // Add a button to begin conversation if it isn't started yet { if (GUILayout.Button("Start Convo")) { VIDE_Data.BeginDialogue(GetComponent <VIDE_Assign>()); //We've attached a DialogueAssign to this same gameobject, so we just call the component } } }
void Start() { dialogue = gameObject.AddComponent <VIDE_Data>(); }
void OnGUI() { GUILayout.BeginArea(new Rect(1000, 100, 200, 200)); if (VIDE_Data.isLoaded) { var data = VIDE_Data.nodeData; //Quick reference if (data.currentIsPlayer) // If it's a player node, let's show all of the available options as buttons { for (int i = 0; i < data.playerComments.Length; i++) { /* string debug = etape.ToString(); * timer.timerText.text = debug; * * if (etape == 1) * { * timer.timerText.color = Color.yellow; * } * else * { * timer.timerText.color = Color.black; * } */ // Choisis dans la liste des émotions celle qui sera choisis, ici ça se traduit avec un bouton du nom de l'émotion if (GUILayout.Button(data.playerComments[i])) //When pressed, set the selected option and call Next() { data.selectedOption = i; // selectionne la valeur du bouton et l'intégre dans la variable data Debug.Log("i =" + i); Photo.TakePhoto(); //Prend une photo // Lance la fonction choixVideo du script Jouervideo. VIDE_Data.Next(); // passe au texte suivant etape++; action = true; // CoolDown.CoolDownActive(); } } // Choix du dialogue en appuyant sur une touche if (Input.GetKeyDown(KeyCode.Keypad1)) { Debug.Log("data =" + data.selectedOption); Photo.TakePhoto(); } if (Input.GetKeyDown(KeyCode.Keypad2)) { data.selectedOption = 2; //Choix 2 Debug.Log("data =" + data.selectedOption); VIDE_Data.Next(); } } else //if it's a NPC node, Let's show the comment and add a button to continue { if (action == true) // on ne teste qu'une fois l'émotion { Debug.Log("Valeur action" + action); Debug.Log("ExtraVar" + data.extraVars.ContainsKey("Peur")); //Emotion Peur if (data.extraVars.ContainsKey("Peur")) //Si l'emotion choisi est la peur. { EmotionTest = "Peur"; Dictionary <string, object> newVars = data.extraVars; //Clone the current extraVars content newItem = (int)newVars["Peur"]; //Retrieve the value we want to change Debug.Log("Valeur NewItem avant incrément" + newItem); // newItem += 2; //Change it as we desire // Debug.Log("Valeur NewItem" + newItem); // newVars["Peur"] = newItem; //Set it back // VIDE_Data.UpdateExtraVariables(2, newVars); //Send newVars through UpdateExtraVariable method } //Emotion Colere if (data.extraVars.ContainsKey("Colere") && action == true) //Si l'emotion choisi est la Colere. { EmotionTest = "Colere"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Colere"]; Video.ChoixVideo(); action = false; } //Emotion Joie if (data.extraVars.ContainsKey("Joie")) { EmotionTest = "Joie"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Joie"]; action = false; } //Emotion Tristesse if (data.extraVars.ContainsKey("Tristesse")) { EmotionTest = "Tristesse"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Tristesse"]; action = false; } //Emotion Tristesse if (data.extraVars.ContainsKey("Tristesse")) { EmotionTest = "Tristesse"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Tristesse"]; action = false; } //Emotion Dégout if (data.extraVars.ContainsKey("Degout")) { EmotionTest = "Degout"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Degout"]; action = false; } //Emotion Surprise if (data.extraVars.ContainsKey("Surprise")) { EmotionTest = "Surprise"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Surprise"]; action = false; } //Emotion Neutre if (data.extraVars.ContainsKey("Neutre")) { EmotionTest = "Neutre"; Dictionary <string, object> newVars = data.extraVars; newItem = (int)newVars["Neutre"]; action = false; } } // on ajout un bouton pour pouvoir passer à la suite GUILayout.Label(data.npcComment[data.npcCommentIndex]); Debug.Log("Valeur" + data.npcComment[data.npcCommentIndex]); if (GUILayout.Button(">")) { VIDE_Data.Next(); } if (CoolDown.Next == true) { VIDE_Data.Next(); CoolDown.Next = false; } // On ajoute un timer pour lancer la suite } if (data.isEnd) // If it's the end, let's just call EndDialogue { VIDE_Data.EndDialogue(); } } else // Add a button to begin conversation if it isn't started yet { if (GUILayout.Button("Start Convo")) { VIDE_Data.BeginDialogue(GetComponent <VIDE_Assign>()); //We've attached a DialogueAssign to this same gameobject, so we just call the component } } GUILayout.EndArea(); }
public void ChoixEmotion(string put2) { Debug.Log("Emotion à envoyer =" + put2); if (VIDE_Data.isLoaded) { Debug.Log("Vide data is loaded"); var data = VIDE_Data.nodeData; //Quick reference // if (data.currentIsPlayer) // If it's a player node, let's show all of the available options as buttons // { Debug.Log("Current is player"); if (put2 == "anger ") { data.selectedOption = 2; Debug.Log("Emotion change next =" + put2); VIDE_Data.Next(); } if (put2 == "contempt ") { data.selectedOption = 0; Debug.Log("Emotion change next =" + put2); VIDE_Data.Next(); } if (put2 == "disgust ") { data.selectedOption = 5; Debug.Log("Emotion change next =" + put2); VIDE_Data.Next(); } if (put2 == "fear ") { data.selectedOption = 1; Debug.Log("Emotion =" + put2); VIDE_Data.Next(); } if (put2 == "happiness ") { data.selectedOption = 0; Debug.Log("Emotion =" + put2); VIDE_Data.Next(); } if (put2 == "neutral ") { data.selectedOption = 4; Debug.Log("Emotion change next =" + put2); VIDE_Data.Next(); } if (put2 == "sadness ") { data.selectedOption = 3; Debug.Log("Emotion =" + put2); VIDE_Data.Next(); } if (put2 == "surprise ") { data.selectedOption = 6; Debug.Log("Emotion =" + put2); VIDE_Data.Next(); } /* else * { * data.selectedOption = 4; * Debug.Log("Emotion Else =" + put2+"test"); * VIDE_Data.Next(); * * } */ // } } }
void Update() { if (position.x < 1000 && etatMask == 1) { // Mask.transform.position = new Vector2(100, 0); position.x = position.x + 2; this.transform.position = position; // Debug.Log("Postion en X après changement" + position.x); // Debug.Log("Postion en X et Y après changement" + position); Mask.transform.position = position; } else { etatMask = 0; Debug.Log("Etat mask" + etatMask); } // Debug.Log("Postion en X Final" + position.x); // Debug.Log("Postion en X et Y Final " + position); if (VIDE_Data.isLoaded) //Only if { var data = VIDE_Data.nodeData; if (data.currentIsPlayer) // If it's a player node, let's show all of the available options as buttons { Debug.Log("C'est le joueur"); ordinateur = false; if (Timeractive == 0) { Photo.TakePhoto(); Debug.Log("Photo prise"); Timeractive = 3; } } else { Debug.Log("C'est le comput"); ordinateur = true; npcText.text = data.npcComment[data.npcCommentIndex]; if (Timeractive == 0) { Timeractive = 1; } if (Timeractive == 3) { coolDownTimer = coolDown; Timeractive = 1; } } if (data.isEnd) // If it's the end, let's just call EndDialogue { VIDE_Data.EndDialogue(); Debug.Log("Chargement de la scène suivante"); SceneManager.LoadScene("MiroirEmpathique", LoadSceneMode.Single); } if (Input.GetKey("escape")) { Application.Quit(); } } // CoolDown party if (coolDownTimer > 0 && Timeractive == 1) // Lorsque Le timer est supérieur à 0 et actif { coolDownTimer -= Time.deltaTime; // Debug.Log("CoolDown" + coolDownTimer); } if (coolDownTimer < 0 && Timeractive == 1 && ordinateur == true) { coolDownTimer = coolDown; VIDE_Data.Next(); Debug.Log("Timer finis ordi,Next joueur"); } if (coolDownTimer < 0 && Timeractive == 1 && ordinateur == false) { Debug.Log("Timer finis du joueur"); Timeractive = 0; } if (coolDownTimer > 1.5 && coolDownTimer < 1.9 && Timeractive == 1) { etatMask = 1; Debug.Log("Lancer le mask" + etatMask); } if (coolDownTimer > 2.5 && Timeractive == 1) { position = positionIni; Debug.Log("Reposition du mask" + position); } // if (GetComponent<VIDE_Assign>().overrideStartNode == 40) if (GetComponent <VIDE_Assign>().overrideStartNode == 9) { Debug.Log("Chargement de la scène suivante"); SceneManager.LoadScene("MiroirEmpathique", LoadSceneMode.Single); } }
public override void OnInspectorGUI() { d = (VIDE_Data)target; GUIStyle b = new GUIStyle(GUI.skin.GetStyle("Label")); b.fontStyle = FontStyle.Bold; if (EditorApplication.isPlaying) { if (d.isLoaded) { GUILayout.Box("Active: " + d.diags[d.currentDiag].name, GUILayout.ExpandWidth(true)); } else { GUILayout.Box("No dialogue Active", GUILayout.ExpandWidth(true)); } scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUI.skin.GetStyle("Box"), GUILayout.ExpandWidth(true), GUILayout.Height(400)); for (int i = 0; i < d.diags.Count; i++) { if (!d.diags[i].loaded) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(i.ToString() + ". " + d.diags[i].name + ": NOT LOADED"); if (d.isLoaded) { GUI.enabled = false; } if (GUILayout.Button("Load!")) { d.LoadDialogues(d.diags[i].name, ""); } GUI.enabled = true; GUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField(i.ToString() + ". " + d.diags[i].name + ": LOADED", b); } } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); if (d.isLoaded) { GUI.enabled = false; } if (GUILayout.Button("Load All")) { d.LoadDialogues(); } if (GUILayout.Button("Unload All")) { d.UnloadDialogues(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } else { GUILayout.Label("Enter PlayMode to display loaded/unloaded information"); } }
//Here I'm assigning the variable a new component of its required type void Start() { dialogue = gameObject.AddComponent <VIDE_Data>(); //Remember you can also manually add the VIDE_Data script as a component in the Inspector, //then drag&drop it on your 'dialogue' variable slot }
void Update() { var data = VIDE_Data.nodeData; print(inConversation); if (inConversation) { rbfpc.enabled = false; Cursor.visible = true; } else { rbfpc.enabled = true; Cursor.visible = false; } if (VIDE_Data.isLoaded) { if (!data.pausedAction) { if (Input.GetKeyDown(KeyCode.Alpha1)) { data.selectedOption = 0; } if (Input.GetKeyDown(KeyCode.Alpha2)) { data.selectedOption = 1; } if (Input.GetKeyDown(KeyCode.Alpha3)) { data.selectedOption = 2; } if (Input.GetKeyDown(KeyCode.Alpha4)) { data.selectedOption = 3; } } if (currentOptionsAsGameObjects.Count != 0) { foreach (GameObject option in currentOptionsAsGameObjects) { //Color the Player options. Blue for the selected one for (int i = 0; i < currentOptions.Count; i++) { currentOptions[i].color = Color.white; if (i == data.selectedOption) { currentOptions[i].color = Color.yellow; } } } } } //print(data.npcComment[data.npcCommentIndex]); //text.text = data.npcComment[data.npcCommentIndex]; //print(VIDE_Data.nodeData.selectedOption); if (Input.GetKeyDown(KeyCode.Mouse0)) { VIDE_Data.Next(); //aiDialogue.text = string.Empty; //playerDialogue.text = string.Empty; } if (inConversation) { //text.text = CurrentText(); } if (Input.GetKeyDown(KeyCode.KeypadPlus)) { step++; } }
//Here I'm assigning the variable a new component of its required type void Start() { VIDE_Data.OnActionNode += ActionHandler; //Subscribe to listen to triggered actions VIDE_Data.OnLoaded += OnLoadedAction; //Subscribe VIDE_Data.LoadDialogues(); //Load all dialogues to memory so that we dont spend time doing so later }