Beispiel #1
0
    public void ResetDialogSystem()
    {
        ChoseDialogue.Instance.leaveMultyChoiceDialogue();


        quedDialogs.Clear();
        //activeDialog.holder.GetComponent<ContaningDialog>().hasBeenRead = true;
        activeDialog        = null;
        isInDialogue        = false;
        newMovement.canMove = true;

        dialogTextUI.enabled          = false;
        dialogNameTagUI.enabled       = false;
        dialogPortraitImageUI.enabled = false;
        ChoseDialogue.Instance.gameObject.GetComponent <Image>().enabled = false;
    }
Beispiel #2
0
    //en funktion som kallas vid nya dialoger
    public void queNewDialog(
        AudioClip[] allStartSound,
        float startSundPitch,
        List <Dialogs> newDialog,
        GameObject[] newAnswers,
        UnityEvent newEvents,
        string textOnChose,
        GameObject holder,
        bool hasBeenRead)
    {
        CompleteConvesation newConversation = new CompleteConvesation();

        newConversation.startDialogueSound = allStartSound;
        newConversation.dialogs            = newDialog;
        newConversation.Answers            = newAnswers;
        newConversation.events             = newEvents;
        newConversation.displayText        = textOnChose;
        newConversation.holder             = holder;
        newConversation.hasBeenRead        = hasBeenRead;
        quedDialogs.Add(newConversation);
    }
Beispiel #3
0
    //säkerställer så att det inte finns flera DialogManager
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Debug.LogError("There is too many dialogManager placed on scene");
        }
        activeDialog = null;


        isInDialogue = false;
        //nollställer systemet ifall det inte finns någon dialog i kön
        //obs körs varje frame, oödigt; förbätring?
        dialogTextUI.text             = "";
        dialogNameTagUI.text          = "";
        dialogTextUI.enabled          = false;
        dialogNameTagUI.enabled       = false;
        dialogPortraitImageUI.enabled = false;
        dialogAt = 0;
    }
Beispiel #4
0
 public void forceOne(CompleteConvesation con)
 {
     allReplies.Add(con);
 }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (soundDelay >= 0)
        {
            soundDelay -= Time.deltaTime;
        }

        ///ifall spelaren befinner sig i en dialog
        if (activeDialog != null)
        {
            //hinder vilket gör att en kod endast körs en gång
            if (callFunctionOnce && !stopRewriteText)
            {
                //aktiverar alla ui-eliment
                dialogTextUI.enabled          = true;
                dialogNameTagUI.enabled       = true;
                dialogPortraitImageUI.enabled = true;

                if (soundDelay < 0)
                {
                    //startar animationen för texten (även ljuded?)
                    StartCoroutine(animateText(activeDialog.dialogs[dialogAt].Text));
                    //hindrar från återspelning av animation och ljud
                    callFunctionOnce = false;
                }
                //ändrar profilen till hon/han som pratar
                dialogPortraitImageUI.sprite = activeDialog.dialogs[dialogAt].PortraitOfTalkingNPC;
                dialogNameTagUI.text         = activeDialog.dialogs[dialogAt].NameOfTalkingNPC;

                createAnswers();
            }


            if (soundDelay < 0)
            {
                //lettar efter dialog input
                if (Input.GetButtonDown("Submit"))
                {
                    //ifall man är mitten av en animation kan man hoppa över den
                    if (!callFunctionOnce)
                    {
                        skipAnimation = true;
                    }
                    else
                    {
                        isInDialogBranch = activeDialog.dialogs[dialogAt].dialogueTree;
                        //om man inte är i en...
                        dialogAt++;
                        //isInDialogBranch = activeDialog.dialogs[dialogAt].dialogueTree;
                        stopRewriteText      = false;
                        dialogTextUI.text    = "";
                        dialogNameTagUI.text = "";

                        //nollställer dialogManager efter en dialog, samt tar bort dialogen ur listan
                        if (dialogAt >= activeDialog.dialogs.Count)
                        {
                            ChoseDialogue.Instance.leaveMultyChoiceDialogue();

                            dialogTextUI.enabled          = false;
                            dialogNameTagUI.enabled       = false;
                            dialogPortraitImageUI.enabled = false;
                            isInDialogue = false;

                            quedDialogs.Clear();
                            ChoseDialogue.Instance.gameObject.GetComponent <Image>().enabled = false;
                            Debug.Log("before invoke");
                            if (!activeDialog.holder.GetComponent <ContaningDialog>().hasBeenRead)
                            {
                            }
                            // Debug.Log("in" + isInDialogBranch);
                            //Debug.Log("out" + activeDialog.dialogs[dialogAt - 1].dialogueTree);
                            activeDialog.events.Invoke();
                            activeDialog.holder.GetComponent <ContaningDialog>().hasBeenRead = true;
                            activeDialog = null;
                            //PlayerMovement.newMovement.canMove = true;
                            Invoke("changeMoveState", 0.1f);
                        }
                    }
                }
            }
        }
        if (activeDialog == null)
        {
            if (!isInDialogue)
            {
                //nollställer systemet ifall det inte finns någon dialog i kön
                //obs körs varje frame, oödigt; förbätring?
                dialogTextUI.text             = "";
                dialogNameTagUI.text          = "";
                dialogTextUI.enabled          = false;
                dialogNameTagUI.enabled       = false;
                dialogPortraitImageUI.enabled = false;
                dialogAt = 0;

                if (quedDialogs.Count == 1)
                {
                    //letar efter en ny dialog och ifall det finns en
                    //aktiveras den
                    if (quedDialogs[0].holder.GetComponent <ContaningDialog>().canPlaySound)
                    {
                        playStartDialogueSound();
                    }

                    activeDialog = quedDialogs[0];
                    ChoseDialogue.Instance.forceOne(activeDialog);
                    activeDialog.hasBeenRead = true;
                    callFunctionOnce         = true;
                    isInDialogue             = true;
                    ChoseDialogue.Instance.gameObject.GetComponent <Image>().enabled = true;
                    newMovement.canMove = false;
                }
                else if (quedDialogs.Count >= 2)
                {
                    playStartDialogueSound();
                    ChoseDialogue.Instance.enterMultyChoiceDialogue(quedDialogs);
                    callFunctionOnce = true;
                    isInDialogue     = true;
                    ChoseDialogue.Instance.gameObject.GetComponent <Image>().enabled = true;
                    newMovement.canMove = false;
                }
            }
        }
    }