Beispiel #1
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            if (dialogBox.DialogState == DialogBox.State.Open)
            {
                if (currentText == null)
                {
                    if (dialogueIndex == dialogue.Count)
                    {
                        dialogBox.Close();
                    }
                    else
                    {
                        currentText = new AnimatedText(Engine, new Vector2(dialogBox.Size.Left + 5, dialogBox.Size.Top + 5), dialogBox.Size.Width - 10, dialogue[dialogueIndex].Text);
                        ++dialogueIndex;
                    }
                }
                else
                {
                    if (currentText.IsDone)
                    {
                        WaitingForInput = true;
                    }
                }
            }
            else if (dialogBox.DialogState == DialogBox.State.Closed)
            {
                IsDone = true;
            }

            if (WaitingForInput)
            {
                // TODO: display an animation at the bottom right corner of the dialog box
                // signaling that the user should press something

                // set a timer to make sure we don't go through this process too fast
                if (waitStartTime == 0.0)
                {
                    waitStartTime = gameTime.TotalGameTime.TotalMilliseconds;
                }
                else
                {
                    double currentSeconds = (gameTime.TotalGameTime.TotalMilliseconds - waitStartTime) / 1000;

                    if (currentSeconds > Global.Configuration.GetFloatConfig("TextBasedVariables", "AfterTextFinishedDisplayTime") && (Engine.Input.IsButtonDown(Global.Configuration.GetButtonConfig("GameControls", "TalkButton")) || Engine.Input.IsKeyDown(Global.Configuration.GetKeyConfig("GameControls", "TalkKey"))))
                    {
                        WaitingForInput = false;
                        Engine.RemoveComponent(currentText);
                        currentText   = null;
                        waitStartTime = 0.0;
                    }
                }
            }

            base.Update(gameTime);
        }
Beispiel #2
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            if(dialogBox.DialogState == DialogBox.State.Open) {
            if(currentText == null) {
              if(dialogueIndex == dialogue.Count) {
            dialogBox.Close();
              }
              else {
            currentText = new AnimatedText(Engine, new Vector2(dialogBox.Size.Left + 5, dialogBox.Size.Top + 5), dialogBox.Size.Width - 10, dialogue[dialogueIndex].Text);
            ++dialogueIndex;
              }
            }
            else {
              if(currentText.IsDone) {
            WaitingForInput = true;
              }
            }
              }
              else if(dialogBox.DialogState == DialogBox.State.Closed) {
            IsDone = true;
              }

              if(WaitingForInput) {
            // TODO: display an animation at the bottom right corner of the dialog box
            // signaling that the user should press something

            // set a timer to make sure we don't go through this process too fast
            if(waitStartTime == 0.0) {
              waitStartTime = gameTime.TotalGameTime.TotalMilliseconds;
            }
            else {
              double currentSeconds = (gameTime.TotalGameTime.TotalMilliseconds - waitStartTime) / 1000;

              if(currentSeconds > Global.Configuration.GetFloatConfig("TextBasedVariables", "AfterTextFinishedDisplayTime") && (Engine.Input.IsButtonDown(Global.Configuration.GetButtonConfig("GameControls", "TalkButton")) || Engine.Input.IsKeyDown(Global.Configuration.GetKeyConfig("GameControls", "TalkKey")))) {
            WaitingForInput = false;
            Engine.RemoveComponent(currentText);
            currentText = null;
            waitStartTime = 0.0;
              }
            }
              }

              base.Update(gameTime);
        }
Beispiel #3
0
        public DialogBox(Engine engine, bool animated)
            : base(engine)
        {
            DrawOrder    = (int)Global.Layers.TextBackground;
            Animated     = animated;
            animatedText = null;

            // default size of the rectangle is a 4:3 formatted box at the bottom of the screen
            int width = engine.Video.GraphicsDevice.Viewport.Width / 3 * 2;
            int x     = (engine.Video.GraphicsDevice.Viewport.Width - width) / 2;

            int y      = engine.Video.GraphicsDevice.Viewport.Bounds.Bottom - engine.Video.GraphicsDevice.Viewport.Height / 3;
            int height = engine.Video.GraphicsDevice.Viewport.Bounds.Bottom - y;

            if (!animated)
            {
                CurrentSize = Size;
                DialogState = State.Open;
            }
            else
            {
                CurrentSize = new Rectangle(x + width / 2, y + height / 2, 1, 1);
                DialogState = State.Opening;
            }
            Size             = new Rectangle(x, y, width, height);
            startTime        = 0.0;
            animationSeconds = Global.Configuration.GetFloatConfig("TextBasedVariables", "DialogExpansionSeconds");

            BackgroundColor = Color.Gray;
            OutlineColor    = Color.White;

            BackgroundTexture = new Texture2D(engine.Video.GraphicsDevice, 1, 1);
            BackgroundTexture.SetData(new Color[] { BackgroundColor });
            OutlineTexture = new Texture2D(engine.Video.GraphicsDevice, 1, 1);
            OutlineTexture.SetData(new Color[] { OutlineColor });

            Engine.AddComponent(this);
        }
Beispiel #4
0
        public DialogBox(Engine engine, bool animated)
            : base(engine)
        {
            DrawOrder = (int)Global.Layers.TextBackground;
              Animated = animated;
              animatedText = null;

              // default size of the rectangle is a 4:3 formatted box at the bottom of the screen
              int width = engine.Video.GraphicsDevice.Viewport.Width / 3 * 2;
              int x = (engine.Video.GraphicsDevice.Viewport.Width - width) / 2;

              int y = engine.Video.GraphicsDevice.Viewport.Bounds.Bottom - engine.Video.GraphicsDevice.Viewport.Height / 3;
              int height = engine.Video.GraphicsDevice.Viewport.Bounds.Bottom - y;

              if(!animated) {
            CurrentSize = Size;
            DialogState = State.Open;
              }
              else {
            CurrentSize = new Rectangle(x + width / 2, y + height / 2, 1, 1);
            DialogState = State.Opening;
              }
              Size = new Rectangle(x, y, width, height);
              startTime = 0.0;
              animationSeconds = Global.Configuration.GetFloatConfig("TextBasedVariables", "DialogExpansionSeconds");

              BackgroundColor = Color.Gray;
              OutlineColor = Color.White;

              BackgroundTexture = new Texture2D(engine.Video.GraphicsDevice, 1, 1);
              BackgroundTexture.SetData(new Color[] { BackgroundColor });
              OutlineTexture = new Texture2D(engine.Video.GraphicsDevice, 1, 1);
              OutlineTexture.SetData(new Color[] { OutlineColor });

              Engine.AddComponent(this);
        }