Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            Commands.Enabled = false;

            int          initGAccess  = GAccess.SolidTag.ID;
            GFX          graphicsInit = GFX.Instance;
            DialogueData dialogueInit = DialogueData.Instance;

            NarBox = new NarBox();

            // create NPCs
            NPCDict = new Dictionary <string, NPC>();
            NPC aisya = new NPC("Aisya");

            aisya.Add(new CoDialogue("SCENE1001AISYA"));
            NPCDict.Add("Aisya", aisya);

            // initialize player and scene
            Player = new Player(new Vector2(9 * 16, 12 * 16));
            Scene  = new MainMenu();

            // intro dialogue
            GameDialogue = new CoDialogue();
        }
Exemple #2
0
        private IEnumerator DisplayDialogue(string key)
        {
            if (Running)
            {
                yield break;
            }
            else
            {
                Running = true;
            }

            DialogueInfo dialogueInfo = DialogueData.GetDialogueInfo(key);

            while (Running)
            {
                string   character = dialogueInfo.Character;
                string   text      = dialogueInfo.Text;
                string[] options   = dialogueInfo.Options;

                // log character dialogue
                Game1.NarBox.Log(character.ToUpper() + " -- \"" + text + "\"", Color.Red);
                for (int i = 0; i < options.GetLength(0); i++)
                {
                    Game1.NarBox.Log((i + 1) + ". " + options[i], Color.Yellow);
                }
                if (dialogueInfo.CanEnd)
                {
                    Game1.NarBox.Log(options.GetLength(0) + 1 + ". End", Color.Yellow);
                    leaveChoiceNum = options.GetLength(0);
                }
                Game1.NarBox.Log("");

                // wait for key input
                int canEnd = dialogueInfo.CanEnd ? 1 : 0;
                yield return(WaitForKeyPressed(options.GetLength(0) + canEnd));

                // fade all previous text
                Game1.NarBox.FadeAllLines();

                // resolve key input
                if (dialogueInfo.CanEnd && optionChoice == leaveChoiceNum)
                {
                    StopDisplayDialogue();
                    OnComplete?.Invoke();
                }
                else
                {
                    if (options[optionChoice] != "next")
                    {
                        Game1.NarBox.Log("You " + " -- \"" + options[optionChoice] + "\"", Color.Gray, true);
                    }
                    DialogueState = dialogueInfo.Paths[optionChoice];
                    dialogueInfo  = DialogueData.GetDialogueInfo(DialogueState);
                }
            }
        }