コード例 #1
0
    // Parses a Text Event
    int parseTextEvent(int start_pos, string text, DialogueItem d_item, StringBuilder parsed)
    {
        int    end_pos = text.IndexOf(']', start_pos);
        int    eq_pos  = text.IndexOf('=', start_pos);
        string evt;

        string[] opt;
        if (eq_pos == -1 || eq_pos > end_pos)           // if no '='
        {
            evt = text.Substring(start_pos + 1, end_pos - start_pos - 1);
            opt = new string[0];
        }
        else
        {
            evt = text.Substring(start_pos + 1, eq_pos - start_pos - 1);
            opt = text.Substring(eq_pos + 1, end_pos - eq_pos - 1).Split(opt_delim);
        }
        if (d_item.text_events [parsed.Length] == null)
        {
            d_item.text_events [parsed.Length] = new List <TextEvent> ();
        }
        d_item.text_events [parsed.Length].Add(new TextEvent(evt, opt));
        //Debug.Log ("  text_event:" + evt + ":" + opt.Aggregate("", (acc, next) => acc + "," + next));
        return(end_pos);
    }
コード例 #2
0
 void Awake()
 {
     displayedDialogue   = new DialogueItem();
     sentences           = new Queue <DialogueItem>();
     characterController = FindObjectOfType <PlayerController>();
     codeChecker         = FindObjectOfType <CodeChecker>();
 }
コード例 #3
0
        private void HandleCurrentContextChanged(object sender, EventArgs e)
        {
            Dialogue currentDialogue = FindCurrentDialogue();

            // Reset repetitions count for dialogues, unless actively prevented:
            if (currentDialogue != null)
            {
                currentDialogue.ResetRepetitionCount();
                if (workingMemory.CurrentID == "") // If no ID has been set, then just start from the beginning.
                {
                    workingMemory.CurrentID = currentDialogue.DialogueItemList[0].ID;
                }
                else
                {
                    DialogueItem currentDialogueItem = FindCurrentDialogueItem();
                    PropertyInfo timeoutProperty     = currentDialogueItem.GetType().GetProperty(AgentConstants.TIMEOUT_INTERVAL_PROPERTY_NAME);
                    if (timeoutProperty != null)
                    {
                        dialogueItemTimer.Stop(); // Just in case it was running previously.
                        double timeoutInterval = (double)timeoutProperty.GetValue(currentDialogueItem);
                        dialogueItemTimer.Run(timeoutInterval);
                    }
                }
            }
        }
コード例 #4
0
 private void LoadNextDialogue()
 {
     m_current_dialogue = m_dialogues.Dequeue();
     m_name_text.text   = m_current_dialogue.GetTalkerName();
     m_dialogue_image.overrideSprite = m_current_dialogue.GetTalkerImage();
     m_dialogue_text.text            = m_current_dialogue.NextTextSegment();
 }
コード例 #5
0
    // Show input options when text is done scrolling
    IEnumerator showInput(DialogueItem d_item, DialogueBox d_box, Coroutine d_box_init)
    {
        yield return(d_box_init);                                   // Wait for d_box to finish setting up

        yield return(new WaitUntil(() => d_box.cr_scroll == null)); // Wait for scroll to end

        input_field.gameObject.SetActive(true);
        input_field.ActivateInputField();
        //spacebar_icon_vn.SetActive(true);
        curr_spacebar_animator.Play("anim_key_spacebar_no");
        if (d_item.input_display != null)
        {
            input_display = Instantiate(d_item.input_display, transform);
        }
        if (d_item.input_options.Length > 0)
        {
            switch (d_item.input_options.Length)
            {
            case 2:
                input_display_C.SetActive(false);
                break;

            case 3:
                input_display_C.SetActive(true);
                break;
            }
            populateChoices();
            input_display_choices.SetActive(true);
        }
    }
コード例 #6
0
    void CreateControl(DialogueItem item = null)
    {
        DialogueItem dialogueItem = item;

        if (item == null)
        {
            dialogueItem    = ScriptableObject.CreateInstance <DialogueItem> ();
            dialogueItem.id = dialogueCount++;
        }

        DialogueItemWindow newWindow = new DialogueItemWindow(dialogueItem, this);

        //Default Dialogue Window Rect Size Reference for Zooming
        newWindow.orgRect = new Rect(
            newWindow.rect.x,
            newWindow.rect.y,
            newWindow.rect.width,
            newWindow.rect.height
            );
        //
        //Adapt to zoomed size if adding a window after zooming
        newWindow.rect = new Rect(
            newWindow.rect.x,
            newWindow.rect.y,
            newWindow.rect.width * _zoomLevel,
            newWindow.rect.height * _zoomLevel
            );
        //
        controls.Add(newWindow);
    }
コード例 #7
0
    private void MouseOver(GameObject gameObject)
    {
        switch (gameObject.tag)
        {
        case "Interactable":
            gameObject.SendMessage("Over");
            if (Input.GetMouseButtonUp(0))
            {
                InventoryItem item = gameObject.GetComponent <InventoryItem>();
                if (item != null)
                {
                    inventory.AddItem(item);
                }
            }
            break;

        case "NPC":
            gameObject.SendMessage("Over");
            if (Input.GetMouseButtonUp(0))
            {
                DialogueItem item = gameObject.GetComponent <DialogueItem>();
                if (item != null)
                {
                    dialogue.StartDialogue(item);
                }
            }
            break;
        }
    }
コード例 #8
0
 private bool IsReadyForCompletion(DialogueItem dialogueItem)
 {
     return(dialogueItem
            .GetValidLines()
            .Select(x => x.GetAssociatedQuestModel())
            .Where(x => x != null && Quest.IsQuestEventReadyForCompletion(x))
            .Count() > 0);
 }
コード例 #9
0
ファイル: Dialogue.cs プロジェクト: Garciaj007/Game154
 public void Display(DialogueItem item)
 {
     if (item != null)
     {
         name.text      = item.name;
         sentences.text = item.sentences;
     }
 }
コード例 #10
0
    DialogueItem item;  // Current item in the slot

    // Add item to the slot
    public void AddItem(DialogueItem newItem)
    {
        item = newItem;

        info.text    = item.infoGained;
        info.enabled = true;
        //removeButton.interactable = true;
    }
コード例 #11
0
    // Clear the slot
    public void ClearSlot()
    {
        item = null;

        info.text    = "";
        info.enabled = false;
        //removeButton.interactable = false;
    }
コード例 #12
0
ファイル: DialogueSystem.cs プロジェクト: jono-m/GameJams
 public void Enqueue(DialogueItem i)
 {
     queue.Enqueue(i);
     if (queue.Count == 1)
     {
         Present();
     }
 }
コード例 #13
0
 private void InitText()
 {
     displayedDialogue = sentences.Dequeue();
     displayedDialogue.SelectedIndex = 0;
     StopCoroutine("DisplaySentence");
     dialogueText.text = "";
     StartCoroutine("DisplaySentence");
     DisplayOptions();
 }
コード例 #14
0
    public void StartDialogue(DialogueItem dialogue)
    {
        dialogue.OnStartDialogue();

        if (DialogueStarted != null)
        {
            DialogueStarted(this, new DialogueItemEventArgs(dialogue));
        }
    }
コード例 #15
0
    // Remove an item
    public void Remove(DialogueItem item)
    {
        info.Remove(item);

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }
コード例 #16
0
    public void CreateReward(List <Item> reward)
    {
        DialogueItem i = Instantiate <DialogueItem>(itemPrefab, content.transform);

        i.SetText("");
        dialogues.Add(i);
        item.AddItems(ItemLibrary.GenerateAmounts(reward, 500)); //placeholder value
        item.SetText("Yours for the taking...");
    }
コード例 #17
0
    public DialogueItemWindow(DialogueItem dialogueItem, DialogueEditor parent)
    {
        _dialogue = dialogueItem;
        _parent   = parent;

        //Set default rect if its unitialized
        if (_dialogue.rect == Rect.zero)
        {
            _dialogue.rect = new Rect(10, 10, 200, 150);
        }
    }
コード例 #18
0
    // Fill the choice display boxes with current options text
    public void populateChoices()
    {
        Text[]       choiceText = input_display_choices.GetComponentsInChildren <Text>();
        DialogueItem d_item     = curr_dialogue.GetComponents <DialogueItem> () [curr_line];
        int          j          = 0;

        for (int i = 1; (i < choiceText.Length) && (j < d_item.input_options.Length); i = i + 2)
        {
            choiceText [i].text = d_item.input_options[j];
            ++j;
        }
    }
コード例 #19
0
    // Methods used for Dialog
    private void DialogueStarted(object sender, DialogueItemEventArgs e)
    {
        _currentDialogue = e.Dialogue;
        _sentences.Clear();

        foreach (DialogueSentence sentance in _currentDialogue.Sentences)
        {
            _sentences.Enqueue(sentance);
        }

        _dialogPanel.SetActive(true);
        DisplayNextSentence();
    }
コード例 #20
0
    private void EndDialogue()
    {
        speaking          = false;
        displayedDialogue = new DialogueItem();
        dialoguePanel.SetActive(false);
        GameObject teleporter = GameObject.Find("Teleporter");

        if (teleporter != null)
        {
            GameObject door = GameObject.Find("Door");
            door.SetActive(false);
        }
    }
コード例 #21
0
ファイル: DialogueSystem.cs プロジェクト: jono-m/GameJams
    private void Present()
    {
        dialogueBox.SetActive(true);
        DialogueItem d = queue.Peek();

        textField.text   = d.text;
        buttonField.text = d.buttonText;
        advanceButton.gameObject.SetActive(buttonField.text != "");
        if (d.time > 0)
        {
            StartCoroutine(AdvanceAfter(d.time));
        }
    }
コード例 #22
0
    // Parses an effect's ending tag, and matches with top of effect stack
    void parseEffectEnd(int start_pos, string text, DialogueItem d_item, StringBuilder parsed)
    {
        int          end_pos = text.IndexOf('\\', start_pos) - 1;
        string       fx_name = text.Substring(start_pos, end_pos - start_pos + 1);
        FXTextEffect top     = effect_stack.Pop();

        if (text_effect_map [fx_name].GetType() != top.GetType())
        {
            Debug.LogException(new System.Exception("Mismatched FXTextEffect tags:" + fx_name));
        }
        top.chars [1] = parsed.Length;
        d_item.fx_text_effects.Add(top);
    }
コード例 #23
0
    /// <summary>
    /// Retrieves all Diagloue items from dialogue txt files
    /// </summary>
    public static void LoadDialogueItems()
    {
        DialogueItems = new Dictionary <string, DialogueItem>();

        //Get each text file in the primary objectives folder
        TextAsset[] DialogueList = Resources.LoadAll <TextAsset>("Text/Dialogue");

        //Loop through each file in folder
        foreach (TextAsset txt in DialogueList)
        {
            DialogueItem newDialogue = LoadDialogueFromText(txt);
            DialogueItems.Add(txt.name, newDialogue);
        }
    }
コード例 #24
0
    // Add a new item if enough room
    public void Add(DialogueItem item)
    {
        if (info.Contains(item))
        {
            return;
        }

        info.Add(item);

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }
コード例 #25
0
        private DialogueItem FindCurrentDialogueItem()
        {
            Dialogue currentDialogue = FindCurrentDialogue();

            if (currentDialogue != null)
            {
                DialogueItem currentDialogueItem = currentDialogue.DialogueItemList.Find(d => d.ID == workingMemory.CurrentID);
                return(currentDialogueItem);
            }
            else
            {
                return(null);
            }
        }
コード例 #26
0
        public DialogueProperties(DialogueItem di)
        {
            InitializeComponent();

            current = di;

            portraitSource.Text = current.portrait;
            AttemptSetPortrait(portraitSource.Text);

            dialogue.Text = current.text;

            entryPoint.Checked = current.entry;

            loadOptions();
        }
コード例 #27
0
    // Parses dialogue item, returning updated text and modifying fields
    public string parse(DialogueItem d_item, DialogueBox d_box)
    {
        //Debug.Log ("parse:" + d_item.text);
        StringBuilder parsed = new StringBuilder();         // Processes string
        string        text   = substituteMacros(d_item.text);

        d_item.fx_text_effects = new List <FXTextEffect> ();
        d_item.text_events     = new List <TextEvent> [text.Length];
        bool tag = false;         // Are we parsing a tag?
        int  i   = 0;

        for (; i < text.Length; ++i)
        {
            char c = text [i];
            if (c == '|')               // FXTextEffect start tag
            {
                tag = !tag;
                if (tag)
                {
                    parseEffectStart(i + 1, text, parsed, d_box);
                }
            }
            else if (c == '\\')                 // FXTextEffect end tag
            {
                tag = !tag;
                if (tag)
                {
                    parseEffectEnd(i + 1, text, d_item, parsed);
                }
            }
            else if (c == '[' || c == ']')                 // Text Event
            {
                i = parseTextEvent(i, text, d_item, parsed);
            }
            else if (!tag)
            {
                if (c == '’')
                {
                    parsed.Append("'");
                }
                else
                {
                    parsed.Append(c);
                }
            }
        }
        return(parsed.ToString());
    }
コード例 #28
0
    void OnGUI()
    {
        GUIStyle a = skin.button;

        if (answerNode.questions.Length != 0)
        {
            for (int i = 0; i < answerNode.questions.Length; i++)
            {
                if (GUI.Button(new Rect(Screen.width / 2 - Screen.width / 4, 600 + i * 50, Screen.width / 2, 50), answerNode.questions[i].text, a))
                {
                    answerNode = answerNode.questions[i].question;
                    UpdateUi();
                }
            }
        }
    }
コード例 #29
0
    void OnGUI()
    {
        GUIStyle a = skin.button;

        if (answerNode.questions.Length != 0)
        {
            for (int i = 0; i < answerNode.questions.Length; i++)
            {
                if (GUI.Button(new Rect(Screen.width / 2 - Screen.width / 10, Screen.height - Screen.height / 5 + i * 45, Screen.width / 5, 45), answerNode.questions[i].text, a))
                {
                    answerNode = answerNode.questions[i].question;
                    UpdateUi();
                }
            }
        }
    }
コード例 #30
0
        public DialogueEventProperties(DialogueItem di)
        {
            InitializeComponent();

            current = di;

            switch (di.eventType)
            {
            case "GiveItem":
                giveItemPanel.Visible = true;

                LoadItemOptions();
                break;

            case "LoadMap":
                loadMapPanel.Visible = true;

                LoadMapOptions();
                break;

            case "AffectPlayer":
                affectPlayerPanel.Visible = true;

                LoadAffectPlayerOptions();
                break;

            case "SpawnNPC":
                spawnNPCPanel.Visible = true;

                LoadSpawnNPCOptions();
                break;

            case "ShowQuest":
                showQuestPanel.Visible = true;

                loadShowQuestOptions();
                break;
            }

            repeatable.Checked = current.repeatable;

            nextIndex.Value  = current.options[0].next;
            nextIndex1.Value = current.options[1].next;
        }