Пример #1
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");
    }
Пример #2
0
    public void Update()
    {
        if (pause == false)
        {
            timevar += Time.deltaTime;
            dayTime  = (int)timevar;

            if (waitingForOpen == true)
            {
                if (waitingTime > 0)
                {
                    waitingTime -= Time.deltaTime;
                }
                else
                {
                    waitingForOpen = false;
                    notification.SetActive(false);
                    currentDayQuestion++;
                    dialogue.Clear();
                }
            }
            else
            {
                CheckTimeForQuestion();
            }
            CheckForEndDay();
            CalculateTime();
        }
    }
 public void CompleteLevel()
 {
     if (level + 1 == levels.Length)
     {
         worspace.SetActive(true);
         worspace.transform.SetAsLastSibling();
     }
     else
     {
         GameLevel currentLevel = levels[level];
         if (currentLevel.cutscene)
         {
             dialogue.Clear();
             level++;
             gameplay.playing   = false;
             currentLevel       = levels[level];
             LevelNameText.text = currentLevel.levelName;
         }
         else
         {
             GameObject[] destroyables = GameObject.FindGameObjectsWithTag("Respawn");
             foreach (GameObject game in destroyables)
             {
                 GameObject.Destroy(game);
             }
             CharacterController character = FindObjectOfType <CharacterController>();
             GameObject.Destroy(character);
             level++;
             gameplay.playing   = false;
             currentLevel       = levels[level];
             LevelNameText.text = currentLevel.levelName;
             openGame();
         }
     }
 }
Пример #4
0
    protected virtual void Start()
    {
        dialogueRunner.Clear(); // Clear all loaded nodes upon start. This is needed, as the dialogueRunner will try to load the same nodes when entering a scene multiple times.
        if (yarnScriptToLoad != null)
        {
            dialogueRunner.Add(yarnScriptToLoad);
        }

        player         = GameObject.Find("Player");
        playerAnimator = player.GetComponent <Animator>();
    }
Пример #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
        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();
            }
        }
 public void Clear()
 {
     _dialogeRunner?.Clear();
 }