Пример #1
0
    // Update is called once per frame
    void Update()
    {
        /*if $gettingthehint is over 3, tell armfollow that touching is fine now
         * use eventmanager on armfollow, broadcast when you touch
         * depending on your $busted value it'll send you to the appropriate dialogue branch
         *
         */
        /*if (dialogue.currentNodeName != stayingNode)
         * {
         *  Debug.Log("staying node");
         *  if (visitedNodes.Contains(dialogue.currentNodeName))
         *  {
         *      stayingNode = dialogue.currentNodeName;
         *      Debug.Log("setting true");
         *      storage.SetValue("$hasvisited", new Yarn.Value(true));
         *  }
         *  else
         *  {
         *      Debug.Log("setting variable false");
         *      storage.SetValue("$hasvisited", new Yarn.Value(false));
         *  }
         * }*/
        if ((int)storage.GetValue("$busted").AsNumber == 5)
        {
            dialogue.Stop();

            Services.SceneStackManager.Swap <EndScreen>();
        }
        if (storage.GetValue("$askedout").AsBool)
        {
            dialogue.Stop();
            Services.GameManager.dateSuccess = true;
            Services.SceneStackManager.Swap <EndScreen>();
        }
    }
Пример #2
0
    public void CallTextBoxStringInterrupt(string text)
    {
        string prefix =
            @"title:Inline
---
";
        string node = prefix + text + System.Environment.NewLine + "===";

        dialogueRunner.Stop();
        dialogueRunner.Clear();

        dialogueRunner.AddScript(node);
        // Load all scripts
        if (dialogueRunner.sourceText != null)
        {
            foreach (var source in dialogueRunner.sourceText)
            {
                // load and compile the text
                dialogueRunner.AddScript(source.text);
            }
        }

        Clean();
        dialogueRunner.StartDialogue("Inline");
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        //if other is player
        if (other.gameObject.CompareTag("Player"))
        {
            if (!string.IsNullOrEmpty(talkToNode))
            {
                if (dialogueCanavas != null)
                {
                    //move the Canvas to the object and off set
                    dialogueCanavas.transform.SetParent(transform.parent.transform); // use the root to prevent scaling
                    //dialogueCanavas.GetComponent<RectTransform>().anchoredPosition3D = transform.parent.TransformVector(PostionSpeachBubble);
                    dialogueCanavas.GetComponent <RectTransform>().anchoredPosition3D = PostionSpeachBubble;
                    dialogueCanavas.GetComponent <RectTransform>().localEulerAngles   = RotationSpeechBubble;
                }

                if (dialogueRunner.IsDialogueRunning)
                {
                    dialogueRunner.Stop();
                }
                Debug.Log("start dialogue");
                dialogueRunner.StartDialogue(talkToNode);
            }
        }
    }
Пример #4
0
    private IEnumerator ChangeSceneCoroutine(string sceneToChangeTo, float time)
    {
        // Stop the dialogue
        dialogueRunner.Stop();

        cgHandler.SetCg(CgHandler.BlackScreenSpriteName, time);

        yield return(new WaitForSecondsRealtime(time + 0.5f));

        Debug.Log($"Loading new scene: {sceneToChangeTo}");

        SceneManager.LoadScene(sceneToChangeTo);
    }
Пример #5
0
    IEnumerator OutputRoutine(string url)
    {
        dialogueRunner.Stop();
        while (dialogueRunner.isDialogueRunning)
        {
            yield return(0);
        }
        dialogueRunner.Clear();
        var loader = new WWW(url);

        yield return(loader);

        currentFilePath = url;
        previousFilePaths.Add(url);
        dialogueRunner.AddScript(loader.text);

        // save path into playerprefs
        if (previousFilePaths.Contains(currentFilePath))
        {
            Debug.Log("detecting duplicate filepaths in file history...");
            previousFilePaths.RemoveAll(x => x == currentFilePath);
        }
        previousFilePaths.Insert(0, currentFilePath);

        PlayerPrefs.DeleteAll();
        PlayerPrefs.Save();
        for (int i = 0; i < previousFilePaths.Count; i++)
        {
            PlayerPrefs.SetString(prefsKey + i.ToString(), previousFilePaths[i]);
        }
        PlayerPrefs.Save();

        yield return(0);

        StartCurrentFile();
    }
Пример #6
0
    public void RunNode(string nodeToRun)
    {
        var tags = "";

        // tage a look at those tags
        if (DR.GetTagsForNode(nodeToRun) != null)
        {
            tags = string.Join(" ", DR.GetTagsForNode(nodeToRun));
        }
        if (DR.CurrentNodeName != null)
        {
            //Debug.Log("Got tags");
            var tagsCurrent = string.Join(" ", DR.GetTagsForNode(DR.CurrentNodeName));
            if (tags.Contains("main")) // MAIN is never interrupted and interrupts anything else, including Main
            //Debug.Log("running MAIN dialogue");
            {
                DR.Stop();
                DR.StartDialogue(nodeToRun);
            }
            else if (tags.Contains("world")) // WORLD is only interrupted by Main and World, only interrupts Sub and World
            {
                if (DR.IsDialogueRunning && tagsCurrent.Contains("main"))
                {
                    return;
                }
                else
                {
                    //Debug.Log("running WORLD dialogue");
                    DR.Stop();
                    DR.StartDialogue(nodeToRun);
                }
            }
            else if (tags.Contains("sub")) // SUB is interrupted by anything, and does not interrupt anything
            {
                if (DR.IsDialogueRunning)
                {
                    return;
                }
                else
                {
                    // Debug.Log("running SUB dialogue");
                    int randomRoll = Random.Range(0, 4);
                    Debug.Log("Rolled: " + randomRoll);
                    if (randomRoll == 0)
                    {
                        DR.Stop();
                        DR.StartDialogue(nodeToRun);
                    }
                }
            }
            else
            {
                if (tagsCurrent.Contains("main") || tagsCurrent.Contains("world"))
                {
                    return;
                }
                else
                {
                    DR.StartDialogue(nodeToRun);
                }
            }
        }
        else
        {
            if (tags.Contains("sub"))
            {
                int randomRoll = Random.Range(0, 4);
                Debug.Log("Rolled: " + randomRoll);
                if (randomRoll == 0)
                {
                    DR.StartDialogue(nodeToRun);
                }
            }
            else
            {
                DR.StartDialogue(nodeToRun);
            }
        }
    }
Пример #7
0
    public override IEnumerator RunCommand(Yarn.Command command)
    {
        string[] commandSplit = command.text.Split(' ');

        if (commandSplit[0] == "hideui")
        {
            dialogueUIFrame.SetActive(false);
            yield return(null);
        }
        else if (commandSplit[0] == "wait")
        {
            float seconds = 0.0f;
            float.TryParse(commandSplit[1], out seconds);
            yield return(new WaitForSeconds(seconds));
        }
        else if (command.text == "protag_passed_out_eyes_closed")
        {
            player.AnimatePassedOut();
            yield return(null);
        }
        else if (command.text == "protag_passed_out_eyes_open")
        {
            player.AnimatePassedOutEyesOpen();
            yield return(null);
        }
        else if (command.text == "protag_idle")
        {
            player.AnimateIdle();
            yield return(null);
        }
        else if (command.text == "protag_still")
        {
            player.AnimateStill();
            yield return(null);
        }
        else if (command.text == "protag_smoke")
        {
            Debug.Log("dialogue says to smoke");
            player.AnimateSmoking();
            yield return(null);
        }
        else if (command.text == "protag_vom")
        {
            yield return(player.AnimateVom());
        }
        else if (command.text == "logan_put_out_cig")
        {
            yield return(logan.AnimatePutOutCig());
        }
        else if (command.text == "logan_pull_out_gun")
        {
            yield return(logan.AnimatePullOutGun());
        }
        else if (command.text == "loop")
        {
            dialogueUIFrame.SetActive(false);
            runner.Stop();
            yield return(gameCoordinator.ShootAndLoop());
        }
        else if (command.text == "win")
        {
            dialogueUIFrame.SetActive(false);
            runner.Stop();
            yield return(gameCoordinator.Win());
        }
    }
Пример #8
0
 public void Stop()
 => DialogueRunner.Stop();
Пример #9
0
        IEnumerator OutputRoutine(string url)
        {
            dialogueRunner.Stop();
            while (dialogueRunner.isDialogueRunning)
            {
                yield return(0);
            }
            dialogueRunner.Clear();
            var loader = new WWW(url);

            yield return(loader);

            currentFilePath = url;
            previousFilePaths.Add(url);

            // try to add the script... if there are compile errors, we'll want to remember them for later
            var exceptions = new List <string>();

            try {
                dialogueRunner.AddScript(loader.text);
            } catch (Exception ex) {
                // to be extra helpful, let's show an excerpt from the broken script
                // 10 September 2017 -- OH NO, turns out we can't actually do this yet, due to how DialogueRunner works
                //                      I'll just leave this here, maybe investigate later

                /*
                 * if( ex.Message.StartsWith( "In file <input>: Error parsing node " ) ) {
                 *      // extract node name
                 *      var node = ex.Message.Substring( 36 ).Split( ':' )[0];
                 *      // extract line number
                 *      var lineNumberString = ex.Message.Split( new string[] {" Line ", ":"}, StringSplitOptions.None )[3];
                 *      int lineNumber = -1;
                 *      if( int.TryParse( lineNumberString, out lineNumber ) ) {
                 *              // OH NO, turns out if it's broken, we can't actually get node data from DialogueRunner
                 *              // I guess we can't actually do this, for now
                 *      }
                 * }
                 */

                exceptions.Add(ex.Message);
            }
            // if we did have compile errors, we'll want to do other stuff (e.g. don't let user press Play button)
            noCompileErrors = exceptions.Count == 0;

            // save path into playerprefs
            if (previousFilePaths.Contains(currentFilePath))
            {
                Debug.Log("detecting duplicate filepaths in file history...");
                previousFilePaths.RemoveAll(x => x == currentFilePath);
            }
            previousFilePaths.Insert(0, currentFilePath);

            PlayerPrefs.DeleteAll();
            PlayerPrefs.Save();
            for (int i = 0; i < previousFilePaths.Count; i++)
            {
                PlayerPrefs.SetString(prefsKey + i.ToString(), previousFilePaths[i]);
            }
            PlayerPrefs.Save();

            yield return(0);

            // validate and analyze files
            // TODO: add support for multiple files
            var scriptData = new Dictionary <string, string>();

            scriptData.Add(Path.GetFileNameWithoutExtension(currentFilePath), loader.text);
            validator.StartMain(scriptData, exceptions);

            // load the file now (or try to!)
            if (noCompileErrors)
            {
                StartCurrentFile();
            }
        }
Пример #10
0
 public void StartNewNode(string s)
 {
     dr.Stop();
     dr.StartDialogue(s);
 }
 public void StopDialogue()
 {
     _dialogeRunner?.Stop();
 }
Пример #12
0
        public override void Stop()
        {
            DialogueRunner.Stop();

            DialogueManager.OnDialogueEnded();
        }