Пример #1
0
        /// <summary>
        /// Updates this Response.
        /// </summary>
        public virtual void Update(DialogueScreen screen, bool isSelected, GameTime gameTime)
        {
            // When the menu selection changes, entries gradually fade between
            // their selected and deselected appearance, rather than instantly
            // popping to the new state.
            float fadeSpeed = (float)gameTime.ElapsedGameTime.TotalSeconds * 4;

            if (isSelected)
                selectionFade = Math.Min(selectionFade + fadeSpeed, 1);
            else
                selectionFade = Math.Max(selectionFade - fadeSpeed, 0);
        }
Пример #2
0
 /// <summary>
 /// Queries how wide the response is, used for centering on the screen.
 /// </summary>
 public virtual int GetWidth(DialogueScreen screen)
 {
     return (int)screen.ScreenManager.Font.MeasureString(Text).X;
 }
Пример #3
0
        /// <summary>
        /// Draws this Response. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(DialogueScreen screen, bool isSelected, GameTime gameTime)
        {
            // Draw the selected entry in yellow, otherwise white.
            Color color = isSelected ? Color.Yellow : Color.White;
            String displayText = isSelected ? selectedText : text;

            // Pulsate the size of the selected menu entry.
            double time = gameTime.TotalGameTime.TotalSeconds;

            // float pulsate = (float)Math.Sin(time * 6) + 1;

            float scale = 1; // +pulsate * 0.05f * selectionFade;

            // Modify the alpha to fade text out during transitions.
            color *= screen.TransitionAlpha;

            // Draw text, centered on the middle of each line.
            ScreenManager screenManager = screen.ScreenManager;
            SpriteBatch spriteBatch = screenManager.SpriteBatch;
            SpriteFont font = screenManager.Font;

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);

            spriteBatch.DrawString(font, displayText, position, color, 0,
                                   origin, scale, SpriteEffects.None, 0);
        }
Пример #4
0
 /// <summary>
 /// Queries how much space this response requires.
 /// </summary>
 public virtual int GetHeight(DialogueScreen screen)
 {
     return screen.ScreenManager.Font.LineSpacing;
 }
Пример #5
0
        /// <summary>
        /// Static method for creating a DialogueScreen from the gameplay screen.
        /// </summary>
        /// <param name="id">The GUID of the <see cref="NPCPrompt"/>NPCPrompt</see> in the database.</param>
        /// <returns>A new instance of a DialogueScreen</returns>
        public static DialogueScreen InitializeDialogueBox(Guid id)
        {
            DialogueScreen openingPrompt = new DialogueScreen(id);
            if (openingPrompt.Prompt.ResponseRequired)
            {
                openingPrompt.Responses = EngineGame.Instance.Database.FindResponses(id);
                openingPrompt.AttachResponseEvents();
            }
            else
            {
                openingPrompt.Prompt.IncludeUsageText();
            }

            foreach (IDialogueAction action in openingPrompt.Prompt.PromptActions)
            {
                action.ExecuteAction();
            }
            return openingPrompt;
        }