Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (isInSequence && Input.GetMouseButtonDown(0))
        {
            if (currentSequenceCount >= curDs.dialogues.Count)
            {
                currentSequenceCount = 0;
                isInSequence         = false;
                textHolder.SetActive(false);
                disableDialogueBar();
                if (curDs.questID != 0)
                {
                    qm.displayQuest(curDs.questID, curPlanet);
                }

                curDs     = null;
                curPlanet = null;
            }
            else
            {
                print(curDs.dialogues.Count);

                displayDialog(curDs.dialogues [currentSequenceCount].message);
                currentSequenceCount += 1;
            }
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 public void StartDialogue(DialogueSequence dialogues)
 {
     if (havingConversation && !isInterruptable)
     {
         if (dialogues.mustSpeak)
         {
             conversation.AddRange(dialogues.dialogues);
         }
         else
         {
             return;
         }
     }
     else
     {
         gameObject.SetActive(true);
         onDialogueStart.Invoke();
         Reset();
         conversation.AddRange(dialogues.dialogues);
         isInterruptable    = dialogues.interruptable;
         autoNext           = dialogues.autoScroll;
         havingConversation = true;
         Next();
     }
 }
Ejemplo n.º 3
0
 public virtual void StartDialogue(DialogueSequence sequence, Transform target)
 {
     player.GetComponent <movement>().SetTarget(target, false);
     dialogueController.GetComponent <DialogueController>().SetSequence(sequence);
     dialogueController.SetActive(true);
     // dialogue.SetActive(true);
 }
Ejemplo n.º 4
0
 public DialogueSegment2D()
 {
     Guid = Guid.NewGuid();
     Name = "New interaction";
     Description = "Add description";
     Prerequisites = new List<DialoguePrerequisite2D>();
     Dialogue = new DialogueSequence();
 }
Ejemplo n.º 5
0
 public void Broadcast(DialogueSequence sequence)
 {
     // Potentially items may be removed
     // "Remove items behind you instead of ahead of you" --Matt
     for (var i = _listeners.Count - 1; i >= 0; i--)
     {
         _listeners[i].OnEventBroadcast(sequence);
     }
 }
Ejemplo n.º 6
0
 // Use this for initialization
 public void StartDialogue(DialogueSequence dialogues)
 {
     gameObject.SetActive(true);
     conversation = dialogues.dialogues;
     autoNext     = dialogues.autoScroll;
     Reset();
     characterName.text = conversation[dialogueNumber].characterName;
     Next();
 }
    public void StartSequenceFromXML(TextAsset xmlDialogue)
    {
        ManagerScripts.instance.timeManager.ChangeGameState(TimeManager.GameTimeState.Talking);
        // Send XML through a parse and recieve a List<Dialogue> back
        List <Dialogue> sequence = DialogueSequence.Load(xmlDialogue.text).Dialogue;

        // Send the List<Dialogue> to DialogueDisplay
        ManagerScripts.instance.dialogueDisplay.StartDialogueSequence(sequence);
    }
Ejemplo n.º 8
0
    public static DialogueSequence Load(string xml)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(DialogueSequence));

        using (TextReader reader = new StringReader(xml))
        {
            DialogueSequence result = (DialogueSequence)serializer.Deserialize(reader);
            return(result);
        }
    }
Ejemplo n.º 9
0
 ConversationArgs(DialogueSequence dialogue)
 {
     this.Targets = new GameObject[0];
     this.Dialogue = dialogue;
     this.DoCamera = true;
     this.PlayImmediately = false;
     this.ClearOnClose = true;
     this.ActorMap = new StringMap();
     this.Context = new ContextData();
 }
Ejemplo n.º 10
0
    public void StartDialogue(DialogueSequence dialogue)
    {
        sentences.Clear();

        foreach (string sentence in dialogue.sentences)
        {
            sentences.Enqueue(sentence);
        }

        DisplayNextSentence();
    }
        public void SetDialogueSequence(DialogueSequence dialogueSequence)
        {
            _index            = 0;
            _dialogueSequence = dialogueSequence;
            _indexMax         = _dialogueSequence.dialogue.Count;
            SetCharacter(_dialogueSequence.leftCharacter, leftCharacterParent, out _leftCharacter);
            SetCharacter(_dialogueSequence.rightCharacter, rightCharacterParent, out _rightCharacter);
            ApplyCustomizations(_leftCharacter);
            ApplyCustomizations(_rightCharacter);

            HandleDialogueFrame();
            _listenForInput = true;
        }
Ejemplo n.º 12
0
    public static void StartSequence(string text, GameObject speaker = null, bool Skippable = false)
    {
        DialogueSequence ds = Instance.parseSequence(text);

        ds.Speaker = speaker;
        ds.AdvanceSequence();
        if (Skippable == true)
        {
            GameObject go = Instantiate(Instance.SkipTextPrefab);
            go.GetComponent <SkipText> ().SingleSequence = true;
            go.GetComponent <SkipText> ().toSkip         = ds.allDUnits [0];
        }
        Instance.m_currentSequences.Add(ds);
    }
Ejemplo n.º 13
0
    public virtual void InteractWithObject()
    {
        objectAudio.PlayOneShot(sfx);

        DialogueSequence dialogueToUse = timesInteracted <= 0 ? firstTimeDialogue : otherTimeDialogue;

        if (timesInteracted <= 0 && !GlobalStats.instance.PlayerInventory.HasItem(criticalItem))
        {
            dialogueToUse = noItemFirstTimeDialogue;
        }

        dialogueSource.SetDialogue(dialogueToUse);

        timesInteracted++;
    }
Ejemplo n.º 14
0
    public void displaySequence(DialogueSequence ds, Planets plane)
    {
        if (!isInSequence)
        {
            enableDialogueBar();
            isInSequence         = true;
            currentSequenceCount = 0;


            curDs = ds;
            displayDialog(ds.dialogues [currentSequenceCount].message);
            currentSequenceCount += 1;
            curPlanet             = plane;
        }
    }
Ejemplo n.º 15
0
    public void Play(string sequence_name, IDialogueSequenceEventHandler event_handler)
    {
        DialogueBoxInProgress = false;
        DialogueBox.Show();
        StateManager.SetState(State.Dialogue);
        MusicController.Current.SetVolume(0.25f);

        string json = Resources.Load <TextAsset>(sequence_name).text;

        Sequence         = DialogueSequence.ParseJSON(json);
        SequenceProgress = 0;

        EventHandler = event_handler;

        ReadNextPage();
    }
Ejemplo n.º 16
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (isActivated == false)
        {
            return;
        }

        if (collision.tag == playerTag)
        {
            DialogueSequence sequence = gameStateController.dialogueController.GetSequence("end");
            gameStateController.dialogueController.BeginSequence(sequence);

            gameStateController.dialogueController.onCloseDialogue.AddListener(() => {
                // is this what you call an ending?
                menuController.LoadScene(1);
            });
        }
    }
Ejemplo n.º 17
0
 static Item()
 {
     dialogueSequence = new DialogueSequence();
     dialogueSequence.Add("Item", "Hello there {Jitter,Color.Orange:Monet} how are you feeling today?");
 }
Ejemplo n.º 18
0
 public void PlayDialogue(DialogueSequence dialogueSequence)
 {
     _currentDialogueSequence = dialogueSequence;
     _currentDialogueSequence._currentIndex = 0;
     RunDialogue();
 }
Ejemplo n.º 19
0
    public void OnGUI()
    {
        if(seq.numberOfNodes != nodeNames.Count) // Everything is broken, panic
        {
            seq = new DialogueSequence();
            nodeNames = new List<string>();
            windows = new List<Rect>();
        }

        BeginWindows();
        if(createOpt) // Creating a new connection between nodes
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            // Labels
            GUILayout.Label("From Node");
            GUILayout.Label("To Node");
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            // Text fileds
            fromNode = GUILayout.TextField(fromNode, GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
            toNode = GUILayout.TextField(toNode, GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Text");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            optText = GUILayout.TextArea(optText, GUILayout.MinWidth(300), GUILayout.MinHeight(50));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if(GUILayout.Button("Create"))
            {
                seq.AddOption(fromNode, toNode, optText);
                fromNode = toNode = optText = null;
                createOpt = false;
            }
            if(GUILayout.Button("Cancel"))
            {
                fromNode = toNode = optText = null;
                createOpt = false;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else if(createNode) // Creating a new node
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Node Name: ", GUILayout.ExpandWidth(false));
            newNodeName = GUILayout.TextField(newNodeName, GUILayout.Width(250));
            GUILayout.EndHorizontal();
            GUILayout.Space(50);
            GUILayout.BeginHorizontal();
            if(GUILayout.Button("Create"))
            {
                if(!nodeNames.Contains(newNodeName))
                {
                    seq.AddNode(newNodeName, "Speaker", "Text");
                    windows.Add( new Rect(30,30, 200, 150));
                    nodeNames.Add(newNodeName);
                }

                newNodeName = null;
                createNode = false;

            }
            if(GUILayout.Button("Cancel"))
            {
                newNodeName = null;
                createNode = false;
            }

            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else // Viewing the tree
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Create Node")) {
                newNodeName = "New Node";
                createNode = true;
            }
            if(GUILayout.Button("Add Option"))
            {
                createOpt = true;
                fromNode = "From";
                toNode = "To";
                optText = "Text";
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            export = GUILayout.TextField(export, GUILayout.Width(200));
            if(GUILayout.Button("Export to File"))
                ExportToFile(export);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            DrawAllLines();

            for(int i = 0; i < nodeNames.Count; i++)
            {
                windows[i] = GUILayout.Window(i, windows[i], DrawNodeWindow, nodeNames[i]);
            }

        }
        EndWindows();
    }
Ejemplo n.º 20
0
 public ConversationArgs(GameObject target, DialogueSequence dialogue, ContextData context, bool playImmediately)
     : this(target, dialogue)
 {
     this.Context = context;
     this.PlayImmediately = playImmediately;
 }
Ejemplo n.º 21
0
 public static ConversationArgs OpenSegmentArgs(GameObject target, DialogueSequence dialogue, ContextData context)
 {
     return new ConversationArgs(target, dialogue, context, true, false);
 }
Ejemplo n.º 22
0
 public void StartDialogue(DialogueSequence sequence)
 {
     hasFinished = false;
     dialogueController.GetComponent <DialogueController>().SetSequence(sequence);
     dialogueController.SetActive(true);
 }
Ejemplo n.º 23
0
 public int AddSubDialogue(DialogueSequence dialogue, int actorID = 0)
 {
     var e = this.dialogue.AddNewDialogueElement(dialogue);
     e.ActorIndex = actorID;
     ResolveNextID(e);
     return e.ID;
 }
Ejemplo n.º 24
0
 public ConversationArgs(GameObject target, DialogueSequence dialogue, ContextData context)
     : this(target, dialogue)
 {
     this.Context = context;
 }
Ejemplo n.º 25
0
 public void SetDialogue(DialogueSequence sequence)
 {
     dialogueSource.EnableDialogue(sequence.lines);
 }
Ejemplo n.º 26
0
 public ConversationArgs(GameObject target, DialogueSequence dialogue)
     : this(dialogue)
 {
     this.Targets = new GameObject[1];
     this.Targets[0] = target;
 }
Ejemplo n.º 27
0
    public DialogueSequence parseSequence(string text, int startingChar = 0, int indLevel = 0, DialogueSequence parentSeq = null)
    {
        DialogueSequence newSeq = new DialogueSequence();

        newSeq.parentSequence = parentSeq;
        List <DialogueUnit> subDS = new List <DialogueUnit> ();

        DialogueUnit du = new DialogueUnit {
        };

        subDS.Add(du);
        string lastText             = "";
        string lastAnim             = "none";
        int    i                    = startingChar;
        bool   full                 = false;
        int    specialSequenceDepth = 0;

        while (i < text.Length)
        {
            char lastC = text.ToCharArray() [i];
            newSeq.rawText += lastC;
            du.RawText     += lastC;
            if (lastC == '<')
            {
                specialSequenceDepth++;
            }
            else if (lastC == '>')
            {
                specialSequenceDepth--;
            }
            if (lastText.Length == 0 && lastC == ' ')
            {
            }
            else if (lastText.Length == 0 && lastC == '-')
            {
                DialogueSequence newS = parseSequence(text, i, indLevel + 1, newSeq);
                i += newS.numChars;
            }
            else if (lastC == '~')
            {
                full = true;
            }
            else if (specialSequenceDepth == 0 && (lastC == '\n' || lastC == '|'))
            {
                if (lastText.Length > 0)
                {
                    if (lastAnim == "none")
                    {
                        du.addTextbox(lastText, full);
                    }
                    else
                    {
                        du.addTextbox(lastText, lastAnim, full);
                    }
                    full = false;
                }
                lastText = "";
            }
            else
            {
                lastText += lastC;
            }
            newSeq.numChars += 1;
            i += 1;
        }
        if (lastAnim == "none")
        {
            du.addTextbox(lastText, full);
        }
        else
        {
            du.addTextbox(lastText, lastAnim, full);
        }
        subDS.Add(du);
        newSeq.allDUnits = subDS;
        return(newSeq);
    }
Ejemplo n.º 28
0
 public ConversationArgs(GameObject[] targets, DialogueSequence dialogue)
     : this(dialogue)
 {
     this.Targets = targets;
     this.DoCamera = false;
 }
 public void OnEventBroadcast(DialogueSequence sequence) => unityEvent.Invoke(sequence);
Ejemplo n.º 30
0
 public static ConversationArgs ExitArgs(GameObject target, DialogueSequence dialogue, bool clearOnClose = true)
 {
     return new ConversationArgs(target, dialogue, null, false, clearOnClose);
 }
Ejemplo n.º 31
0
    void Update()
    {
        if (GameManager.singleGame)
        {
            dialogueText     = transform.GetChild(0).gameObject.GetComponent <TextMeshProUGUI>();
            dialogueSequence = transform.GetChild(0).gameObject.GetComponent <DialogueSequence>();
        }
        else
        {
            dialogueText     = transform.GetChild(1).gameObject.GetComponent <TextMeshProUGUI>();
            dialogueSequence = transform.GetChild(1).gameObject.GetComponent <DialogueSequence>();
        }

        if (dialogueText.text == " " || dialogueText.text == "")
        {
            if (sprRenderer.enabled)
            {
                sprRenderer.enabled = false;

                if (pl1)
                {
                    pl1.GetComponent <PlayerController>().enabled = true;
                }

                if (inventoryPl1)
                {
                    inventoryPl1.SetActive(true);
                }

                if (pl2)
                {
                    pl2.GetComponent <PlayerController>().enabled = true;
                }

                if (inventoryPl2)
                {
                    inventoryPl2.SetActive(true);
                }

                if (minimap)
                {
                    minimap.SetActive(true);
                }

                Subtitles.Enable();
            }
        }
        else
        {
            sprRenderer.enabled = true;

            if (pl1)
            {
                pl1.GetComponent <PlayerController>().enabled = false;
            }

            if (inventoryPl1)
            {
                inventoryPl1.SetActive(false);
            }

            if (pl2)
            {
                pl2.GetComponent <PlayerController>().enabled = false;
            }

            if (inventoryPl2)
            {
                inventoryPl2.SetActive(false);
            }

            if (minimap)
            {
                minimap.SetActive(false);
            }

            Subtitles.Disable();

            if (dialogueSequence.dialogueNo >= 0)
            {
                checkForDialogueStringTags(dialogueSequence.dialogues[dialogueSequence.dialogueNo]);
            }
        }

        if ((Input.GetButtonDown(proceedInput)) &&
            sprRenderer.enabled)
        {
            if (aud != null && TogglesValues.sound)
            {
                aud.PlayOneShot(proceedSound);
            }

            dialogueSequence.dialogueNo++;

            checkForDialogueStringTags(dialogueSequence.dialogues[dialogueSequence.dialogueNo]);
        }
    }
Ejemplo n.º 32
0
 public void SetSequence(DialogueSequence seq)
 {
     sequence      = seq;
     sequenceIndex = 0;
     UpdateDisplay();
 }
Ejemplo n.º 33
0
 public void SetDialogueSequence(DialogueSequence dialogueSequence)
 {
     this.dialogueSequence = dialogueSequence;
     _dialogueIndex        = 0;
 }
Ejemplo n.º 34
0
    /// <summary>
    /// Turns the given string into a <see cref="DialogueSequence"/> and queues it
    /// </summary>
    public void QueueDialogue(string dialogue)
    {
        DialogueSequence seq = new DialogueSequence(dialogue, this);

        EventManager.Instance.RaiseSequenceGameEvent(EventConstants.ON_SEQUENCE_QUEUE, seq);
    }
Ejemplo n.º 35
0
 public ConversationArgs(GameObject target, DialogueSequence dialogue, ContextData context, bool playImmediately, bool clearOnClose)
     : this(target, dialogue, context,playImmediately)
 {
     ClearOnClose = clearOnClose;
 }