Exemple #1
0
    public void Say(string dialogue, DialogueType type, string speakerName)
    {
        if (isSpeaking)
        {
            StopSpeaking();
        }
        else
        {
            if (isWaitingForChoice) //can't advance dialogue if waiting for choice
            {
                return;
            }

            if (reachedEnd) //ends dialogue if at the end and no one is typing/ speaking
            {
                EndDialogue();
                return;
            }


            speaking = StartCoroutine(Speaking(dialogue, type, speakerName));
            //set sprite here
            SetCharacterSprite(currentConverstaion.conversationLines[currentConverstaion.lineIndex].spriteType);
            reachedEnd = !currentConverstaion.IterateLineIndex();
        }
    }
Exemple #2
0
    public void StartDialogue(Dialogue dialogue, DialogueType type = DialogueType.Fade, bool isAuto = false)
    {
        sentences.Clear();
        foreach (SentenceInfo sentence in dialogue.sentences)
        {
            sentences.Enqueue(sentence);
        }
        this.type     = type;
        nameText.text = dialogue.name;
        switch (this.type)
        {
        case DialogueType.Fade:
            dialogueText.DOFade(0, 0);
            dialogueBox.GetComponent <RectTransform>().DOAnchorPosY(0, 0);
            break;

        case DialogueType.Move:
            dialogueBox.GetComponent <RectTransform>().DOAnchorPosY(0, moveTransitTime);
            break;
        }
        //animator.SetBool("isOpen",true);
        if (isAuto)
        {
            StartCoroutine(DisplayNextSentenceAuto(dialogue.sentences.Length));
        }
        else
        {
            DisplayNextSentence();
        }
    }
Exemple #3
0
    public DialogueNode()
    {
        windowTitle = "Dialogue Node";

        NumText = 1;

        inputs     = new List <BaseNode>();
        inputRects = new List <Rect>();

        outputs     = new List <BaseNode>();
        outputRects = new List <Rect>();

        Sentences = new List <string>();

        dialogueType = new DialogueType()
        {
            dialogueType  = "Dialogue",
            windowRect    = windowRect,
            index         = index,
            sentences     = new List <string>(),
            inputIndexes  = new List <int>(),
            inputRects    = new List <Rect>(),
            outputIndexes = new List <int>(),
            outputRects   = new List <Rect>()
        };

        hasInputs = true;
    }
 public void SetValues(int index, string displayText, DialogueType type)
 {
     this.index  = index;
     text.text   = (index + 1) + ") " + displayText;
     image.color = HUD.instance.dialogueMenu.GetDialogueChoiceColour(type);
     rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, text.preferredHeight + 20);
 }
    public DialogueObject giveDialog(DialogueType type, GameObject prefab = null)
    {
        DialogueObject d = null;

        if (prefab == null)
        {
            switch (type)
            {
            case DialogueType.Dialogue:
                d = createDialogObject(dialogPrefab);
                break;

            case DialogueType.ItemDescription:
                d = createDialogObject(itemDialogPrefab);
                break;

            case DialogueType.ItemShop:
                d = createDialogObject(shopDialogPrefab);
                break;
            }
        }
        else
        {
            d = createDialogObject(prefab);
        }
        return(d);
    }
Exemple #6
0
    public void SetupDialogue(DialogueType _fillType, ClickForDialogueBox _parent)
    {
        parent = _parent;

        switch (_fillType)
        {
        case DialogueType.ACCEPT_CHALLENGE:
            dialogueDesc.text = "Are you sure you want to accept this challenge?";
            acceptText.text   = "Bring it!";
            cancelText.text   = "On second thoughts...";
            break;

        case DialogueType.OPT_OUT:
            dialogueDesc.text = "Are you really giving up on this challenge?";
            acceptText.text   = "Count me out";
            cancelText.text   = "No, I can do this!";
            break;

        case DialogueType.ACCEPT_REWARD:
            dialogueDesc.text = "Is this the reward you want?";
            acceptText.text   = "Definately";
            cancelText.text   = "Not really...";
            break;
        }
    }
Exemple #7
0
    public ChoiceNode()
    {
        windowTitle = "Choice Node";

        NumChoices = 2;
        Choices    = new List <string>();

        inputs     = new List <BaseNode>();
        inputRects = new List <Rect>();

        outputs     = new List <BaseNode>();
        outputRects = new List <Rect>();

        ChoiceRects = new List <Rect>();

        ChoiceNodePair = new Dictionary <int, BaseNode>();

        dialogueType = new DialogueType()
        {
            dialogueType         = "Choice",
            windowRect           = windowRect,
            index                = index,
            choices              = new List <string>(),
            choiceRects          = new List <Rect>(),
            choiceDialogueKeys   = new List <int>(),
            choiceDialogueValues = new List <int>(),
            inputIndexes         = new List <int>(),
            inputRects           = new List <Rect>(),
            outputIndexes        = new List <int>(),
            outputRects          = new List <Rect>(),
        };

        hasInputs = true;
    }
Exemple #8
0
    // See src/dialogue_1.txt for formatting the file
    private void LoadDialogueFromFile(string filepath)
    {
        StreamReader file = new StreamReader(filepath);

        char[] delim = { ' ', ',' };

        while (!file.EndOfStream)
        {
            string line = file.ReadLine();

            //string [] values = line.Split (delim, StringSplitOptions.RemoveEmptyEntries);
            string [] values = line.Split(delim, 5, StringSplitOptions.RemoveEmptyEntries);
            if (values.Length == 0 || values[0] == "#") // ignore blank lines and comments
            {
                continue;
            }

            if (values[0].Contains(">>>"))   // start trigger
            {
                string       trigger = values[1];
                DialogueType type    = EnumUtil.FromString <DialogueType>(values[2]);

                Dialogue dialogue = GetMessagesFromFile(file);
                mTriggers[type].Add(trigger, dialogue);
            }
        }

        file.Close();
    }
 public void startFinalCheckpointDialogue()
 {
     // Get the final checkpoint dialogue
     Dialogue[] selected = dialogue.checkpointDialogue[5].dialogue;
     currDialogue = selected;
     currType     = DialogueType.FinalCheckpoint;
     startDialogue();
 }
 public void startPostDialogue()
 {
     // Get pre-post minigame dialogue
     Dialogue[] selected = dialogue.postDialogue[0].dialogue;
     currDialogue = selected;
     currType     = DialogueType.Post;
     startDialogue();
 }
Exemple #11
0
            /// <summary>
            /// Creates a basic DialogueObject. lineCall delegate will be called when this dialogue box is shown.
            /// </summary>
            /// <param name="name">Name of the person speaking</param>
            /// <param name="line">Dialogue the person says</param>
            /// <param name="lineCall">Fucntion to be called when dialogue line is shown. Function must be of type void and take in no parameters.</param>
            public DialogueObject(string name, string line, BasicLineCall lineCall)
            {
                dialogueType = DialogueType.BasicLine;

                speakerName   = name;
                dialogueLine  = line;
                basicLineCall = lineCall;
            }
Exemple #12
0
 public bool HasUsedDialogueType(DialogueType type)
 {
     if (usedDialogueOptions.ContainsKey(type))
     {
         return(usedDialogueOptions[type]);
     }
     return(false);
 }
 public void startDateDialogue()
 {
     // Get date dialogue
     Dialogue[] selected = dialogue.dateDialogue[0].dialogue;
     currDialogue = selected;
     currType     = DialogueType.Date;
     startDialogue();
 }
 public void startGreetingDialogue()
 {
     // Get greeting dialogue
     Dialogue[] selected = dialogue.greetDialogue[0].dialogue;
     currDialogue = selected;
     currType     = DialogueType.Greeting;
     startDialogue();
 }
 public void startCheckpointDialogue(int i)
 {
     // Get the ith checkpoint dialogue
     Dialogue[] selected = dialogue.checkpointDialogue[i].dialogue;
     currDialogue = selected;
     currType     = DialogueType.Checkpoint;
     startDialogue();
 }
    public IEnumerator cont(string text)
    {
        finishedText        = false;
        currentDialogueType = DialogueType.Continue;
        stringToReveal      = text;
        yield return(StartCoroutine(AnimateText(text)));

        yield return(StartCoroutine(done()));
    }
        public static IDialogue Get(DialogueType type)
        {
            if (dialogue.ContainsKey(type))
            {
                return(dialogue[type]);
            }

            return(null);
        }
    private void showDialog(string msg, DialogueType type)
    {
                #if UNITY_ANDROID
        // Obtain activity
        AndroidJavaClass  unityPlayer    = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject activity       = unityPlayer.GetStatic <AndroidJavaObject>  ("currentActivity");
        AndroidJavaObject InputTextField = new AndroidJavaObject("android.widget.EditText", activity);

        // Lets execute the code in the UI thread
        activity.Call("runOnUiThread", new AndroidJavaRunnable(() => {
            //clear flag
            clearflag();

            // Create an AlertDialog.Builder object
            AndroidJavaObject alertDialogBuilder = new AndroidJavaObject("android/app/AlertDialog$Builder", activity);

            // Call setTitle on the builder
            alertDialogBuilder.Call <AndroidJavaObject> ("setTitle", "Info:");

            // Call setMessage on the builder
            alertDialogBuilder.Call <AndroidJavaObject> ("setMessage", msg);

            //You must answer it before proceed
            alertDialogBuilder.Call <AndroidJavaObject> ("setCancelable", false);

            // Call setPositiveButton and set the message along with the listner
            // Listner is a proxy class
            alertDialogBuilder.Call <AndroidJavaObject> ("setPositiveButton", "Yes", new PositiveButtonListner(this));

            // Call setPositiveButton and set the message along with the listner
            // Listner is a proxy class
            switch (type)
            {
            case DialogueType.INPUT:
                alertDialogBuilder.Call <AndroidJavaObject> ("setTitle", "Enter Code:");
                alertDialogBuilder.Call <AndroidJavaObject> ("setView", InputTextField);
                alertDialogBuilder.Call <AndroidJavaObject> ("setPositiveButton", "Yes", new InputTextFieldListner(this, InputTextField));
                break;

            case DialogueType.YESONLY:
                break;

            case DialogueType.NORMAL:
                alertDialogBuilder.Call <AndroidJavaObject> ("setNegativeButton", "No", new NegativeButtonListner(this));
                break;

            default:            //same as normal
                alertDialogBuilder.Call <AndroidJavaObject> ("setNegativeButton", "No", new NegativeButtonListner(this));
                break;
            }
            // Finally get the dialog instance and show it
            AndroidJavaObject dialog = alertDialogBuilder.Call <AndroidJavaObject> ("create");
            dialog.Call("show");
        }));
                #endif
    }
Exemple #19
0
 private static void ConvertDialogue(ArticyData articyData, DialogueType dialogue)
 {
     if (dialogue != null)
     {
         articyData.dialogues.Add(dialogue.Id, new ArticyData.Dialogue(dialogue.Id, dialogue.TechnicalName,
                                                                       ConvertLocalizableText(dialogue.DisplayName), ConvertLocalizableText(dialogue.Text),
                                                                       ConvertFeatures(dialogue.Features), new Vector2(dialogue.Position.X, dialogue.Position.Y),
                                                                       ConvertPins(dialogue.Pins), ConvertReferences(dialogue.References)));
     }
 }
Exemple #20
0
    public Dialogue(string name, string line)
    {
        DialogueLine dialogueLine = new DialogueLine();

        dialogueLine.name = name;
        dialogueLine.line = line;

        lines = new DialogueLine[] { dialogueLine };
        type  = DialogueType.end;
    }
        private List <Dialogue> GetDialogues(DialogueType dialogueType)
        {
            switch (dialogueType)
            {
            case DialogueType.TurnipTutorial:
                return(settings.turnipTutorialDialogues);
            }

            return(new List <Dialogue>());
        }
 public void StartDialogue(Dialogue dialogue)
 {
     currentDialogueType = dialogue.type;
     nameText.text       = dialogue.name;
     sentences.Clear();
     foreach (string sentence in dialogue.sentences)
     {
         sentences.Enqueue(sentence);
     }
     DisplayNextSentence();
 }
    public void startHatedDialogue()
    {
        // Get insufficient followers dialogue
        int diaLen = dialogue.hatedDialogue.Length;
        int index  = Random.Range(0, diaLen);

        Dialogue[] selected = dialogue.hatedDialogue[index].dialogue;
        currDialogue = selected;
        currType     = DialogueType.Hated;
        startDialogue();
    }
    public void startInsufficientAffectionDialogue()
    {
        // Get insufficient affection dialogue
        int diaLen = dialogue.insufficientAffectionDialogue.Length;
        int index  = Random.Range(0, diaLen);

        Dialogue[] selected = dialogue.insufficientAffectionDialogue[index].dialogue;
        currDialogue = selected;
        currType     = DialogueType.Insufficient;
        startDialogue();
    }
Exemple #25
0
 public void StartDialogue(string key, DialogueType dialogueType, Player.Death deathType = Player.Death.barbecue)
 {
     player.isTalking = true;
     textList         = TextesDictionary.GetTexte(key);
     if (textList.Count == 0)
     {
         Debug.Log("Le dialogue n'a pas de composants");
     }
     things.SetActive(true);
     StartCoroutine(PrintText(dialogueType, deathType));
 }
    public void startFailDateDialogue()
    {
        // Get failed date dialogue
        int diaLen = dialogue.goodPostDialogue.Length;
        int index  = Random.Range(0, diaLen);

        Dialogue[] selected = dialogue.failDateDialogue[index].dialogue;
        currDialogue = selected;
        currType     = DialogueType.FailedDate;
        startDialogue();
    }
    public void startGoodPostDialogue()
    {
        // Get good after-post minigame dialogue
        int diaLen = dialogue.goodPostDialogue.Length;
        int index  = Random.Range(0, diaLen);

        Dialogue[] selected = dialogue.goodPostDialogue[index].dialogue;
        currDialogue = selected;
        currType     = DialogueType.AfterPost;
        startDialogue();
    }
    public IEnumerator text(string text, bool keepText)
    {
        finishedText        = false;
        currentDialogueType = DialogueType.Text;
        stringToReveal      = "";
        yield return(StartCoroutine(AnimateText(text)));

        if (!keepText)
        {
            yield return(StartCoroutine(done()));
        }
    }
Exemple #29
0
            /// <summary>
            /// Creates a DialogueObject of type TextInput. Allows the player to input text into the conversation.
            /// </summary>
            /// <param name="name">Name of the person speaking</param>
            /// <param name="line">Dialogue the person says</param>
            /// <param name="contentType">Type of input to be entered into the text input field.</param>
            /// <param name="placeholderText">Text to be displayed in the input field before the player enters text</param>
            /// <param name="maxLength">Max length of the string to be entered. 0 = no max length.</param>
            /// <param name="enterInput">Function to be called when player advances dialogue. Function must be of type void and take in one string variable.</param>
            public DialogueObject(string name, string line, InputField.ContentType contentType, string placeholderText, int maxLength,
                                  EnterInput enterInput)
            {
                dialogueType = DialogueType.TextInput;

                speakerName           = name;
                dialogueLine          = line;
                inputContentType      = contentType;
                inputPlaceholderText  = placeholderText;
                maxInputLength        = maxLength;
                dialogueInputCallback = enterInput;
            }
Exemple #30
0
    IEnumerator PrintText(DialogueType dialogueType, Player.Death deathType)
    {
        for (int i = 0; i < textList.Count; i++)
        {
            actualText   = textList[i].text;
            image.sprite = dialogueImages.GetImage(textList[i].image);
            skip         = false;
            text.text    = "";
            yield return(new WaitForSeconds(WAIT_AT_START));

            foreach (char c in actualText)
            {
                text.text += c;
                if (!skip)
                {
                    yield return(new WaitForSeconds(SHORT_DELTA_TIME));

                    if (c == '.' || c == '!' || c == '?' || c == ';' || c == '\n')
                    {
                        yield return(new WaitForSeconds(LONG_DELTA_TIME));
                    }
                    else if (c == ',')
                    {
                        yield return(new WaitForSeconds(DELTA_TIME));
                    }
                }
            }
            skip = true;
            next = false;
            while (!next)
            {
                yield return(new WaitForSeconds(SHORT_DELTA_TIME));
            }
        }
        things.SetActive(false);

        switch (dialogueType)
        {
        case DialogueType.DIE:
            death.StartDeath(deathType);
            break;

        case DialogueType.BOSS:
            end.GameOver();
            break;

        case DialogueType.NOTHING:
        default:
            player.isTalking = false;
            break;
        }
    }
Exemple #31
0
    public void DecideOnBalloon()
    {
        if (currentDialogueType == DialogueType.Stalling) {
            isInDialogue = false;
            currentDialogueType = DialogueType.DecideOnBalloon;
            dialogueBox.GetComponent<Canvas>().enabled = true;
            dialogueText.GetComponent<Text>().text = balloon.dialogues[1];

            for (int i = 0; i < items.Length; i++) {
                items[i].GetComponent<Image>().enabled = false;
            }
            for (int i = 0; i < endings.Length; i++) {
                endings[i].SetActive(true);
            }
        }
    }
Exemple #32
0
 public void ChooseEnding(bool choosePower)
 {
     GetComponents<AudioSource>()[1].Stop();
     GetComponents<AudioSource>()[0].Play();
     if (choosePower) {
         currentDialogueType = DialogueType.ChoosePower;
         currentDialogue = d_ChoosePower;
     } else {
         currentDialogueType = DialogueType.ChooseBalloon;
         currentDialogue = d_ChooseBalloon;
     }
     currentDialogueIndex = 0;
     for (int i = 0; i < endings.Length; i++) {
         endings[i].SetActive(false);
     }
     isInDialogue = true;
     NextDialogue();
 }
Exemple #33
0
 public void OnEvent(AtavismEventData eData)
 {
     if (eData.eventType == "NPC_INTERACTIONS_UPDATE") {
         dialogueType = DialogueType.Options;
         if (!open)
             ToggleOpen();
     } else if (eData.eventType == "DIALOGUE_UPDATE") {
         dialogueType = DialogueType.Chat;
         if (!open)
             ToggleOpen();
     } else if (eData.eventType == "QUEST_OFFERED_UPDATE") {
         dialogueType = DialogueType.QuestOffer;
         if (!open)
             ToggleOpen();
     } else if (eData.eventType == "QUEST_PROGRESS_UPDATE") {
         dialogueType = DialogueType.QuestProgress;
         if (!open)
             ToggleOpen();
     }
 }
Exemple #34
0
 void DrawQuestProgress()
 {
     QuestLogEntry q = ClientAPI.ScriptObject.GetComponent<Quests>().GetQuestProgressInfo(0);
     GUILayout.Label(q.Title);
     GUILayout.TextArea(q.ProgressText);
     if (q.Complete) {
         if (GUILayout.Button("Continue")) {
             dialogueType = DialogueType.QuestConclusion;
         }
     }
 }
Exemple #35
0
    // Use this for initialization
    void Start()
    {
        dialogueBox = GameObject.Find("DialogueBox");
        currentDialogueIndex = 0;
        currentDialogueType = DialogueType.Intro;

        player = GameObject.Find("Player").GetComponent<Player>();
        balloon = GameObject.Find("Balloon").GetComponent<EndBalloon>();
        balloon.Init();
        dialogueText = GameObject.Find("DialogueBox/Background/Text");

        d_Intros = (Resources.Load("Home/EndDialogue1") as TextAsset).text.Split('\n');
        d_FirstAttempt = (Resources.Load("Home/EndDialogue2") as TextAsset).text.Split('\n');
        d_Stalling = (Resources.Load("Home/EndDialogue3") as TextAsset).text.Split('\n');
        d_ChoosePower = (Resources.Load("Home/EndDialogue4") as TextAsset).text.Split('\n');
        d_ChooseBalloon = (Resources.Load("Home/EndDialogue5") as TextAsset).text.Split('\n');
        d_ItemOrigins = (Resources.Load("Home/EndItemOrigins") as TextAsset).text.Split('\n');

        items = new GameObject[d_ItemOrigins.Length + 1];
        for (int i = 0; i < items.Length; i++) {
            items[i] = GameObject.Find("DialogueBox/Item" + i);
            items[i].GetComponent<Image>().enabled = false;
        }

        endings = new GameObject[2];
        for (int i = 0; i < endings.Length; i++) {
            endings[i] = GameObject.Find("DialogueBox/Ending" + i);
            endings[i].SetActive(false);
        }

        currentDialogue = d_Intros;
        startedConvo = false;

        creditsDelay = 0f;

        player.isFrozen = true;
        isInDialogue = true;
        NextDialogue();
    }
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
            case DialogueType.SHERLOCK_PROMPT:
                Sherlock.Instance.PlaySequenceInstructions(sherlockPrompt, null);
                return true;

            case DialogueType.DAD_REWARD:
                Sherlock.Instance.PlaySequenceInstructions(dadReward, null);
                return true;

            case DialogueType.STORY_END:
                Sherlock.Instance.PlaySequenceInstructions(storyEnd, CompleteLevel);
                return true;

            default:
                return false;
        }
    }
	public void Load ()
	{ 
		string i = CommonVariable.Instance.loadi; 
		if (ES2.Exists (this.gameObject.name + "MapItem" + i)) {
			isDestroyOnStart = ES2.Load<bool> (this.gameObject.name + "MapItem" + i + "?tag=isDestroyOnStart" + i); 
			giveItem = ES2.Load<string> (this.gameObject.name + "MapItem" + i + "?tag=giveItem" + i);
			string _currentDialogue = ES2.Load<string> (this.gameObject.name + "MapItem" + i + "?tag=currentDialogue" + i);
			if (_currentDialogue == DialogueType.DefaultDialogue.ToString ())
				this.currentDialogue = DialogueType.DefaultDialogue;
			else if (_currentDialogue == DialogueType.SecondDialogue.ToString ())
				this.currentDialogue = DialogueType.SecondDialogue;
			if (isDestroyOnStart) {
				this.DestroyMapItem ();
			} 
		}//else { 
		//print ("chưa có");
		//}
	}
    /*public bool CheckCorrectTopic(string topic)
    {
        //List<string> answerList = manager.GetAnswerList();
        bool found = false;

        for(int i = 0; i < answersList.Count; i++){
            if(topic == answersList[i]){
                found = true;
                break;
            }
        }

        return found;
    }*/
    /// <summary>
    /// Display dialogue based on dialogue type
    /// </summary>
    /// <returns>
    /// True if the dialogue was showed
    /// </returns>
    /// <param name='dialogueType'>
    /// Type of dialogue
    /// </param>
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
            case DialogueType.HINT1:
                Sherlock.Instance.PlaySequenceInstructions(hint1, null);
                return true;
            case DialogueType.HINT2:
                Sherlock.Instance.PlaySequenceInstructions(hint2, null);
                return true;

            case DialogueType.NEXTROUND:
                Sherlock.Instance.PlaySequenceInstructions(sherlockIntroPhases[currentRound - 2], null);
                return true;

            case DialogueType.SOLCHOSEN:
                Sherlock.Instance.PlaySequenceInstructions(solutionsChosen.GetRandomDialogue(), null);
                return true;

            case DialogueType.CORRECT:
                Sherlock.Instance.PlaySequenceInstructions(correctResponses.GetRandomDialogue(), null);
                return true;

            case DialogueType.CHOOSESOL:
                Sherlock.Instance.PlaySequenceInstructions(chooseSolutions.GetRandomDialogue(), null);
                return true;

            case DialogueType.MISTAKE:
                Sherlock.Instance.PlaySequenceInstructions(incorrectResponses.GetRandomDialogue(), null);
                return true;

            case DialogueType.END:
                Sherlock.Instance.PlaySequenceInstructions(end, null);
                return true;

            case DialogueType.START:
                if(showTutorial)
                    Sherlock.Instance.PlaySequenceInstructions(start, initiateTutorial);
                else
                    Sherlock.Instance.PlaySequenceInstructions(start, SelectTopicsOfConversation);
                return true;

            default:
                return false;
        }
    }
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
            case DialogueType.NEXTROUND:
                if(round == 2) StartCoroutine("Phase2Tutorial");
                if(round == 3) StartCoroutine("Phase3Tutorial");
                if(round == 4) GameRoundBegin();
                return true;

            case DialogueType.START:
                StartCoroutine("Phase1Tutorial");
                return true;

            case DialogueType.END:
                Sherlock.Instance.PlaySequenceInstructions(end, null);
                Invoke("StoryEnd", minigame.GetCurrentDialogueDuration());
                return true;

            case DialogueType.BEGIN:
                Sherlock.Instance.PlaySequenceInstructions(begin, playStart);
                return true;

            case DialogueType.START_MINIGAME:
                if(showTutorial)
                    Sherlock.Instance.PlaySequenceInstructions(startMinigame, GameMinigameRoundBegin);
                else
                {
                    Sherlock.Instance.HideDialogue();
                    GameMinigameRoundBegin();
                }
                return true;

            default:
                return false;
        }
    }
    public float GetAudioDuration(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
        case DialogueType.NOT_ON_TRAY:
            return (float) ((notOnTray.voiceOver != null) ? notOnTray.voiceOver.length : 0.5f);
        case DialogueType.WRONG_SPOT:
            return (float) ((wrongSpot.voiceOver != null) ? wrongSpot.voiceOver.length : 0.5f);
        case DialogueType.CORRECT:
            return (float) ((correct.voiceOver != null) ? correct.voiceOver.length : 0.5f);
        case DialogueType.END:
            return (float) ((end.voiceOver != null) ? end.voiceOver.length : 0.5f);
        }

        return 0.5f;
    }
    ///////////////////////////////////////////////////////////////////////////////////
    // Unity Overrides
    ///////////////////////////////////////////////////////////////////////////////////
    void Awake()
    {
        mDialogueQueue = new Dictionary<DialogueType, Queue<Dialogue>>();
        foreach (DialogueType d in EnumUtil.GetValues<DialogueType>())
            mDialogueQueue[d] = new Queue<Dialogue>();

        mTriggers = new Dictionary<DialogueType, Dictionary<string, Dialogue>>();
        foreach (DialogueType d in EnumUtil.GetValues<DialogueType>())
            mTriggers[d] = new Dictionary<string, Dialogue>();

        mTextBoxes = new Dictionary<SpeakerLocation, GUIText>();
        mNameBoxes = new Dictionary<SpeakerLocation, GUIText>();
        mTextWidth = new Dictionary<SpeakerLocation, float>();

        for (int i = 0; i < SpeakerLocations.Count; ++i) {
            SpeakerLocation location = SpeakerLocations[i];

            mTextBoxes.Add (location, DialogueTextBoxes[i]);
            mTextWidth[location] = mTextBoxes[location].GetScreenRect ().width;
            mTextBoxes[location].text = "";

            mNameBoxes.Add (location, NameTextBoxes[i]);
            mNameBoxes[location].text = "";
        }

        mSpeakers = new Dictionary<string, Speaker>();

        for (int i = 0; i < Speakers.Count; ++i) {
            string speakerKey = Speakers[i].SpeakerName + Speakers[i].Location.ToString();
            mSpeakers.Add (speakerKey, Speakers[i]);
        }

        string dialoguePath = "Data/IngameDialogue/dialogue_" + GameState.GameEra.ToString() + ".txt";

        LoadDialogueFromFile(dialoguePath);
        this.TriggerDialogue("ArcherMage");
        this.TriggerDialogue("Tutorial");

        mIsIdle = true;
        mDialogueType = DialogueType.Standard;
        mRealtimeStamp = Time.realtimeSinceStartup;
        TriggerRealtimeDialogue("Pause");
        //mDialogue = mDialogueQueue[DialogueType.Standard].Dequeue();
    }
    /// <summary>
    /// Display dialogue based on dialogue type
    /// </summary>
    /// <returns>
    /// True if the dialogue was showed
    /// </returns>
    /// <param name='dialogueType'>
    /// Type of dialogue
    /// </param>
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
            case DialogueType.START:
                return minigame.ContinueConversation(start);
            case DialogueType.CORRECT:
                return minigame.ContinueConversation(correct);
            case DialogueType.INCORRECT:
                return minigame.ContinueConversation(incorrect);
            case DialogueType.INTEREST:
                return minigame.ContinueConversation(interest);
            case DialogueType.JULIAINTEREST:
                return minigame.ContinueConversation(juliainterest);
            case DialogueType.INCORRECTINTEREST:
                minigame.ContinueConversation(incorrectinterest);
                return true;
            case DialogueType.START_NEXT_ROUND:
                return minigame.ContinueConversation(amber);
            case DialogueType.AMBERINTEREST:
                return minigame.ContinueConversation(amberinterest);
            case DialogueType.FOUND:
                return minigame.ContinueConversation(found);
            case DialogueType.END:
                Sherlock.Instance.PlaySequenceInstructions(end, null);//minigame.ContinueConversation(end);
                return true;
            case DialogueType.INTERESTS_QUESTION:
                return minigame.ContinueConversation(interestsQuestion);
        }

        return false;
    }
Exemple #43
0
    public void NextDialogue()
    {
        if (currentDialogueIndex < currentDialogue.Length) {
            dialogueBox.GetComponent<Canvas>().enabled = true;

            string s = currentDialogue[currentDialogueIndex];
            if (currentDialogueType == DialogueType.FirstAttempt && currentDialogueIndex == 1) {
                s += d_ItemOrigins[chosenItemIndex];
            } else if (currentDialogueType == DialogueType.Stalling) {
                if (currentDialogueIndex == 0) {
                    for (int i = 0; i < items.Length; i++) {
                        items[i].GetComponent<Image>().enabled = true;
                    }
                    dialogueText.GetComponent<Text>().text = s;
                    isInDialogue = false;
                    return;
                } else if (currentDialogueIndex == 3){
                    currentDialogueIndex = -1;
                }
            } else if (currentDialogueType == DialogueType.ChoosePower && currentDialogueIndex == 2) {
                GameObject.Find("DialogueBox/Image1").GetComponent<Image>().enabled = true;
            } else if (currentDialogueType == DialogueType.ChooseBalloon && currentDialogueIndex == 9) {
                GameObject.Find("DialogueBox/Image2").GetComponent<Image>().enabled = true;
            }

            dialogueText.GetComponent<Text>().text = s;
            currentDialogueIndex++;
        } else { // finished current dialogue
            switch (currentDialogueType) {
                case DialogueType.Intro:
                    // display items
                    for (int i = 0; i < items.Length - 1; i++) {
                        items[i].GetComponent<Image>().enabled = true;
                    }
                    currentDialogueType = DialogueType.FirstAttempt;
                    currentDialogue = d_FirstAttempt;
                    isInDialogue = false;
                    currentDialogueIndex = 0;
                    break;
                case DialogueType.FirstAttempt:
                    GameObject.Find("Precostone").GetComponent<Precostone>().Activate();
                    currentDialogueType = DialogueType.Stalling;
                    currentDialogue = d_Stalling;
                    HideDBox();
                    currentDialogueIndex = 0;
                    break;
                case DialogueType.ChoosePower:
                    GameObject.Find("DialogueBox/Background").GetComponent<Image>().enabled = false;
                    dialogueText.GetComponent<Text>().enabled = false;
                    creditsDelay = Time.time;
                    break;
                case DialogueType.ChooseBalloon:
                    GameObject.Find("DialogueBox/Background").GetComponent<Image>().enabled = false;
                    dialogueText.GetComponent<Text>().enabled = false;
                    creditsDelay = Time.time;
                    break;
                default:
                    break;
            }
        }
    }
    /// <summary>
    /// Display dialogue based on dialogue type
    /// </summary>
    /// <returns>
    /// True if the dialogue was showed
    /// </returns>
    /// <param name='dialogueType'>
    /// Type of dialogue
    /// </param>
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
        case DialogueType.NOT_ON_TRAY:
            return minigame.ContinueConversation(notOnTray);
        case DialogueType.WRONG_SPOT:
            return minigame.ContinueConversation(wrongSpot);
        case DialogueType.CORRECT:
            return minigame.ContinueConversation(correct);
        case DialogueType.END:
            return minigame.ContinueConversation(end);
        }

        return false;
    }
    private void UpdateDialogueQueue(DialogueType type)
    {
        if (mDialogueQueue[type].Count == 0) // no messages to display
            return;

        if (type != mDialogueType) { // a different type of dialogue needs to be
            mDialogueType = type;
            mIsIdle = true;
        }

        if (mIsIdle) {
            mDialogue = mDialogueQueue[mDialogueType].Peek();
            mIsIdle = false;
        }

        float deltaTime;
        if (type == DialogueType.Realtime)
            deltaTime = Time.realtimeSinceStartup - mRealtimeStamp;
        else
            deltaTime = Time.deltaTime;

        Message message;
        bool isValid = mDialogue.AdvanceMessage(deltaTime, out message);

        if (isValid) {
            DisplayMessage(message);
            mIsIdle = false;
        } else { // indicate that the current dialogue is complete
            mDialogueQueue[mDialogueType].Dequeue();
            mIsIdle = true;
        }
    }
    /// <summary>
    /// Display dialogue based on dialogue type
    /// </summary>
    /// <returns>
    /// True if the dialogue was showed
    /// </returns>
    /// <param name='dialogueType'>
    /// Type of dialogue
    /// </param>
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch(dialogueType)
        {
            case DialogueType.HINT:
                return minigame.ContinueConversation(hint);
            case DialogueType.WANTHINT:
                return minigame.ContinueConversation(wantHint);
            case DialogueType.LAUGHRIGHT:
                Sherlock.Instance.PlaySequenceInstructions(laughRight, null);
                return true;
            case DialogueType.LAUGHWRONG:
                Sherlock.Instance.PlaySequenceInstructions(laughWrong, null);
                return true;
            case DialogueType.HELPRIGHT:
                Sherlock.Instance.PlaySequenceInstructions(helpRight, null);
                return true;
            case DialogueType.HELPWRONG:
                Sherlock.Instance.PlaySequenceInstructions(helpWrong, null);
                return true;
            case DialogueType.CORRECT:
                return minigame.ContinueConversation(correct);
            case DialogueType.MISTAKE:
                return minigame.ContinueConversation(mistake);
            case DialogueType.CHOOSESOL:
                return minigame.ContinueConversation(chooseSol);
            case DialogueType.END:
                Sherlock.Instance.PlaySequenceInstructions(end, null);
                return true;
            case DialogueType.START:
                return minigame.ContinueConversation(start);
            default:
                return false;
        }

        return false;
    }
    /// <summary>
    /// Display dialogue based on dialogue type
    /// </summary>
    /// <returns>
    /// True if the dialogue was showed
    /// </returns>
    /// <param name='dialogueType'>
    /// Type of dialogue
    /// </param>
    public bool ShowDialogue(DialogueType dialogueType)
    {
        // Display dialogue depending on dialogue type
        switch (dialogueType) {
        case DialogueType.TOBLAKE:
            Sherlock.Instance.PlaySequenceInstructions (switchCharacter, null);
            return true;
        case DialogueType.TODRAKE:
            Sherlock.Instance.PlaySequenceInstructions (teachFriend, null);
            return true;
        case DialogueType.END:
            return minigame.ContinueConversation (end);
        case DialogueType.TUTORIAL:
            return minigame.ContinueConversation (tutorial[0]);
        }

        return false;
    }