Ejemplo n.º 1
0
    //This begins the conversation (Called by examplePlayer script)
    public void Begin(VIDE_Assign diagToLoad)
    {
        //First step is to call BeginDialogue, passing the required VIDE_Assign component
        //This will store the first Node data in dialogue.nodeData
        dialogue.BeginDialogue(diagToLoad);


        //Safety check in case a null dialogue was sent
        if (dialogue.assigned == null)
        {
            dialogue.EndDialogue();
            return;
        }

        //Let's clean the NPC text variables
        npcText.text = "";
        npcName.text = "";

        //If we already talked to this NPC, lets modify the start of the conversation
        //Of course, this will be true for particular cases
        //Here, we are using the dialogueName variable of the VIDE_Assign to compare
        if (dialogue.assigned.interactionCount > 0 || LocalDataSingleton.instance.talkedToDragon)
        {
            string name = dialogue.assigned.dialogueName;
            switch (name)
            {
            case "Dragon":
                dialogue.nodeData = dialogue.SetNode(30);     //SetNode allows you to jump to whichever node you want
                if (!LocalDataSingleton.instance.talkedToDragon)
                {
                    LocalDataSingleton.instance.talkedToDragon = true;
                }
                break;
            }
        }

        var data = dialogue.nodeData;

        //Let's specifically check for dynamic text change
        if (!data.currentIsPlayer && data.extraData.Equals("itemLookUp"))
        {
            ItemLookUp(data);
        }
        else if (!data.currentIsPlayer && data.extraData.Equals("RelicLookUp"))
        {
            RelicLookUp(data);
        }

        //Everytime dialogue.nodeData gets updated, we update our UI with the new data
        UpdateUI();
    }
Ejemplo n.º 2
0
    public void UpdateUI()
    {
        var data = dialogue.nodeData;

        //If we've reached the end, let's end everything.
        if (data.isEnd)
        {
            //This is called when we have reached the end of the conversation
            dialogue.EndDialogue();
            return;
        }

        //If this new Node is a Player Node, set the selectable comments offered by the Node
        if (data.currentIsPlayer)
        {
            SetOptions(data.playerComments);
        }
        //If it's an NPC Node, let's just update NPC's text
        else
        {
            if (npcText.text != data.npcComment[data.npcCommentIndex])
            {
                npcText.text = "";
                StartCoroutine(AnimateText());
            }
            npcName.text = data.tag;
        }
    }
Ejemplo n.º 3
0
 //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();
 }
Ejemplo n.º 4
0
    public void EndConversation(VIDE_Data.NodeData data)
    {
        _currentDialogue.OnActionNode -= ActionHandler;
        _currentDialogue.OnNodeChange -= NodeChangeAction;
        _currentDialogue.OnEnd        -= EndConversation;

        SetPlayerControllerActive(true);
        _currentDialogue.EndDialogue();
        UIRoot.SetActive(false);
    }
Ejemplo n.º 5
0
    void OnGUI()
    {
        if (dialogue.isLoaded)
        {
            var data = dialogue.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;
                        dialogue.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(">"))
                {
                    dialogue.Next();
                }

                if (data.isEnd) // If it's the end, let's just call EndDialogue
                {
                    dialogue.EndDialogue();
                }
            }
        }
        else   // Add a button to begin conversation if it isn't started yet
        {
            if (GUILayout.Button("Start Convo"))
            {
                dialogue.BeginDialogue(GetComponent <VIDE_Assign>()); //We've attached a DialogueAssign to this same gameobject, so we just call the component
            }
        }
    }
Ejemplo n.º 6
0
    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();
    }
    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);
        }
    }