예제 #1
0
    public static DialogueMap Open(DialogueManager manager, TextReader reader)
    {
        DialogueMap map = new DialogueMap(manager);

        map._instances = new Dictionary <string, DialogueInstance>();
        int    lnum = 0;
        string line;
        string currentDialogue = null;
        List <DialogueEntry> currentEntries = null;
        Author currentAuthor = null;

        while ((line = reader.ReadLine()) != null)
        {
            ++lnum;
            line = line.TrimStart();
            bool escape = false;
            if (line.StartsWith(EscapeChar))
            {
                line   = line.Substring(1);
                escape = true;
            }
            if (!escape && (line.StartsWith(CommentChar) || StringExt.IsNullOrWhitespace(line)))
            {
                continue;
            }
            else if (!escape && line.StartsWith(InstanceChar))
            {
                if (currentEntries != null)
                {
                    map._instances[currentDialogue] = new DialogueInstance(currentEntries, manager.GetComponent <UnityEngine.AudioSource>());
                }
                currentAuthor   = null;
                currentDialogue = line.Substring(1).Trim();
                currentEntries  = new List <DialogueEntry>();
            }
            else if (!escape && line.StartsWith(AuthorChar))
            {
                if (currentEntries == null)
                {
                    throw new IOException(string.Format("Invalid dialogue format at line {0}", lnum));
                }
                string author = line.Substring(1).Trim();
                currentAuthor = manager.GetAuthor(author);
            }
            else
            {
                if (currentEntries == null || currentAuthor == null)
                {
                    throw new IOException(string.Format("Invalid dialogue format at line {0}", lnum));
                }
                currentEntries.Add(new DialogueEntry(currentAuthor, line));
            }
        }
        if (currentEntries != null)
        {
            map._instances[currentDialogue] = new DialogueInstance(currentEntries, manager.GetComponent <UnityEngine.AudioSource>());
        }

        return(map);
    }
예제 #2
0
 void SetData()
 {
     authorDict = new Dictionary <string, Author>(StringComparer.OrdinalIgnoreCase);
     foreach (var author in authors)
     {
         authorDict[author.Key] = author;
     }
     defMap = new DialogueMap(this);
 }
예제 #3
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        isActive = false;
        interact = GameObject.Find("Interact").GetComponent <PointerController> ();
        buy      = GameObject.Find("Buy1").GetComponent <PointerController> ();
        yes      = GameObject.Find("DialogueButtonYes").GetComponent <PointerController> ();
        no       = GameObject.Find("DialogueButtonNo").GetComponent <PointerController> ();
        ok       = GameObject.Find("DialogueOkButton").GetComponent <PointerController> ();

        gameController  = GameObject.Find("GameController").GetComponent <GameController> ();
        ObjectiveStatus = 0;
        gameController.ChangeObjective("Leave Hospital");
        yes.getPressed();
        dialogueButtons.SetActive(false);

        dialogueMap = new DialogueMap();
    }
예제 #4
0
//	public DialogueMap dialogueMap {
//		get; private set;
//	}

    public void Load(int level)
    {
        if (level >= levels.Count)
        {
            /*GameWorld.success = false;
             * ScreenFader.QueueEvent(BackgroundRenderer.instance.SetSunBackground);
             * ScreenFader.StartFade(Color.clear, Color.black, 1.0f, delegate()
             *                    {
             *      LevelManager.instance.Level--;
             *
             *      //TODO: If something weird happens, this is why
             *      GameWorld.success = false;
             *      GroupManager.main.activeGroup = GroupManager.main.group["Epilogue"];
             *
             *      // Clear resources
             *      LevelManager.instance.Clear();
             *
             *      ScreenFader.StartFade(Color.black, Color.clear, 0.5f, delegate()
             *                            {
             *              GroupManager.main.activeGroup = GroupManager.main.group["Epilogue"];
             *
             *              AudioManager.PlaySFX("Menu Next");
             *      });
             * });*/
            //return;
        }
        level %= levels.Count;
        if (level < 0)
        {
            level += levels.Count;
        }

        Level = level;

        TmxMap      map;
        DialogueMap dialogue;

        if (tileMaps.ContainsKey(level))
        {
            map = tileMaps[level];
        }
        else
        {
            var name  = levels[level];
            var asset = Resources.Load <TextAsset>(name);
            using (var reader = new StringReader(asset.text)) {
                map = TmxMap.Open(reader);
            }
            tileMaps[level] = map;
        }
        if (dialogues.ContainsKey(level))
        {
            dialogue = dialogues[level];
        }
        else
        {
            var name = levels[level];
            var dia  = Resources.Load <TextAsset>("Dialogues/" + name);
            if (dia != null)
            {
                using (var reader = new StringReader(dia.text)) {
                    dialogue = DialogueMap.Open(Object.FindObjectOfType <DialogueManager>(), reader);
                }
            }
            else
            {
                dialogue = new DialogueMap(DialogueManager.instance);
            }
            dialogues[level] = dialogue;
        }

        Width  = map.Width;
        Height = map.Height;
        Camera.main.transform.position = CameraPosition;
        Camera.main.orthographicSize   = OrthographicSize;

        //	dialogueMap = dialogue;
        settings.dialogueMap = dialogue;
        loader.Load(map, settings);

        //Load map settings
        settings.minScore = map.Properties.GetInt("MinScore", 0);
        settings.maxScore = map.Properties.GetInt("MaxScore", 0);
        string nameIntro = map.Properties.GetTag("Intro", null);
        string nameOutro = map.Properties.GetTag("Outro", null);

        if (nameIntro != null)
        {
            settings.intro = settings.dialogueMap[nameIntro];
        }
        else
        {
            settings.intro = null;
        }
        if (nameOutro != null)
        {
            settings.outro = settings.dialogueMap[nameOutro];
        }
        else
        {
            settings.outro = null;
        }

        var hand = Object.FindObjectOfType <HandController>();

        if (hand != null)
        {
            hand.value = map.Properties.GetInt("Health", HandController.DefValue);
        }

        //string dialogueName;
        //if (!map.
    }