Esempio n. 1
0
        public override void Update(float gameTime, MainSprite main)
        {
            //talking to dogs
            KeyboardState keyboardState = Keyboard.GetState();

            if (data.Equals("Dave"))
            {
                Console.WriteLine("You reached the exit");
                if (oldState.IsKeyUp(Keys.Enter) && keyboardState.IsKeyDown(Keys.Enter))
                {
                    //lock the character's animation and allow the dialog box to be drawn
                    drawDialog  = true;
                    main.locked = true;
                    dialogReader.nextLine();

                    //reset the dialog reader and unlock character animation once we've reached the end of the dialog
                    if (dialogReader.isDialogDone())
                    {
                        main.locked  = false;
                        drawDialog   = false;
                        dialogReader = new DialogReader();
                        dialogReader.getDialog(@"C:\Users\ember\source\repos\firstrate\Content\TestDialog.txt");
                    }
                }
            }

            if (drawDialog)
            {
                currentDialog = dialogReader.typeLine(animationTimer);
            }

            //check if they are at the exit
            if (data.Equals("Exit"))
            {
                // isDone = true;
                Console.WriteLine("You reached the exit"); //never reaching this point -- have to remember how data is set
            }


            //dog animation
            animationTimer += gameTime;
            if (animationTimer > 450)
            {
                daveAnimation.Update();
                animationTimer = 0;
            }

            oldState = keyboardState;
        }
Esempio n. 2
0
        public FirstScreen(ContentManager Content)
        {
            levelMap    = new LevelMap(700, 0, 700, 0);
            coordinates = new List <int>();
            isDone      = false;
            data        = "";

            //upper wall
            //would like to streamline the adding process at some point
            coordinates.Add(1);
            coordinates.Add(1);
            coordinates.Add(2);
            coordinates.Add(1);
            coordinates.Add(3);
            coordinates.Add(1);
            coordinates.Add(4);
            coordinates.Add(1);
            coordinates.Add(5);
            coordinates.Add(1);
            coordinates.Add(6);
            coordinates.Add(1);
            coordinates.Add(7);
            coordinates.Add(1);
            coordinates.Add(8);
            coordinates.Add(1);
            coordinates.Add(9);
            coordinates.Add(1);

            //dog
            levelMap.addObjectsWithName(5, 5, "Dave");
            //exit doorway at top right
            levelMap.addObjectsWithName(10, 0, "Exit");//this sorta works, but not very well -- need something better

            //load content
            firstScreen  = Content.Load <Texture2D>("tutorialscreen/tutotialroom");
            dialogScreen = Content.Load <Texture2D>("tutorialscreen/dialogscreen");

            //load font
            retroFont = Content.Load <SpriteFont>("fonts/RetroFont");

            daveTheDog    = Content.Load <Texture2D>("tutorialscreen/dogsprite");
            daveAnimation = new AnimateSprite(daveTheDog, 2, 4, false);

            //dialog for dog
            //using absolute path for now -- will be changed in the future, but this is good enough for now
            dialogReader.getDialog(@"C:\Users\ember\source\repos\firstrate\Content\TestDialog.txt");

            levelMap.addObjects(coordinates);
        }
Esempio n. 3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            answerBox.SetData(new Color[] { Color.LemonChiffon });

            //singleton!!!
            if (dialogReader == null)
            {
                dialogReader  = new DialogReader();
                currentDialog = dialogReader.getDialog
                                    (@"C:\Users\ember\source\repos\Aljourney\Aljourney\Dialogs\IntroDialog.txt");
            }

            /*get mouse click to progress dialog box
             * where dialogCounter is the current position in the array of dialogs
             * currentDialog is the array of dialogs retrieved from the file
             * currentLine is the line we are going to type to the screen*/
            if (dialogCounter == 0)
            {
                currentLine = currentDialog[dialogCounter];
                dialogCounter++;
            }
            MouseState mouseState = Mouse.GetState();

            if (mouseState.LeftButton == ButtonState.Pressed && !oldMouseState.Equals(mouseState))
            {
                mouseClicks++;
                if (mouseClicks % 2 == 1)
                {
                    textCounter = currentLine.Length;
                    typedLine   = "";
                    foreach (char c in currentLine)
                    {
                        typedLine += c;
                    }
                }
                else
                {
                    if (dialogCounter < currentDialog.Count)
                    {
                        currentLine = currentDialog[dialogCounter];
                        textCounter = 0;
                        typedLine   = "";
                    }
                    dialogCounter++;
                }
            }
            oldMouseState = mouseState;

            //time Rho's animation
            rhoTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (rhoTimer > 250)
            {
                animateRho.Update();
                animateXCharacter.Update();
                animateYCharacter.Update();
                rhoTimer = 0;
            }

            textTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (textTimer > 100)
            {
                if (textCounter < currentLine.Length)
                {
                    typedLine += currentLine[textCounter];
                }
                if (textCounter <= currentLine.Length)
                {
                    textCounter++;
                }
                if (textCounter == currentLine.Length)
                {
                    mouseClicks++;
                }
                textTimer = 0;
            }
            base.Update(gameTime);
        }