Пример #1
0
 public Tile(Rectangle r, String tileType, DialogTree <DialogBox> t, Texture2D text, SpriteBatch sb)
 {
     rect = r;
     setTile(tileType);
     tree    = t;
     texture = text;
     this.sb = sb;
 }
Пример #2
0
        public DialogTree <T> AddChild(T value)
        {
            var node = new DialogTree <T>(value)
            {
                Parent = this
            };

            _children.Add(node);
            return(node);
        }
Пример #3
0
 public TreeHelper(DialogTree <DialogBox> dT, SpriteBatch sb, ContentManager content, GraphicsDeviceManager graphics, Player p)
 {
     this.dT         = dT;
     curTreeLoc      = dT;
     isDialogVisable = false;
     isChoiceVisable = false;
     count           = 0;
     nextframe       = false;
     this.sb         = sb;
     this.content    = content;
     choiceMaker     = new DialogueChoices(sb, content, curTreeLoc.Value.Choices, graphics);
     player          = p;
 }
Пример #4
0
        private DialogTree <DialogBox> BuildTree(List <string> dialogue, DialogTree <DialogBox> parent)
        {
            string dFB = "";
            DialogTree <DialogBox> tree = parent;

            if (cL < dialogue.Count && !dialogue[cL].Contains("*+ "))
            {
                List <string> initdB  = new List <string>();
                List <string> choices = new List <string>();
                while (!dialogue[cL].Contains("*+ "))
                {
                    dFB += dialogue[cL];
                    initdB.Add(dialogue[cL]);
                    cL++;
                }
                int numOfChoices = Convert.ToInt32(dialogue[cL].Substring(3));
                if (numOfChoices > 1)
                {
                    foreach (string s in initdB[initdB.Count - 1].Substring(2).Split(','))
                    {
                        choices.Add(s);
                    }
                    initdB.RemoveAt(initdB.Count - 1);
                }
                if (choices.Count == 0)
                {
                    choices = new List <string>();
                }
                string dT = "";
                foreach (string s in initdB)
                {
                    dT += "\n" + s;
                }
                tree.AddChild(new DialogBox(sb, cM, g, dFB, choices));
                for (int curChoice = 0; curChoice < numOfChoices; curChoice++)
                {
                    if (numOfChoices < parent.Children.Count - 1)
                    {
                        tree = BuildTree(dialogue, parent.Children[curChoice]);
                    }
                }
            }
            else
            {
                cL++;
            }
            return(tree);
        }
Пример #5
0
        internal DialogTree <DialogBox> BuildTreeFromFile(string path)
        {
            StreamReader  read         = new StreamReader(path);
            List <string> dialogue     = new List <string>();
            List <string> choices      = new List <string>();
            int           numOfChoices = 0;

            cL = 0;
            while (!read.EndOfStream)
            {
                string line = read.ReadLine();
                if (!line.Contains("*//"))
                {
                    dialogue.Add(line);
                }
            }
            List <string> initdB = new List <string>();

            foreach (string line in dialogue)
            {
                initdB.Add(line); //initial DialogBox is the parent
                if (line.Contains("*+"))
                {
                    numOfChoices = Convert.ToInt32(line.Substring(3));
                    break;
                }
            }
            foreach (string s in initdB[initdB.Count - 2].Substring(2).Split(','))
            {
                choices.Add(s);
            }
            initdB.RemoveAt(initdB.Count - 1);
            string dT = "";

            foreach (string s in initdB)
            {
                dT += "\n" + s;
            }
            DialogTree <DialogBox> temp = new DialogTree <DialogBox>(new DialogBox(sb, cM, g, dT, choices));

            for (int x = 0; x < numOfChoices; x++)
            {
                temp = BuildTree(dialogue, temp);
            }
            return(temp);
        }
Пример #6
0
        public DialogueTree(SpriteBatch spriteBatch, ContentManager content, GraphicsDeviceManager graphics, string path)
        {
            this.spriteBatch = spriteBatch;
            this.content     = content;
            this.graphics    = graphics;
            font             = content.Load <SpriteFont>("DialogChoiceFont");
            text             = new string[7];
            readFile(path);


            DialogBox parent = new DialogBox(this.spriteBatch, this.content, this.graphics, text[0]);

            tree        = new DialogTree <DialogBox>(parent);
            children    = new DialogBox[2];
            children[0] = new DialogBox(spriteBatch, content, graphics, text[1]);//the text will need to be changed
            children[1] = new DialogBox(spriteBatch, content, graphics, text[2]);
            tree.AddChildren(children);
        }
Пример #7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // TODO: use this.Content to load your game content here
            song1 = Content.Load <Song>("bensound-acousticbreeze");
            MediaPlayer.Play(song1);
            npcT[0] = Content.Load <Texture2D>("sprite_0");
            npcT[1] = Content.Load <Texture2D>("sprite_1");
            npcT[2] = Content.Load <Texture2D>("sprite_2");
            //shoesT = Content.Load<Texture2D>("Temporary/shoes");
            //keyT = Content.Load<Texture2D>("Temporary/key");

            player   = new Player(spriteBatch, this.Content.Load <Texture2D>("Hero"), new Rectangle(64, 64, spriteSize, spriteSize), 10f);
            camHand  = new CameraHandler(GraphicsDevice, new Vector2(64, 32), 2, 1, player.Speed);
            curLevel = new Level(spriteBatch, this.Content.Load <Texture2D>("start2"), spriteSize, GraphicsDevice.Viewport.Bounds, player, graphics, this.Content);

            //DialogTree<DialogBox> T = new DialogTree<DialogBox>(new DialogBox(spriteBatch, Content, graphics, "Hifdsafe!", new List<string> { "Greet back" }));
            //T.AddChild(new DialogBox(spriteBatch, Content, graphics, "Hello.", new List<string> { "Let him introduce himself" }));
            //T[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "My name is Pete Hamburg. I'm a high school student at Allen High School. I'm a junior. I have zero social skills, no friends, and my grades are below average, to say the least. I have been like this since middle school, and they always said that high school would be a new start for me, but that wasn't the case. My family is dysfunctional. My dad left us when I was in elementary school, and I haven't seen him since. I hardly remember what he looks like. My mother works two jobs to accommodate for us, one shift from the morning till five in the afternoon, and then she joins the night shift and gets home at around 2 in the morning every night. I have to take care of myself for the most part, at least I'm independent. Too independent it seems though, since I can't make friends and all of my love interests have ended miserably. What do you want me to do?", new List<string> { "Go to school", "Skip and eat breakfast", "Keep sleeping" }));
            //T[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Wow, school is as boring as usual. I wish someone would come and bully me... *Bully walks up to character and pushes character down*", new List<string> { "Fight the bully", "Get bullied" }));
            //T[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "MMM, breakfast", new List<string> { "Eat food", "Throw away food" }));
            //T[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Keep sleeping", new List<string> { "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" }));
            //T[0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Punches, kicks, somersaults into a hind kick, and lastly fatal blow.", new List<string> { }));
            //T[0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Oh no, I'm getting bullied. Ow, ouch, oof, yikes.", new List<string> { }));
            //T[0][0][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "Stomach capacity = 100%", new List<string> { }));
            //T[0][0][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "Nevermind, I guess this doesn't look that great. Better throw it away!", new List<string> { }));
            //T[0][0][2].AddChild(new DialogBox(spriteBatch, Content, graphics, "Zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...", new List<string> { }));
            //curLevel.setTile(0, 0, new Tile(new Rectangle(0 * 64, 0 * 64, 64, 64), "dialog", T));

            DialogTree <DialogBox> dT1NPC1 = new DialogTree <DialogBox>(new DialogBox(spriteBatch, Content, graphics, "Oh? Well what do we have here...", new List <string> {
                "..."
            }));                                                                                                                                                                      //Used when the running shoes have not been acquired

            dT1NPC1.AddChild(new DialogBox(spriteBatch, Content, graphics, "Not much of a talker are you. Well, no worries, you mind helping me for a sec?", new List <string> {
                "Nod head.", "Back down from helping this friendly stranger."
            }));
            dT1NPC1[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "You see that item all the way yonder there? I would greatly appreciate if you could get it for me. My legs aren't as useful as they used to be.", new List <string> {
            }));
            dT1NPC1[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "...Okay?", new List <string> {
            }));
            curLevel.setTile(0, 0, new Tile(npc[0], "dialog", dT1NPC1, npcT[0], spriteBatch));

            //DialogTree<DialogBox> dT2NPC1 = new DialogTree<DialogBox>(new DialogBox(spriteBatch, Content, graphics, "Wow, that was pretty quick. Did you manage to get me that item?", new List<string> { "Hand over item.", "Keep this item." })); //Used when the running shoes have been acquired
            //dT2NPC1.AddChild(new DialogBox(spriteBatch, Content, graphics, "Hmmmmmmm...", new List<string> { "Stare as the stranger deeply examines the item." }));
            //dT2NPC1.AddChild(new DialogBox(spriteBatch, Content, graphics, "Really??? Nothing? How strange. I guess I better look around myself. Thanks anyway.", new List<string> { }));
            //dT2NPC1[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "It's just a pair of running shoes. And they don't fit me... how about this, you can have them. Think of it as thanks for helping me.", new List<string> { "Take the running shoes and equip them.", "Decline the offer by shaking your head side to side." }));
            //dT2NPC1[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "They fit you quite nicely don't they? Oh yes, how could I forget. What might your name be child?", new List<string> { "..." }));
            //dT2NPC1[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Oh come on now, just take them. Here.", new List<string> { "Accept the running shoes hesitantly." }));
            //dT2NPC1[0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Now that I think about it, you haven't spoken even an inkling yet. Might you be a mute?", new List<string> { "Nods head." }));
            //dT2NPC1[0][0][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "Alright, thanks for help. See ya around I guess.", new List<string> {  }));
            //dT2NPC1[0][0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Hahahaha! This is might first time being sorry for someone. Well, the names Chris Burkingham. You... I'll call you Bud. How about it?", new List<string> { "Accept"}));
            //dT2NPC1[0][0][0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Alright Bud, I think it's about time that I go. See ya around!", new List<string> {  }));
            ////curLevel.setTile(0, 0, new Tile(new Rectangle(0 * 64, 0 * 64, 64, 64), "dialog", dT2NPC1));

            DialogTree <DialogBox> dT1NPC2 = new DialogTree <DialogBox>(new DialogBox(spriteBatch, Content, graphics, "Sigh...", new List <string> {
                "Look at the depressed student."
            }));

            dT1NPC2.AddChild(new DialogBox(spriteBatch, Content, graphics, "Hm? What are you looking at?", new List <string> {
                "..."
            }));
            dT1NPC2[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Are you mocking me?!?!?", new List <string> {
                "Shake head."
            }));
            dT1NPC2[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "What's your freaking name!", new List <string> {
                "Point to mouth and throat"
            }));
            dT1NPC2[0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "You can't talk? Man, my luck is the best isn't it. Just leave me alone.", new List <string> {
                "Pat his head.", "Stare.", "Leave"
            }));
            dT1NPC2[0][0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "DO YOU WANT ME TO KILL YOU?!?!?! If you're not leaving, then I'm leaving!!!", new List <string> {
            }));
            dT1NPC2[0][0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "...", new List <string> {
                "Stare intensely.", "Look at the student worriedly"
            }));
            dT1NPC2[0][0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "You leave the student alone.", new List <string> {
            }));
            dT1NPC2[0][0][0][0][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "GET AWAY FROM ME!!!", new List <string> {
            }));
            dT1NPC2[0][0][0][0][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "Sigh. Look, I'm fine, I just lost my keys, that's all. Mind leaving me alone?", new List <string> {
                "Try to get more information about the keys by showing him your keys.", "Leave respectfully."
            }));
            dT1NPC2[0][0][0][0][1][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "Those are your keys right? Mine is both silver and smaller.", new List <string> {
            }));
            dT1NPC2[0][0][0][0][1][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "You walk away.", new List <string> {
            }));
            curLevel.setTile(2, 0, new Tile(npc[1], "dialog", dT1NPC2, npcT[1], spriteBatch));

            //DialogTree<DialogBox> dT2NPC2 = new DialogTree<DialogBox>(new DialogBox(spriteBatch, Content, graphics, "What do you want?", new List<string> { "Hand over his keys.", "Leave." }));
            //dT2NPC2.AddChild(new DialogBox(spriteBatch, Content, graphics, "You found my keys? Heck yeah! Now I can get outta here! Thanks bro, you're the best! Want me to give you a ride?", new List<string> { "Shake head." }));
            //dT2NPC2.AddChild(new DialogBox(spriteBatch, Content, graphics, "", new List<string> { }));
            //dT2NPC2[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "No, huh. Well, I'm gonna get goin' then. Cya.", new List<string> { }));
            //curLevel.setTile(0, 0, new Tile(new Rectangle(0 * 64, 0 * 64, 64, 64), "dialog", dT2NPC2));

            DialogTree <DialogBox> dT1NPC3 = new DialogTree <DialogBox>(new DialogBox(spriteBatch, Content, graphics, "HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA!!!", new List <string> {
                "Look at the person on the roof with you.", "Leave."
            }));

            dT1NPC3.AddChild(new DialogBox(spriteBatch, Content, graphics, "Look here world! I can fly!!!", new List <string> {
                "Run up to the person and grab them.", "Watch silently"
            }));
            dT1NPC3.AddChild(new DialogBox(spriteBatch, Content, graphics, "You left.", new List <string> {
            }));
            dT1NPC3[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "OHHH!?!?", new List <string> {
                "Throw them down on the ground."
            }));
            dT1NPC3[0].AddChild(new DialogBox(spriteBatch, Content, graphics, "...", new List <string> {
                "Watch as he abruptly stops and just stares into the sky."
            }));
            dT1NPC3[0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Hey, what are you doing? That hurt!", new List <string> {
                "Intensely stare at the person with a strained look."
            }));
            dT1NPC3[0][1].AddChild(new DialogBox(spriteBatch, Content, graphics, "You've been staring for some time. Do you think I'm crazy?", new List <string> {
                "No.", "Yes.", "Really crazy. Worthy enough to leave him be."
            }));
            dT1NPC3[0][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Hahaha, boy, you truly are innocent. Were you thinking I was jumping off the roof? Too bad! I was just reminiscing my childhood. You don't need to mind this old man.", new List <string> {
            }));
            dT1NPC3[0][1][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Weird, wouldn't normally seeing a seemingly suicidal man spell out his doom be a strange occurrence?", new List <string> {
                "Yes.", "No."
            }));
            dT1NPC3[0][1][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Brutally honest aren't you... Hey, what do you think the point of life is? I'm growing older as the days pass and all I can see to do is reminisce about the past.", new List <string> {
            }));
            dT1NPC3[0][1][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "You leave.", new List <string> {
            }));
            dT1NPC3[0][1][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "Hm...so you are normal. Ok well, don't mind me, I'll still be kicking even after the world ends. HAHAHAHAHAHAHAHAHAHA!!!", new List <string> {
            }));
            dT1NPC3[0][1][0][0].AddChild(new DialogBox(spriteBatch, Content, graphics, "I think I'll leave you to your own devices then.", new List <string> {
            }));
            curLevel.setTile(4, 0, new Tile(npc[2], "dialog", dT1NPC3, npcT[2], spriteBatch));

            s = new StartScreen(spriteBatch, this.Content, graphics);
            e = new EndScreen(spriteBatch, this.Content, graphics);
        }
Пример #8
0
 public Tile(Rectangle r, String tileType, DialogTree <DialogBox> t)
 {
     rect = r;
     setTile(tileType);
     tree = t;
 }
Пример #9
0
 public void startDialog(DialogTree <DialogBox> t)
 {
     tree = new TreeHelper(t, sb, content, Game1.graphics, player);
     tree.DialogVisable = true;
     MediaPlayer.Play(talking);
 }
Пример #10
0
 public bool RemoveChild(DialogTree <T> node)
 {
     return(_children.Remove(node));
 }